[PATCH 2/2] md/raid5: preserve active PPL log when removing a replacement

From: Yingjie Wang

Date: Mon Nov 09 2026 - 04:16:33 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 the writes without first recording them in
PPL.

Only change the PPL log when the active rdev is removed. Keep it attached
to the active member while an unpromoted replacement is detached.

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..2f4fe416113c 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) {
err = log_modify(conf, rdev, false);
if (err)
goto abort;
}
+ WRITE_ONCE(*rdevp, NULL);

tmp = p->replacement;
if (tmp) {
--
2.43.0