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

From: Yu Kuai

Date: Tue Apr 28 2026 - 04:23:16 EST


Hi,

在 2026/4/25 16:41, Su Yue 写道:
> On Sat 25 Apr 2026 at 10:46, Yu Kuai <yukuai@xxxxxxxxx> wrote:
>
>> 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
>>
>
> Thanks for all.
> Would you like to add tag Fixes: fb8cc3b0d9db for the whole series
> while merging?

Sure, sorry that I forgot the fix tag.

>
> --
> Su
>
>>  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(-)

Applied with following fix tag for patch 3:

Fixes: fb8cc3b0d9db ("md/md-bitmap: delay registration of bitmap_ops until creating bitmap")

>>
>> base-commit: c85d314b135ff569c1031f2ef8e40368bcfe72ac

--
Thansk,
Kuai