[RFC PATCH 2/5] md: clear stale sync flags when frozen before sync starts

Zheng Qixing posted 5 patches 1 month, 1 week ago
There is a newer version of this series
[RFC PATCH 2/5] md: clear stale sync flags when frozen before sync starts
Posted by Zheng Qixing 1 month, 1 week ago
From: Zheng Qixing <zhengqixing@huawei.com>

In md_check_recovery(), add clearing of all sync flags when sync is not
running. This fixes the issue where a sync operation is requested, then
'frozen' is executed before MD_RECOVERY_RUNNING is set, leaving stale
operation flags that cause subsequent operations to fail with EBUSY.

Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
---
 drivers/md/md.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index ccaa2e6fe079..52e09a9a9288 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -10336,6 +10336,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
Re: [RFC PATCH 2/5] md: clear stale sync flags when frozen before sync starts
Posted by Li Nan 1 month ago

在 2025/12/31 15:09, Zheng Qixing 写道:
> From: Zheng Qixing <zhengqixing@huawei.com>
> 
> In md_check_recovery(), add clearing of all sync flags when sync is not
> running. This fixes the issue where a sync operation is requested, then
> 'frozen' is executed before MD_RECOVERY_RUNNING is set, leaving stale
> operation flags that cause subsequent operations to fail with EBUSY.
> 
> Signed-off-by: Zheng Qixing <zhengqixing@huawei.com>
> ---
>   drivers/md/md.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index ccaa2e6fe079..52e09a9a9288 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -10336,6 +10336,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);
>   		}
>   

Merge into one with the previous fix patch. Do not introduce an issue
and fix it later.

-- 
Thanks,
Nan