[PATCH V2 0/6] md: fix takeover failure handling and raid0 size calculation

From: Zizhi Wo

Date: Sun Oct 18 2026 - 21:17:23 EST


From: Zizhi Wo <wozizhi@xxxxxxxxxx>

Patches 1-3 fix the inconsistent mddev state left behind when a takeover
fails.

Patch 4 rejects a raid0 takeover whose zones cannot cover the capacity the
gendisk advertises, fixing a syzbot BUG() in find_zone().

Patch 5 factors out the member-size rounding. Patch 6 uses it in
raid0_size(), where the power-of-2 mask is not a round down for a
non-power-of-2 chunk.

Changes since v1:
- Added 3 patches fixing the inconsistent mddev state left behind by a
failed takeover in raid0, raid10 and raid5.
- Patch 4: expanded the commit message with a paragraph addressing the
issue previously reported by Sashiko.

v1:
https://lore.kernel.org/all/20261017005802.2212102-1-wozizhi@xxxxxxxxxxxxxxx/

Zizhi Wo (6):
md/raid0: don't leave mddev in an inconsistent state when takeover
fails
md/raid10: don't leave mddev in an inconsistent state when takeover
fails
md/raid5: don't leave mddev in an inconsistent state when takeover
fails
md/raid0: reject a takeover whose zones cannot cover the array
md/raid0: factor out raid0_member_sectors()
md/raid0: round member size in raid0_size() with sector_div()

drivers/md/raid0.c | 84 +++++++++++++++++++++++++++++++++++----------
drivers/md/raid10.c | 11 ++++--
drivers/md/raid5.c | 13 ++++---
3 files changed, 84 insertions(+), 24 deletions(-)

--
2.52.0