From: sashiko-bot@kernel.org
To: "Yunye Zhao" <yunye.zhao@linux.alibaba.com>
Cc: linux-raid@vger.kernel.org, yukuai@fygo.io
Subject: Re: [PATCH v2 3/3] md/raid10: skip clean regions in bulk during recovery
Date: Thu, 23 Jul 2026 14:16:20 +0000 [thread overview]
Message-ID: <20260723141628.026F31F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260723135535.101995-4-yunye.zhao@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Fallback to an unscaled `max_sync` mixes array and device sectors, overshooting the recovery cursor and silently skipping dirty sectors.
--
--- Patch [3]: [PATCH v2 3/3] md/raid10: skip clean regions in bulk during recovery ---
commit 4abce2392f76451810793b3efca0299da30d9898
Author: Yunye Zhao <yunye.zhao@linux.alibaba.com>
md/raid10: skip clean regions in bulk during recovery
During recovery of a degraded RAID10 array with a mostly-clean bitmap, this
patch calculates the skipped clean span in bulk. It tracks the minimum clean
span across skipped devices, converts it to device sectors, and skips it in
one step to reduce CPU spinning.
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 54cddb3a98cd6..8acbd5ef618b4 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
[ ... ]
> @@ -3514,6 +3530,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
> }
> }
> if (biolist == NULL) {
> + sector_t skip_sectors = max_sync;
> +
> while (r10_bio) {
> struct r10bio *rb2 = r10_bio;
> r10_bio = (struct r10bio*) rb2->master_bio;
> @@ -3521,7 +3539,29 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
> put_buf(rb2);
> }
> *skipped = 1;
> - return max_sync;
> +
> + /*
> + * min_sync_blocks is in array sectors, but the return
> + * value advances the per-device cursor; for a near
> + * layout the two spaces differ by the factor
> + * raid_disks / near_copies.
> + */
> + if (!missing_source &&
> + conf->geo.far_copies == 1 && !conf->geo.far_offset &&
> + conf->geo.raid_disks % conf->geo.near_copies == 0 &&
> + min_sync_blocks != MaxSector) {
> + sector_t clean_sectors = min_sync_blocks;
> +
> + clean_sectors *= conf->geo.near_copies;
> + sector_div(clean_sectors, conf->geo.raid_disks);
> + clean_sectors &= ~chunk_mask;
> + if (clean_sectors > sync_end - sector_nr)
> + clean_sectors = sync_end - sector_nr;
> + if (clean_sectors > skip_sectors)
> + skip_sectors = clean_sectors;
> + }
> +
> + return skip_sectors;
[Severity: Critical]
This is a pre-existing issue, but does returning the unscaled max_sync mix
array and device sectors here?
When recovering a degraded RAID10 array, md_bitmap_start_sync() returns
sync_blocks in array sectors, which is then assigned to max_sync.
If a clean span is small or not chunk-aligned, the truncation:
clean_sectors &= ~chunk_mask;
can force the scaled clean_sectors to 0. When that happens, the condition:
if (clean_sectors > skip_sectors)
skip_sectors = clean_sectors;
fails, leaving skip_sectors as the unscaled max_sync value.
Because raid10_sync_request() then returns skip_sectors (an array-sector
distance) to advance the physical per-device cursor in md_do_sync(), could
the physical cursor overstep the actual clean physical span?
For layouts where array sectors advance faster than device sectors
(e.g., near_copies > 1), won't this silently skip dirty sectors and leave
mirrors out of sync?
> }
> } else {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723135535.101995-1-yunye.zhao@linux.alibaba.com?part=3
prev parent reply other threads:[~2026-07-23 14:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 6:27 [PATCH] md: fix soft lockup during resync when sync is repeatedly skipped Yunye Zhao
2026-07-17 6:51 ` sashiko-bot
2026-07-19 10:45 ` yu kuai
2026-07-20 6:20 ` Yunye Zhao
2026-07-22 4:00 ` yu kuai
2026-07-23 13:55 ` [PATCH v2 0/3] md/raid10: fix recovery corruption and soft lockup on large arrays Yunye Zhao
2026-07-23 13:55 ` [PATCH v2 1/3] md/raid10: fix still_degraded being inverted in raid10_sync_request() Yunye Zhao
2026-07-23 13:55 ` [PATCH v2 2/3] md: add cond_resched() to md_do_sync()'s skip path Yunye Zhao
2026-07-23 14:05 ` sashiko-bot
2026-07-23 13:55 ` [PATCH v2 3/3] md/raid10: skip clean regions in bulk during recovery Yunye Zhao
2026-07-23 14:16 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260723141628.026F31F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yukuai@fygo.io \
--cc=yunye.zhao@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox