[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231110172834.3939490-8-yukuai1@huaweicloud.com>
Date: Sat, 11 Nov 2023 01:28:33 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: song@...nel.org, xni@...hat.com, yukuai3@...wei.com, neilb@...e.de
Cc: linux-kernel@...r.kernel.org, linux-raid@...r.kernel.org,
yukuai1@...weicloud.com, yi.zhang@...wei.com, yangerkun@...wei.com
Subject: [PATCH -next 7/8] md: use new helper to stop sync_thread in __md_stop_writes()
From: Yu Kuai <yukuai3@...wei.com>
md_reap_sync_thread() should only be called when md_do_sync() is done,
for example, holding 'reconfig_mutex' to wait for md_do_sync() to be
done can deadlock(see details in commit 130443d60b1b ("md: refactor
idle/frozen_sync_thread() to fix deadlock")). Hence use new helper to
stop sync_thread.
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
Signed-off-by: Yu Kuai <yukuai1@...weicloud.com>
---
drivers/md/md.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7252fae0c989..35f3dd7db369 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6325,12 +6325,11 @@ static void md_clean(struct mddev *mddev)
static void __md_stop_writes(struct mddev *mddev)
{
- set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
- if (work_pending(&mddev->sync_work))
- flush_workqueue(md_misc_wq);
- if (mddev->sync_thread) {
- set_bit(MD_RECOVERY_INTR, &mddev->recovery);
- md_reap_sync_thread(mddev);
+ if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) {
+ stop_sync_thread(mddev, true, false);
+ mddev_lock_nointr(mddev);
+ } else {
+ set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
}
del_timer_sync(&mddev->safemode_timer);
--
2.39.2
Powered by blists - more mailing lists