From: sashiko-bot@kernel.org
To: "Eric Hagberg" <ehagberg@janestreet.com>
Cc: linux-raid@vger.kernel.org, yukuai@fygo.io
Subject: Re: [PATCH RESEND 2/3] md/raid10: re-arm in-progress bitmap chunks when recovery is interrupted
Date: Fri, 04 Dec 2026 18:16:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-250398@kernel.org> (raw)
In-Reply-To: <20261204174621.3475573-3-ehagberg@janestreet.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] md/raid10: raid10_abort_sync_bitmap() permanently leaves
NEEDED_MASK set
- [Low] md/raid10: raid10_abort_sync_bitmap() couples to md-bitmap
internals
- [Low] md/raid10: misleading llbitmap abort rationale in
raid10_classic_bitmap()
--
commit 0d112aed9e653ad59e91dbedbc2614b80f007e0e
Author: Jason Chu <jaschu@janestreet.com>
md/raid10: re-arm in-progress bitmap chunks when recovery is interrupted
When a classic-bitmap raid10 recovery is aborted, this commit walks the
bitmap from sector 0 and calls end_sync() on every chunk instead of
calling bitmap_ops->close_sync(), so in-progress chunks with remaining
copies keep NEEDED_MASK set.
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 3ef0143acfd97..e42abe747d81b 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -3071,6 +3071,51 @@ static void raid10_set_cluster_sync_high(struct r10conf *conf)
> conf->cluster_sync_high = conf->cluster_sync_low + window_size;
> }
>
> +/*
> + * llbitmap's end_sync already aborts every syncing chunk from the given
> + * offset to the end. The classic bitmap ends one chunk per call.
> + */
> +static bool raid10_classic_bitmap(struct mddev *mddev)
> +{
> + return mddev->bitmap_id == ID_BITMAP && md_bitmap_enabled(mddev, false);
> +}
[Severity: Low]
Is this rationale (and the matching note in the commit message) accurate
for aborted recovery?
On aborted recovery, raid10_sync_request() passes virtual offsets from
raid10_find_virt(conf, mddev->curr_resync, i) rather than 0, so
llbitmap_end_sync() only aborts chunks from those offsets to the end.
llbitmap_close_sync() then transitions lower syncing chunks to BitDirty
rather than BitNeedSync, so avoiding skipped copies depends on llbitmap's
degraded-array BitDirty handling instead.
> +
> +/*
> + * Re-arm the classic bitmap's in-progress chunks from @start to the end of
> + * the array, so that they are synced again.
> + *
> + * Recovery walks member sectors, but the bitmap tracks array sectors. A
> + * chunk that was started for one copy can still cover copies that recovery
> + * has not reached: on another returning member, or further into the same
> + * member for the far layout. An aborted recovery therefore re-arms every
> + * in-progress chunk (@start == 0). A chunk whose copies are all done may
> + * stay dirty and be copied again, but an unfinished copy is not skipped.
> + */
> +static void raid10_abort_sync_bitmap(struct mddev *mddev, sector_t start)
> +{
> + /* The bitmap chunk size is a power of two. */
> + sector_t chunk_sectors = mddev->bitmap_info.chunksize >> SECTOR_SHIFT;
> + sector_t limit = mddev->resync_max_sectors;
> + sector_t sector = round_down(start, chunk_sectors);
> +
> + while (sector < limit) {
> + sector_t blocks;
> +
> + mddev->bitmap_ops->end_sync(mddev, sector, &blocks);
> + blocks = min(blocks, limit - sector);
> + sector += blocks;
> + /*
> + * Missing and hijacked counter pages report a whole page
> + * span. A hijacked page has two counters, one for each
> + * half. Visit the last sector of the span as well, in
> + * case it uses the other counter.
> + */
> + if (blocks > chunk_sectors)
> + mddev->bitmap_ops->end_sync(mddev, sector - 1, &blocks);
> + cond_resched();
> + }
> +}
[Severity: Low]
Should this range-abort walk live behind struct bitmap_operations in
drivers/md/md-bitmap.c instead of raid10.c?
raid10_abort_sync_bitmap() checks mddev->bitmap_id == ID_BITMAP and
hardcodes classic bitmap's hijacked counter-page layout from
md_bitmap_get_counter(), while md-bitmap.c already owns both that layout
and the full-bitmap walk in bitmap_close_sync().
Separately, on aborted recovery raid10_sync_request() still runs the
per-disk raid10_find_virt() and md_bitmap_end_sync() loop right before
raid10_abort_sync_bitmap(mddev, 0) walks and ends every chunk from
sector 0 again.
[ ... ]
> @@ -3182,8 +3229,16 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
> }
> conf->fullsync = 0;
> }
> - if (md_bitmap_enabled(mddev, false))
> + if (aborted && raid10_classic_bitmap(mddev) &&
> + !test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
> + /*
> + * close_sync would clear in-progress chunks that
> + * still have copies outstanding.
> + */
> + raid10_abort_sync_bitmap(mddev, 0);
> + } else if (md_bitmap_enabled(mddev, false)) {
> mddev->bitmap_ops->close_sync(mddev);
> + }
> close_sync(conf);
> *skipped = 1;
> return 0;
[Severity: Medium]
Can calling raid10_abort_sync_bitmap(mddev, 0) and skipping close_sync()
permanently leave NEEDED_MASK set on already-recovered chunks?
When recovery resumes, md_sync_position() starts at rdev->recovery_offset,
so chunks whose copies all lie below curr_resync are never revisited by
md_bitmap_start_sync(). When recovery later finishes, bitmap_close_sync()
only clears RESYNC_MASK and leaves NEEDED_MASK set.
Because NEEDED_MASK keeps *bmc above 2, bitmap_daemon_work() never clears
those on-disk bits or lets md_bitmap_checkfree() free their 4 KiB counter
pages. Those pages stay pinned in memory while the array runs, and a
later unclean shutdown or member re-add needlessly resyncs those chunks.
Passing a layout-derived virtual lower bound for curr_resync as start (for
example on near and offset layouts) and then calling close_sync() would
close already-completed chunks cleanly.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204174621.3475573-1-ehagberg@janestreet.com?part=2
next prev parent reply other threads:[~2026-12-04 18:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 19:31 [REGRESSION] md/raid10: far-layout member left with stale data after bitmap re-add (6.11+, 6.12.y, 6.18.y) Eric Hagberg
2026-11-30 19:48 ` sashiko-bot
2026-12-04 17:46 ` [PATCH RESEND 0/3] md/raid10: fix old data left by skipped and interrupted sync Eric Hagberg
2026-12-04 17:46 ` [PATCH RESEND 1/3] md/raid10: do not skip past the range that sync_request examined Eric Hagberg
2026-12-04 17:46 ` [PATCH RESEND 2/3] md/raid10: re-arm in-progress bitmap chunks when recovery is interrupted Eric Hagberg
2026-12-04 18:16 ` sashiko-bot [this message]
2026-12-04 19:17 ` Eric Hagberg
2026-12-04 17:46 ` [PATCH RESEND 3/3] md/raid10: keep look-ahead bitmap chunks when resync " Eric Hagberg
2026-12-04 18:09 ` sashiko-bot
2026-12-04 19:18 ` Eric Hagberg
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=sashiko-outbox-250398@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ehagberg@janestreet.com \
--cc=linux-raid@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yukuai@fygo.io \
/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