[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260203061259.609206-3-zhengqixing@huaweicloud.com>
Date: Tue, 3 Feb 2026 14:12:56 +0800
From: Zheng Qixing <zhengqixing@...weicloud.com>
To: song@...nel.org,
yukuai@...as.com,
linan122@...wei.com
Cc: xni@...hat.com,
linux-raid@...r.kernel.org,
linux-kernel@...r.kernel.org,
yi.zhang@...wei.com,
yangerkun@...wei.com,
houtao1@...wei.com,
zhengqixing@...wei.com
Subject: [RFC v2 2/5] md: serialize requested sync actions and clear stale request state
From: Zheng Qixing <zhengqixing@...wei.com>
In handle_requested_sync_action(), return -EBUSY when
MD_RECOVERY_REQUESTED is already set. This serializes requested sync
actions (such as check or repair) and avoids a race window where a
second sync request can be issued before MD_RECOVERY_RUNNING is set,
resulting in the later request being neither rejected nor executed.
Additionally, in md_check_recovery(), clear requested-sync related
state bits when no recovery operation is running. This prevents stale
request state from persisting in cases where a sync action is queued
and 'frozen' is written before MD_RECOVERY_RUNNING is set, which would
cause subsequent sync requests to spuriously fail with -EBUSY.
Signed-off-by: Zheng Qixing <zhengqixing@...wei.com>
---
drivers/md/md.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 84af578876e2..7fe02ee21d3e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -668,6 +668,9 @@ void mddev_put(struct mddev *mddev)
static int handle_requested_sync_action(struct mddev *mddev,
enum sync_action action)
{
+ if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
+ return -EBUSY;
+
switch (action) {
case ACTION_CHECK:
set_bit(MD_RECOVERY_CHECK, &mddev->recovery);
@@ -10318,6 +10321,9 @@ void md_check_recovery(struct mddev *mddev)
queue_work(md_misc_wq, &mddev->sync_work);
} else {
clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
+ clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
+ clear_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
+ clear_bit(MD_RECOVERY_CHECK, &mddev->recovery);
wake_up(&resync_wait);
}
--
2.39.2
Powered by blists - more mailing lists