This is a note to let you know that I've just added the patch titled md: Flush workqueue md_rdev_misc_wq in md_alloc() to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: md-flush-workqueue-md_rdev_misc_wq-in-md_alloc.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 5e8daf906f890560df430d30617c692a794acb73 Mon Sep 17 00:00:00 2001 From: David Sloan <david.sloan@xxxxxxxxxxxxx> Date: Thu, 11 Aug 2022 11:14:13 -0600 Subject: md: Flush workqueue md_rdev_misc_wq in md_alloc() From: David Sloan <david.sloan@xxxxxxxxxxxxx> commit 5e8daf906f890560df430d30617c692a794acb73 upstream. A race condition still exists when removing and re-creating md devices in test cases. However, it is only seen on some setups. The race condition was tracked down to a reference still being held to the kobject by the rdev in the md_rdev_misc_wq which will be released in rdev_delayed_delete(). md_alloc() waits for previous deletions by waiting on the md_misc_wq, but the md_rdev_misc_wq may still be holding a reference to a recently removed device. To fix this, also flush the md_rdev_misc_wq in md_alloc(). Signed-off-by: David Sloan <david.sloan@xxxxxxxxxxxxx> [logang@xxxxxxxxxxxx: rewrote commit message] Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx> Signed-off-by: Song Liu <song@xxxxxxxxxx> Signed-off-by: Hou Tao <houtao1@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5683,6 +5683,7 @@ static int md_alloc(dev_t dev, char *nam * completely removed (mddev_delayed_delete). */ flush_workqueue(md_misc_wq); + flush_workqueue(md_rdev_misc_wq); mutex_lock(&disks_mutex); error = -EEXIST; Patches currently in stable-queue which might be from david.sloan@xxxxxxxxxxxxx are queue-5.10/md-flush-workqueue-md_rdev_misc_wq-in-md_alloc.patch