mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] md: ensure resync is prioritized over recovery
@ 2025-02-13 13:15 linan666
  2025-02-14  1:11 ` Yu Kuai
  0 siblings, 1 reply; 3+ messages in thread
From: linan666 @ 2025-02-13 13:15 UTC (permalink / raw)
  To: song, yukuai3
  Cc: linux-raid, linux-kernel, linan666, yangerkun, zhangxiaoxu5, wanghai38

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(-)

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;
-- 
2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] md: ensure resync is prioritized over recovery
  2025-02-13 13:15 [PATCH] md: ensure resync is prioritized over recovery linan666
@ 2025-02-14  1:11 ` Yu Kuai
  2025-02-14  1:40   ` Yu Kuai
  0 siblings, 1 reply; 3+ messages in thread
From: Yu Kuai @ 2025-02-14  1:11 UTC (permalink / raw)
  To: linan666, song
  Cc: linux-raid, linux-kernel, yangerkun, zhangxiaoxu5, wanghai38, yukuai (C)


在 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] md: ensure resync is prioritized over recovery
  2025-02-14  1:11 ` Yu Kuai
@ 2025-02-14  1:40   ` Yu Kuai
  0 siblings, 0 replies; 3+ messages in thread
From: Yu Kuai @ 2025-02-14  1:40 UTC (permalink / raw)
  To: Yu Kuai, linan666, song
  Cc: linux-raid, linux-kernel, yangerkun, zhangxiaoxu5, wanghai38, yukuai (C)

在 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
> 
> .
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-14  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-13 13:15 [PATCH] md: ensure resync is prioritized over recovery linan666
2025-02-14  1:11 ` Yu Kuai
2025-02-14  1:40   ` Yu Kuai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®