Re: [PATCH v2 10/11] md/raid10: cleanup skip handling in raid10_sync_request

From: Yu Kuai
Date: Sat Nov 08 2025 - 05:54:40 EST


在 2025/11/6 19:59, linan666@xxxxxxxxxxxxxxx 写道:

> Skip a sector in raid10_sync_request() when it needs no syncing or no
> readable device exists. Current skip handling is unnecessary:
>
> - Use 'skip' label to reissue the next sector instead of return directly
> - Complete sync and return 'max_sectors' when multiple sectors are skipped
> due to badblocks
>
> The first is error-prone. For example, commit bc49694a9e8f ("md: pass in
> max_sectors for pers->sync_request()") removed redundant max_sector
> assignments. Since skip modifies max_sectors, `goto skip` leaves
> max_sectors equal to sector_nr after the jump, which is incorrect.
>
> The second causes sync to complete erroneously when no actual sync occurs.
> For recovery, recording badblocks and continue syncing subsequent sectors
> is more suitable. For resync, just skip bad sectors and syncing subsequent
> sectors.
>
> Clean up complex and unnecessary skip code. Return immediately when a
> sector should be skipped. Reduce code paths and lower regression risk.
>
> Fixes: bc49694a9e8f ("md: pass in max_sectors for pers->sync_request()")
> Signed-off-by: Li Nan<linan122@xxxxxxxxxx>
> ---
> drivers/md/raid10.c | 96 +++++++++++----------------------------------
> 1 file changed, 22 insertions(+), 74 deletions(-)

LGTM
Reviewed-by: Yu Kuai <yukuai@xxxxxxxxx>