[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231110172834.3939490-3-yukuai1@huaweicloud.com>
Date: Sat, 11 Nov 2023 01:28:28 +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 2/8] md: use interruptible apis in idle/frozen_sync_thread()
From: Yu Kuai <yukuai3@...wei.com>
Before refactoring idle and frozen from action_store, interruptible apis
is used so that hungtask warning won't be triggered if it takes too long
to finish indle/frozen sync_thread. So change to use interruptible apis.
Fixes: 130443d60b1b ("md: refactor idle/frozen_sync_thread() to fix deadlock")
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
Signed-off-by: Yu Kuai <yukuai1@...weicloud.com>
---
drivers/md/md.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1701e2fb219f..5c9387369de1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4882,11 +4882,14 @@ static void idle_sync_thread(struct mddev *mddev)
{
int sync_seq = atomic_read(&mddev->sync_seq);
- mutex_lock(&mddev->sync_mutex);
+ if (mutex_lock_interruptible(&mddev->sync_mutex))
+ return;
+
clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
stop_sync_thread(mddev);
- wait_event(resync_wait, sync_seq != atomic_read(&mddev->sync_seq) ||
+ wait_event_interruptible(resync_wait,
+ sync_seq != atomic_read(&mddev->sync_seq) ||
!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery));
mutex_unlock(&mddev->sync_mutex);
@@ -4894,11 +4897,13 @@ static void idle_sync_thread(struct mddev *mddev)
static void frozen_sync_thread(struct mddev *mddev)
{
- mutex_lock(&mddev->sync_mutex);
+ if (mutex_lock_interruptible(&mddev->sync_mutex))
+ return;
+
set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
stop_sync_thread(mddev);
- wait_event(resync_wait, mddev->sync_thread == NULL &&
+ wait_event_interruptible(resync_wait, mddev->sync_thread == NULL &&
!test_bit(MD_RECOVERY_RUNNING, &mddev->recovery));
mutex_unlock(&mddev->sync_mutex);
--
2.39.2
Powered by blists - more mailing lists