]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
md: update curr_resync_completed even when MD_RECOVERY_INTR is set
authorLi Nan <linan122@huawei.com>
Mon, 5 Jan 2026 11:02:54 +0000 (19:02 +0800)
committerYu Kuai <yukuai@fnnas.com>
Mon, 26 Jan 2026 05:16:17 +0000 (13:16 +0800)
An error sync IO may be done and sub 'recovery_active' while its
error handling work is pending. This work sets 'recovery_disabled'
and MD_RECOVERY_INTR, then later removes the bad disk without Faulty
flag. If 'curr_resync_completed' is updated before the disk is removed,
it could lead to reading from sync-failed regions.

With the previous patch, error IO will set badblocks or mark rdev as
Faulty, sync-failed regions are no longer readable. After waiting for
'recovery_active' to reach 0 (in the previous line), all sync IO has
*completed*, regardless of whether MD_RECOVERY_INTR is set. Thus, the
MD_RECOVERY_INTR check can be removed.

Link: https://lore.kernel.org/linux-raid/20260105110300.1442509-7-linan666@huaweicloud.com
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Yu Kuai <yukuai@fnnas.com>
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
drivers/md/md.c

index f1debba1b02661454b5166ba4cf350074da6a216..96f7eadbf959b404d3a866a731e2516ebb49c6cc 100644 (file)
@@ -9740,8 +9740,8 @@ update:
        wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active));
 
        if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
-           !test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&
            mddev->curr_resync >= MD_RESYNC_ACTIVE) {
+               /* All sync IO completes after recovery_active becomes 0 */
                mddev->curr_resync_completed = mddev->curr_resync;
                sysfs_notify_dirent_safe(mddev->sysfs_completed);
        }