[PATCH v2 0/2] md/raid5: fix PPL disk add and replacement removal

Yingjie Wang posted 2 patches 1 week, 1 day ago
Only 0 patches received!
drivers/md/raid5-ppl.c | 11 ++++++++++-
drivers/md/raid5.c     | 13 +++++++++----
2 files changed, 19 insertions(+), 5 deletions(-)
[PATCH v2 0/2] md/raid5: fix PPL disk add and replacement removal
Posted by Yingjie Wang 1 week, 1 day ago
This is v2 of the two independent PPL disk-transition fixes. The first
patch is unchanged. The second patch also handles a slot that remains
assigned above the current array width after a RAID5 shrink.

When a newly added disk fails PPL setup, raid5_add_disk() can publish the
private disk pointer before the caller rolls back raid_disk. A later
removal can then free the disk while RAID5 still references it. Patch 1
prepares the PPL log before publishing the pointer and restores the
previous state on failure.

Patch 2 keeps the active PPL log attached when an unpromoted replacement
is removed. It also skips log_modify() when removing an active device from
a slot at or above the current raid_disks value. Such a slot has no PPL
child log after a shrink, but its device pointer still has to be cleared.

Changes in v2:

  * guard the active-device log update with number < conf->raid_disks;
  * add a shrink test that leaves an extra slot blocked, enables PPL, and
    compares the v1 and v2 removal results.

The v1 public thread is:
https://lore.kernel.org/r/cover.1794215128.git.x-professor@outlook.com/

Tested on x86_64 with KASAN, PROVE_LOCKING, DEBUG_ATOMIC_SLEEP, LOCKDEP,
MD, and RAID456 enabled:

  * per-commit W=1 builds for both commits;
  * failed PPL disk addition, which reaches DONE on the v2 tip;
  * unpromoted replacement removal, which reaches PASS and DONE on the
    v2 tip, with tracing observing `ppl_write_stripe()` and a successful
    return during a subsequent array write;
  * the shrink comparison, where the sent v1 remains at slot 3 after
    three remove attempts while v2 removes the slot on the first attempt;
  * empty-header `-EIO` injection while adding a spare, where `slot=0`
    returns an error, leaves the slot unassigned, restores `ppl_size`, and
    leaves the degraded array writable.

The runtime tests use native metadata 1.2. IMSM external metadata was not
run. The empty-header failure uses a dedicated kernel with
`CONFIG_FAIL_MAKE_REQUEST` enabled; the separate page-allocation `-ENOMEM`
injection was not run.

Yingjie Wang (2):
  md/raid5: roll back failed PPL disk additions
  md/raid5: preserve active PPL log when removing a replacement

 drivers/md/raid5-ppl.c | 11 ++++++++++-
 drivers/md/raid5.c     | 13 +++++++++----
 2 files changed, 19 insertions(+), 5 deletions(-)


base-commit: 47e1b18f38d74015cb9fd30b5ff2a1eb88e77d31
-- 
2.43.0

Re: [PATCH v2 0/2] md/raid5: fix PPL disk add and replacement removal
Posted by yu kuai 2 days, 5 hours ago
在 2026/11/15 15:39, Yingjie Wang 写道:

> This is v2 of the two independent PPL disk-transition fixes. The first
> patch is unchanged. The second patch also handles a slot that remains
> assigned above the current array width after a RAID5 shrink.
>
> When a newly added disk fails PPL setup, raid5_add_disk() can publish the
> private disk pointer before the caller rolls back raid_disk. A later
> removal can then free the disk while RAID5 still references it. Patch 1
> prepares the PPL log before publishing the pointer and restores the
> previous state on failure.
>
> Patch 2 keeps the active PPL log attached when an unpromoted replacement
> is removed. It also skips log_modify() when removing an active device from
> a slot at or above the current raid_disks value. Such a slot has no PPL
> child log after a shrink, but its device pointer still has to be cleared.
>
> Changes in v2:
>
>    * guard the active-device log update with number < conf->raid_disks;
>    * add a shrink test that leaves an extra slot blocked, enables PPL, and
>      compares the v1 and v2 removal results.
>
> The v1 public thread is:
> https://lore.kernel.org/r/cover.1794215128.git.x-professor@outlook.com/
>
> Tested on x86_64 with KASAN, PROVE_LOCKING, DEBUG_ATOMIC_SLEEP, LOCKDEP,
> MD, and RAID456 enabled:
>
>    * per-commit W=1 builds for both commits;
>    * failed PPL disk addition, which reaches DONE on the v2 tip;
>    * unpromoted replacement removal, which reaches PASS and DONE on the
>      v2 tip, with tracing observing `ppl_write_stripe()` and a successful
>      return during a subsequent array write;
>    * the shrink comparison, where the sent v1 remains at slot 3 after
>      three remove attempts while v2 removes the slot on the first attempt;
>    * empty-header `-EIO` injection while adding a spare, where `slot=0`
>      returns an error, leaves the slot unassigned, restores `ppl_size`, and
>      leaves the degraded array writable.
>
> The runtime tests use native metadata 1.2. IMSM external metadata was not
> run. The empty-header failure uses a dedicated kernel with
> `CONFIG_FAIL_MAKE_REQUEST` enabled; the separate page-allocation `-ENOMEM`
> injection was not run.
>
> Yingjie Wang (2):
>    md/raid5: roll back failed PPL disk additions
>    md/raid5: preserve active PPL log when removing a replacement
>
>   drivers/md/raid5-ppl.c | 11 ++++++++++-
>   drivers/md/raid5.c     | 13 +++++++++----
>   2 files changed, 19 insertions(+), 5 deletions(-)
Applied
>
>
> base-commit: 47e1b18f38d74015cb9fd30b5ff2a1eb88e77d31

-- 
Thanks,
Kuai