Now del_gendisk is called in a queue work which has a small window that mdadm --stop command exits but the device node still exists. It causes trouble in regression tests. This patch set tries to resolve this problem. v1: replace MD_DELETED with MD_CLOSING v2: keep MD_CLOSING v3: call den_gendisk in mddev_unlock, and remove ->to_remove in stop path and adjust the order of patches v4: only remove the codes in stop path. v5: remove sysfs_remove in md_kobj_release and change EBUSY with ENODEV Xiao Ni (3): md: call del_gendisk in control path md: Don't clear MD_CLOSING until mddev is freed md: remove/add redundancy group only in level change drivers/md/md.c | 49 ++++++++++++++++++++++++++----------------------- drivers/md/md.h | 26 ++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 25 deletions(-) -- 2.32.0 (Apple Git-132)