[PATCH 3/3] dm era: construct the target suspended
From: Denis V. Lunev
Date: Wed Nov 18 2026 - 06:03:46 EST
From: Denis V. Lunev <den@xxxxxxxxxx>
era_preresume() resizes the era array and commits the metadata in the
thread that resumes the device, and starts the worker only once that is
done. That is safe only while the worker cannot run, and nothing makes
it so: struct era is zeroed, so era->suspended reads as running from
the moment the target is constructed, and an rpc arriving before the
resume wakes the worker alongside the resize. Both allocate from the
same space map and take the same metadata block, which corrupts it:
device-mapper: block manager: validator mismatch (old=array vs new=index)
device-mapper: space map common: unable to decrement block
device-mapper: era: metadata_commit: pre commit failed
Every commit after that fails the same way, the target reports "era
Error", and the writes it tracks fail, which takes the workload's
filesystem read-only.
Userspace gets there without trying. multipathd asks every
device-mapper target appearing on the node for its status, over its own
uevent socket, to learn whether the target is a multipath map, so a
target is asked exactly while it resumes.
Mark the target suspended when it is constructed, which is the state
start_worker() already assumes it is leaving. The resize and the commit
then run with the worker held back, as they must, and a status query in
that window is refused rather than served beside them.
Fixes: cca2c6aebe86 ("dm era: only resize metadata in preresume")
Cc: stable@xxxxxxxxxxxxxxx # v5.12+
Signed-off-by: Denis V. Lunev <den@xxxxxxxxxx>
---
drivers/md/dm-era-target.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
index 29b0602e7849..d40a98169b04 100644
--- a/drivers/md/dm-era-target.c
+++ b/drivers/md/dm-era-target.c
@@ -1557,6 +1557,7 @@ static int era_ctr(struct dm_target *ti, unsigned int argc, char **argv)
spin_lock_init(&era->rpc_lock);
INIT_LIST_HEAD(&era->rpc_calls);
+ atomic_set(&era->suspended, 1);
ti->private = era;
ti->num_flush_bios = 1;
--
2.55.0