* [PATCH] md: use interruptible apis in idle/frozen_sync_thread
@ 2023-09-06 8:44 Li Nan
[not found] ` <e2befbc6-dfc4-f469-78f0-b648d0ad205d@huaweicloud.com>
0 siblings, 1 reply; 3+ messages in thread
From: Li Nan @ 2023-09-06 8:44 UTC (permalink / raw)
To: song
Cc: linux-raid, linux-kernel, linan122, yukuai3, yi.zhang, houtao1,
yangerkun
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
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <e2befbc6-dfc4-f469-78f0-b648d0ad205d@huaweicloud.com>]
* Re: [PATCH] md: use interruptible apis in idle/frozen_sync_thread [not found] ` <e2befbc6-dfc4-f469-78f0-b648d0ad205d@huaweicloud.com> @ 2023-09-08 20:29 ` Song Liu 2023-09-28 6:31 ` Yu Kuai 0 siblings, 1 reply; 3+ messages in thread From: Song Liu @ 2023-09-08 20:29 UTC (permalink / raw) To: Yu Kuai Cc: Li Nan, linux-raid, linux-kernel, yi.zhang, houtao1, yangerkun, yukuai (C) On Wed, Sep 6, 2023 at 11:31 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: > > 在 2023/09/06 16:44, Li Nan 写道: > > 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. > > > LGTM > > Reviewed-by: Yu Kuai <yukuai3@huawei.com> > > > Signed-off-by: Li Nan <linan122@huawei.com> I think we will need a fix tag and send this via md-fixes branch (to 6.6)? Thanks, Song > > --- > > 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); > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] md: use interruptible apis in idle/frozen_sync_thread 2023-09-08 20:29 ` Song Liu @ 2023-09-28 6:31 ` Yu Kuai 0 siblings, 0 replies; 3+ messages in thread From: Yu Kuai @ 2023-09-28 6:31 UTC (permalink / raw) To: Song Liu, Yu Kuai Cc: Li Nan, linux-raid, linux-kernel, yi.zhang, houtao1, yangerkun, yukuai (C) Hi, 在 2023/09/09 4:29, Song Liu 写道: > On Wed, Sep 6, 2023 at 11:31 PM Yu Kuai <yukuai1@huaweicloud.com> wrote: >> >> 在 2023/09/06 16:44, Li Nan 写道: >>> 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. >>> >> LGTM >> >> Reviewed-by: Yu Kuai <yukuai3@huawei.com> >> >>> Signed-off-by: Li Nan <linan122@huawei.com> > > I think we will need a fix tag and send this via md-fixes branch (to 6.6)? > I agree, Nan, please resend this patch. Thanks, Kuai > Thanks, > Song > > > >>> --- >>> 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); >>> >> > . > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-28 6:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-06 8:44 [PATCH] md: use interruptible apis in idle/frozen_sync_thread Li Nan
[not found] ` <e2befbc6-dfc4-f469-78f0-b648d0ad205d@huaweicloud.com>
2023-09-08 20:29 ` Song Liu
2023-09-28 6:31 ` Yu Kuai
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).