From: Yu Kuai <yukuai@kernel.org>
To: Song Liu <song@kernel.org>, Li Nan <magiclinan@didiglobal.com>,
Xiao Ni <xiao@kernel.org>
Cc: Yu Kuai <yukuai@fygo.io>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Mykola Marzhan <mykola@meshstor.io>, Su Yue <glass.su@suse.com>
Subject: [PATCH v5 00/29] md: improve lockless bitmap reshape support
Date: Mon, 3 Aug 2026 03:50:09 +0800 [thread overview]
Message-ID: <20260802195038.164272-1-yukuai@kernel.org> (raw)
From: Yu Kuai <yukuai@fygo.io>
This series fixes several md/llbitmap and RAID5 bitmap-accounting
correctness issues, and adds the missing lockless bitmap support for
online reshape in RAID10 and RAID5.
llbitmap has different constraints from the existing bitmap code: there is
one live bitmap instance, each bit state has richer semantics, and reshape
can change the mapping from logical array ranges to bitmap ranges. Without
exact old/new geometry tracking, reshape-boundary splitting, and correct
teardown ordering, write accounting can use the wrong bitmap mapping, merge
state across ranges that should be checkpointed separately, or race with
freed llbitmap storage.
The first five patches fix standalone llbitmap and RAID5 correctness issues
that are independent of reshape. Patches 6-11 fix md core and llbitmap
lifetime/accounting prerequisites: behind-write teardown ordering, clone I/O
timestamp initialization, create-failure pointer lifetime, shutdown timer
rearm, empty bitmap ranges, and reshape-boundary bio splitting. Patch 12 adds
the common exact bitmap mapping and reshape hooks. The remaining patches
track and validate llbitmap geometry, grow the page cache for reshape, remap
checkpointed state as reshape advances, and wire RAID10 and RAID5 to split
reshape-crossing bios before bitmap accounting and to mark llbitmap reshape
checkpoints.
Changes since v4:
- Rebase on mdraid/md-7.3, base commit 140234b2380f ("md/raid1: create
serial pool adding rdev to array with serialize_policy=1").
- Add Mykola Marzhan's Tested-by tag from the v4 cover-thread reply to the
25 patches already present in v4; leave v5-only patches 6-9 without that
tag.
- Add patch 6 to call mddev_detach() before md_bitmap_destroy(), so
bitmap_ops->wait_behind_writes() can drain behind writes before
llbitmap storage is freed.
- Add patch 7 to clear md_io_clone->start_time when queue I/O accounting
is disabled, avoiding stale accounting timestamps from reused clone
private data.
- Add patch 8 to clear mddev->bitmap under bitmap_info.mutex before
freeing llbitmap after create failure, avoiding a stale pointer for
mutex-protected readers.
- Add patch 9 to introduce the runtime-only BITMAP_SHUTDOWN state in
llbitmap->flags, stop daemon timer/work rearming during llbitmap
destroy, and mask the state while reading or writing the llbitmap
superblock.
- Move the common exact bitmap mapping and reshape hook patch from v4
patch 6 to v5 patch 12, directly before the sync_size tracking patch, so
earlier standalone fixes no longer depend on the new hook.
- Fix patch 10 to keep empty-range handling valid before the exact mapping
hook is introduced, and update the commit message to describe
personality bitmap mapping instead of prepare_range().
- Fix patch 13 to reject an on-disk llbitmap sync_size that exceeds
mddev->resync_max_sectors when reading the bitmap superblock.
- Fix patch 15 to use GFP_NOIO when expanding llbitmap page controls.
- Fix patch 24 for the current raid10 wait_barrier() API after rebasing.
- Fix patch 26 to compute the previous RAID5 bitmap array size from
mddev->dev_sectors and conf->previous_raid_disks.
Changes since v3:
- Add patch 1 to clear the sticky LLPageFlush state after daemon flush.
- Add patch 2 to use GFP_NOIO for llbitmap cache and control allocations.
- Add patch 3 to only checkpoint fully completed llbitmap sync chunks.
- Add patch 4 to reject zero-sector RAID5 reshape chunks.
- Fix patch 8 to snapshot mddev->reshape_position with READ_ONCE() while
splitting reshape-crossing bios.
- Fix patch 10 to keep the independently allocated page controls under the
GFP_NOIO allocation policy added by patch 2.
- Fix patch 11 to quiesce the array while llbitmap grows page controls
during resize or reshape.
- Fix patch 15 to use READ_ONCE(mddev->reshape_position) in llbitmap
reshape range mapping helpers instead of plain lockless reads.
- Fix patch 17 to serialize reshape checkpoint remapping against normal
write/discard bitmap state updates with a rwlock, and copy overlapping
remap ranges backwards when needed.
- Fix patch 21 to end RAID10 write accounting if reshape bio splitting
fails.
- Fix patch 25 to resubmit the RAID5 front split bio after waiting for
reshape instead of retrying the already-submitted remainder.
Changes since v2:
- Fix RAID5 bitmap stripe rounding for non-power-of-two stripe widths in
patch 1.
- Fix partial discard chunks being marked unwritten in patch 11.
- Fix RAID5 writes past component size being skipped by llbitmap
accounting in patch 11.
- Fix stopped reshape reassembly losing target llbitmap geometry in patch
9.
- Fix the page-cache-grow patch using target-geometry fields before they
are introduced in patch 7.
Changes since v1:
- Add Reviewed-by tags from Su Yue.
- Rename llbitmap_resize_chunks() to llbitmap_calculate_chunks().
- Use an unsigned index in llbitmap_expand_pages() error cleanup.
- Rebase on mdraid/md-7.2, including the
mddev_bio_split_at_reshape_offset() declaration needed by the RAID5
build reported by kernel test robot.
Previous versions:
v4: https://lore.kernel.org/linux-raid/20260801172519.2982121-1-yukuai@kernel.org/
v3: https://lore.kernel.org/linux-raid/cover.1785206690.git.yukuai@fygo.io/
v2: https://lore.kernel.org/linux-raid/cover.1782282042.git.yukuai@kernel.org/
v1: https://lore.kernel.org/linux-raid/20260605091527.2463539-1-yukuai@kernel.org/
Yu Kuai (29):
md/md-llbitmap: clear flush state after daemon flush
md/md-llbitmap: use GFP_NOIO for cache allocations
md/md-llbitmap: only end fully synced chunks
md/raid5: reject zero-sector reshape chunks
md/raid5: round bitmap stripes with sector division
md: wait for behind writes before destroying bitmap
md: avoid stale clone I/O accounting timestamps
md/md-llbitmap: prevent create failure bitmap UAF
md/md-llbitmap: stop daemon timer rearm on destroy
md: skip bitmap accounting for empty write ranges
md: add helper to split bios at reshape offset
md: add exact bitmap mapping and reshape hooks
md/md-llbitmap: track bitmap sync_size explicitly
md/md-llbitmap: allocate page controls independently
md/md-llbitmap: grow the page cache in place for reshape
md/md-llbitmap: track target reshape geometry fields
md/md-llbitmap: finish reshape geometry
md/md-llbitmap: refuse reshape while llbitmap still needs sync
md/md-llbitmap: add reshape range mapping helpers
md/md-llbitmap: don't skip reshape ranges from bitmap state
md/md-llbitmap: remap checkpointed bits as reshape progresses
md/md-llbitmap: clamp state-machine walks to tracked bits
md/raid10: reject llbitmap reshape when md chunk shrinks
md/raid10: wire llbitmap reshape lifecycle
md/raid10: split reshape bios before bitmap accounting
md/raid5: add exact old and new llbitmap mapping helpers
md/raid5: reject llbitmap reshape when md chunk shrinks
md/raid5: wire llbitmap reshape lifecycle
md/raid5: split reshape bios before bitmap accounting
drivers/md/md-bitmap.c | 8 +
drivers/md/md-bitmap.h | 10 +
drivers/md/md-llbitmap.c | 740 +++++++++++++++++++++++++++++++++++----
drivers/md/md.c | 68 +++-
drivers/md/md.h | 8 +
drivers/md/raid10.c | 53 +++
drivers/md/raid5.c | 140 +++++++-
7 files changed, 936 insertions(+), 91 deletions(-)
base-commit: 140234b2380ffb8ffb0cfc46fee0e822f43adef7
--
2.51.0
next reply other threads:[~2026-08-02 19:50 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 19:50 Yu Kuai [this message]
2026-08-02 19:50 ` [PATCH v5 01/29] md/md-llbitmap: clear flush state after daemon flush Yu Kuai
2026-08-02 20:28 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 02/29] md/md-llbitmap: use GFP_NOIO for cache allocations Yu Kuai
2026-08-02 20:44 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 03/29] md/md-llbitmap: only end fully synced chunks Yu Kuai
2026-08-02 19:50 ` [PATCH v5 04/29] md/raid5: reject zero-sector reshape chunks Yu Kuai
2026-08-02 20:31 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 05/29] md/raid5: round bitmap stripes with sector division Yu Kuai
2026-08-02 20:19 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 06/29] md: wait for behind writes before destroying bitmap Yu Kuai
2026-08-02 20:40 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 07/29] md: avoid stale clone I/O accounting timestamps Yu Kuai
2026-08-02 20:45 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 08/29] md/md-llbitmap: prevent create failure bitmap UAF Yu Kuai
2026-08-02 20:39 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 09/29] md/md-llbitmap: stop daemon timer rearm on destroy Yu Kuai
2026-08-02 20:19 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 10/29] md: skip bitmap accounting for empty write ranges Yu Kuai
2026-08-02 19:50 ` [PATCH v5 11/29] md: add helper to split bios at reshape offset Yu Kuai
2026-08-02 20:19 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 12/29] md: add exact bitmap mapping and reshape hooks Yu Kuai
2026-08-02 19:50 ` [PATCH v5 13/29] md/md-llbitmap: track bitmap sync_size explicitly Yu Kuai
2026-08-02 20:24 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 14/29] md/md-llbitmap: allocate page controls independently Yu Kuai
2026-08-02 20:27 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 15/29] md/md-llbitmap: grow the page cache in place for reshape Yu Kuai
2026-08-02 20:37 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 16/29] md/md-llbitmap: track target reshape geometry fields Yu Kuai
2026-08-02 20:25 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 17/29] md/md-llbitmap: finish reshape geometry Yu Kuai
2026-08-02 20:39 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 18/29] md/md-llbitmap: refuse reshape while llbitmap still needs sync Yu Kuai
2026-08-02 20:44 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 19/29] md/md-llbitmap: add reshape range mapping helpers Yu Kuai
2026-08-02 20:31 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 20/29] md/md-llbitmap: don't skip reshape ranges from bitmap state Yu Kuai
2026-08-02 20:31 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 21/29] md/md-llbitmap: remap checkpointed bits as reshape progresses Yu Kuai
2026-08-02 20:43 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 22/29] md/md-llbitmap: clamp state-machine walks to tracked bits Yu Kuai
2026-08-02 19:50 ` [PATCH v5 23/29] md/raid10: reject llbitmap reshape when md chunk shrinks Yu Kuai
2026-08-02 20:40 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 24/29] md/raid10: wire llbitmap reshape lifecycle Yu Kuai
2026-08-02 20:49 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 25/29] md/raid10: split reshape bios before bitmap accounting Yu Kuai
2026-08-02 20:46 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 26/29] md/raid5: add exact old and new llbitmap mapping helpers Yu Kuai
2026-08-02 19:50 ` [PATCH v5 27/29] md/raid5: reject llbitmap reshape when md chunk shrinks Yu Kuai
2026-08-02 20:42 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 28/29] md/raid5: wire llbitmap reshape lifecycle Yu Kuai
2026-08-02 20:46 ` sashiko-bot
2026-08-02 19:50 ` [PATCH v5 29/29] md/raid5: split reshape bios before bitmap accounting Yu Kuai
2026-08-03 12:11 ` [PATCH v5 00/29] md: improve lockless bitmap reshape support Mykola Marzhan
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=20260802195038.164272-1-yukuai@kernel.org \
--to=yukuai@kernel.org \
--cc=glass.su@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=mykola@meshstor.io \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--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