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

Yu Kuai posted 3 patches 1 month, 3 weeks ago
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(-)
[PATCH v13 0/3] md/md-bitmap: restore bitmap grow through sysfs
Posted by Yu Kuai 1 month, 3 weeks ago
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
Re: [PATCH v13 0/3] md/md-bitmap: restore bitmap grow through sysfs
Posted by Su Yue 1 month, 3 weeks ago
On Sat 25 Apr 2026 at 10:46, Yu Kuai <yukuai@fnnas.com> 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?

--
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(-)
>
> base-commit: c85d314b135ff569c1031f2ef8e40368bcfe72ac
Re: [PATCH v13 0/3] md/md-bitmap: restore bitmap grow through sysfs
Posted by Yu Kuai 1 month, 3 weeks ago
Hi,

在 2026/4/25 16:41, Su Yue 写道:
> On Sat 25 Apr 2026 at 10:46, Yu Kuai <yukuai@fnnas.com> 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
Re: [PATCH v13 0/3] md/md-bitmap: restore bitmap grow through sysfs
Posted by Yu Kuai 1 month, 3 weeks ago
Hi,

Please just ignore the v13, it's local version by ai that I forgot to remove.

在 2026/4/25 10:46, Yu Kuai 写道:
> 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

-- 
Thansk,
Kuai