[PATCH v2 2/2] md/raid5: preserve active PPL log when removing a replacement
From: Yingjie Wang
Date: Sun Nov 15 2026 - 02:42:00 EST
raid5_remove_disk() selects either the active member or its
replacement, but then clears the slot PPL log regardless of which
device is being removed. Removing an unpromoted replacement therefore
sets log->rdev to NULL even though the active member remains in the
slot.
ppl_write_stripe() subsequently returns -EAGAIN for that slot, which
lets ops_run_io() dispatch writes without first recording them in PPL.
Only change the PPL log when the active rdev is removed from a slot
that still belongs to the current array width. A slot left beyond
raid_disks after a shrink has no child PPL log, so skip log_modify()
there and still clear the device pointer.
Fixes: 6358c239d88c ("raid5-ppl: support disk hot add/remove with PPL")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yingjie Wang <x-professor@xxxxxxxxxxx>
---
drivers/md/raid5.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 455e36ddceee..418803741c67 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8474,12 +8474,12 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
err = -EBUSY;
goto abort;
}
- WRITE_ONCE(*rdevp, NULL);
- if (!err) {
+ if (rdev == p->rdev && number < conf->raid_disks) {
err = log_modify(conf, rdev, false);
if (err)
goto abort;
}
+ WRITE_ONCE(*rdevp, NULL);
tmp = p->replacement;
if (tmp) {
--
2.43.0