summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sloan <david.sloan@eideticom.com>2022-08-11 11:14:13 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-03 11:44:51 +0100
commit1c44109c30946e4e8dfad785bb006fafad9b3caf (patch)
treedcd3a2b0644cc9c194376cb468e45fd8c4d1f1f9
parent80653a6e6e287eb982be9aa9f60f94382b6767b5 (diff)
downloadlinux-stable-1c44109c30946e4e8dfad785bb006fafad9b3caf.tar.gz
linux-stable-1c44109c30946e4e8dfad785bb006fafad9b3caf.tar.bz2
linux-stable-1c44109c30946e4e8dfad785bb006fafad9b3caf.zip
md: Flush workqueue md_rdev_misc_wq in md_alloc()
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@eideticom.com> [logang@deltatee.com: rewrote commit message] Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Hou Tao <houtao1@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/md/md.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3038e7ecb7e1..c0b34637bd66 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5683,6 +5683,7 @@ static int md_alloc(dev_t dev, char *name)
* completely removed (mddev_delayed_delete).
*/
flush_workqueue(md_misc_wq);
+ flush_workqueue(md_rdev_misc_wq);
mutex_lock(&disks_mutex);
error = -EEXIST;