[PATCH v13 0/3] md/md-bitmap: restore bitmap grow through sysfs

From: Yu Kuai

Date: Fri Apr 24 2026 - 22:46:44 EST


mdadm --grow adds an internal bitmap by writing bitmap/location for an
array that currently has no bitmap. That requires the bitmap directory
and location attribute to exist before the classic bitmap backend is
created.

This series separates bitmap backend lifetime from bitmap sysfs lifetime,
splits the sysfs layout into common and backend-specific groups, and adds
a small "none" bitmap backend. The none backend keeps bitmap/location
available while no real bitmap is active, and the location store path can
then switch between the none backend and the classic bitmap backend
without tearing down the common bitmap sysfs directory.

Patch 1 factors bitmap creation and destruction into helpers that do not
touch sysfs registration.

Patch 2 splits the classic bitmap sysfs files into a common group and an
internal-bitmap group, and converts bitmap backend operations to use a
sysfs group array.

Patch 3 adds the none backend and uses it to restore mdadm --grow bitmap
addition through bitmap/location.

Changes since v12:
- Keep the factoring patch focused on no-sysfs bitmap lifetime helpers.
- Make bitmap operation lookup depend only on the current bitmap id
matching the installed backend.
- Trim the none backend to only the operations required by the active
call paths.
- Rework bitmap/location error handling with explicit cleanup labels.
- Restore the none backend after bitmap removal and creation/load
failures so bitmap/location stays available.

Validation:
- create a RAID1 array with --bitmap=none
- verify /sys/block/md0/md/bitmap/location exists and reports "none"
- mdadm --grow /dev/md0 --bitmap=internal
- verify location switches to "+8", mdadm reports "Intent Bitmap:
Internal", and /proc/mdstat reports a bitmap
- mdadm --grow /dev/md0 --bitmap=none
- verify location switches back to "none" and only the common location
attribute remains under md/bitmap
- repeat the internal/none switch once more
- Checked the QEMU serial log for panic, Oops, BUG, WARNING, Call Trace,
RCU stall, and hung-task patterns; none were found.

Yu Kuai (3):
md: factor bitmap creation away from sysfs handling
md/md-bitmap: split bitmap sysfs groups
md/md-bitmap: add a none backend for bitmap grow

drivers/md/md-bitmap.c | 131 +++++++++++++++++++++++++++++++++++----
drivers/md/md-bitmap.h | 2 +-
drivers/md/md-llbitmap.c | 7 ++-
drivers/md/md.c | 125 ++++++++++++++++++++++++++-----------
drivers/md/md.h | 3 +
5 files changed, 218 insertions(+), 50 deletions(-)

base-commit: c85d314b135ff569c1031f2ef8e40368bcfe72ac
--
2.51.0