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. By the way, this change will cause a regression problem and which will be fixed by https://github.com/md-raid-utilities/mdadm/pull/182 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 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 | 71 +++++++++++++++++++++++++------------------------ drivers/md/md.h | 26 ++++++++++++++++-- 2 files changed, 60 insertions(+), 37 deletions(-) -- 2.32.0 (Apple Git-132)