diff mbox series

md: ensure resync is prioritized over recovery

Message ID 20250213131530.3698600-1-linan666@huaweicloud.com (mailing list archive)
State Accepted
Headers show
Series md: ensure resync is prioritized over recovery | expand

Commit Message

Li Nan Feb. 13, 2025, 1:15 p.m. UTC
From: Li Nan <linan122@huawei.com>

If a new disk is added during resync, the resync process is interrupted,
and recovery is triggered, causing the previous resync to be lost. In
reality, disk addition should not terminate resync, fix it.

Steps to reproduce the issue:
  mdadm -CR /dev/md0 -l1 -n3 -x1 /dev/sd[abcd]
  mdadm --fail /dev/md0 /dev/sdc

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/md.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Yu Kuai Feb. 14, 2025, 1:11 a.m. UTC | #1
在 2025/02/13 21:15, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> If a new disk is added during resync, the resync process is interrupted,
> and recovery is triggered, causing the previous resync to be lost. In
> reality, disk addition should not terminate resync, fix it.
> 
> Steps to reproduce the issue:
>    mdadm -CR /dev/md0 -l1 -n3 -x1 /dev/sd[abcd]
>    mdadm --fail /dev/md0 /dev/sdc
> 
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/md.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> [...]

Applied to md-6.14, thanks!

Kuai
Yu Kuai Feb. 14, 2025, 1:40 a.m. UTC | #2
在 2025/02/14 9:11, Yu Kuai 写道:
> 
> 在 2025/02/13 21:15, linan666@huaweicloud.com 写道:
>> From: Li Nan <linan122@huawei.com>
>>
>> If a new disk is added during resync, the resync process is interrupted,
>> and recovery is triggered, causing the previous resync to be lost. In
>> reality, disk addition should not terminate resync, fix it.
>>
>> Steps to reproduce the issue:
>>    mdadm -CR /dev/md0 -l1 -n3 -x1 /dev/sd[abcd]
>>    mdadm --fail /dev/md0 /dev/sdc
>>
>> Signed-off-by: Li Nan <linan122@huawei.com>
>> ---
>>   drivers/md/md.c | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>> [...]
> 
> Applied to md-6.14, thanks!

I'm trying to find a fixtag, looks like following patch that is 20 years
ago. Or earlier :(

24dd469d728d ("[PATCH] md: allow a manual resync with md")

I'll move this patch to md-6.15 with this fixtag, thanks!

Kuai

> 
> Kuai
> 
> .
>
diff mbox series

Patch

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 30b3dbbce2d2..827646b3eb59 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9460,6 +9460,13 @@  static bool md_choose_sync_action(struct mddev *mddev, int *spares)
 		return true;
 	}
 
+	/* Check if resync is in progress. */
+	if (mddev->recovery_cp < MaxSector) {
+		set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
+		clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
+		return true;
+	}
+
 	/*
 	 * Remove any failed drives, then add spares if possible. Spares are
 	 * also removed and re-added, to allow the personality to fail the
@@ -9476,13 +9483,6 @@  static bool md_choose_sync_action(struct mddev *mddev, int *spares)
 		return true;
 	}
 
-	/* Check if recovery is in progress. */
-	if (mddev->recovery_cp < MaxSector) {
-		set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
-		clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
-		return true;
-	}
-
 	/* Delay to choose resync/check/repair in md_do_sync(). */
 	if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
 		return true;