• L
    md: fix sysfs duplicate file while adding rdev · 0b18dcc1
    Li Nan 提交于
    hulk inclusion
    category: bugfix
    bugzilla: 188553, https://gitee.com/openeuler/kernel/issues/I6TNFX
    CVE: NA
    
    --------------------------------
    
    rdev->del_work has not been queued to md_rdev_misc_wq and flush_workqueue
    will not flush it if tow threads add and remove same device. sysfs might
    WARN duplicate filename as below.
    
        //T1	             //T2
        mdadm write super
    			     add success
    			     remove
    			      unbind_rdev_from_array
    
        md_ioctl
         flush_workqueue
    			      INIT_WORK
                                   queue_work
         md_add_new_disk
          duplicate filename dev-xxx
    
    Check if there is any kobj with the same name, and return busy if true.
    
    Fixes: 5792a285 ("md: avoid a deadlock when removing a device from an md array via sysfs")
    Signed-off-by: NLi Nan <linan122@huawei.com>
    Reviewed-by: NHou Tao <houtao1@huawei.com>
    (cherry picked from commit 5815341f)
    0b18dcc1
md.c 260.9 KB