Re: [PATCH v3 3/3] dm era: construct the target suspended
From: Ming Hung Tsai
Date: Tue Dec 01 2026 - 08:46:05 EST
On Tue, Dec 1, 2026 at 2:35 AM Denis V. Lunev <den@xxxxxxxxxx> wrote:
>
> 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 reported busy 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>
Reviewed-by: Ming-Hung Tsai <mtsai@xxxxxxxxxx>