lkml.org 
[lkml]   [2023]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next 7/8] md: use new helper to stop sync_thread in __md_stop_writes()
Date
From: Yu Kuai <yukuai3@huawei.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@huawei.com>
Signed-off-by: Yu Kuai <yukuai1@huaweicloud.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
\
 
 \ /
  Last update: 2023-11-20 13:55    [W:0.439 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site