linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Li Nan <linan122@huawei.com>
To: <song@kernel.org>
Cc: <linux-raid@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linan122@huawei.com>, <yukuai3@huawei.com>,
	<yi.zhang@huawei.com>, <houtao1@huawei.com>,
	<yangerkun@huawei.com>
Subject: [PATCH] md: use interruptible apis in idle/frozen_sync_thread
Date: Wed, 6 Sep 2023 16:44:01 +0800	[thread overview]
Message-ID: <20230906084401.1027358-1-linan122@huawei.com> (raw)

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.

Signed-off-by: Li Nan <linan122@huawei.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 46badd13a687..52689adfa37f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4834,11 +4834,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);
@@ -4846,11 +4849,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


             reply	other threads:[~2023-09-06  8:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06  8:44 Li Nan [this message]
     [not found] ` <e2befbc6-dfc4-f469-78f0-b648d0ad205d@huaweicloud.com>
2023-09-08 20:29   ` [PATCH] md: use interruptible apis in idle/frozen_sync_thread Song Liu
2023-09-28  6:31     ` Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230906084401.1027358-1-linan122@huawei.com \
    --to=linan122@huawei.com \
    --cc=houtao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).