Re: [PATCH v3 2/3] dm era: refuse metadata rpcs once the target is suspended

From: Ming Hung Tsai

Date: Tue Dec 01 2026 - 08:44:10 EST


On Tue, Dec 1, 2026 at 2:33 AM Denis V. Lunev <den@xxxxxxxxxx> wrote:
>
> From: Denis V. Lunev <den@xxxxxxxxxx>
>
> An rpc reaches the worker in two steps: the caller puts it on the rpc
> list, then wake_worker() queues the work unless the target is
> suspended. stop_worker() raises that flag and drains the workqueue with
> no ordering against either step, so an rpc can land on both sides of
> the drain.
>
> An rpc queued before the flag is raised, whose wake_worker() runs after
> it, is never served. The caller waits for a completion that only the
> next resume can deliver, and it waits holding the table srcu, so a
> reload blocks in dm_swap_table() and the device can no longer be
> reloaded or removed.
>
> An rpc whose wake_worker() read the flag as clear can instead queue the
> work after drain_workqueue() has returned. The worker then commits the
> metadata beside the commit era_postsuspend() runs in its own thread.
> Both commits allocate from the same space map and take the same block,
> which corrupts it, and every commit after that fails:
>
> device-mapper: space map common: unable to decrement block
> device-mapper: era: metadata_commit: pre commit failed
>
> Add the rpc and queue the work under the rpc lock, take that lock to
> raise the flag, and refuse an rpc that arrives once it is raised. An
> rpc that made it onto the list is then queued before the drain waits
> for it.
>
> Userspace sees one change. A status query on a suspended era device
> used to block until the device was resumed, and now reports the target
> in error.
>
> Fixes: eec40579d848 ("dm: add era target")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Denis V. Lunev <den@xxxxxxxxxx>

Reviewed-by: Ming-Hung Tsai <mtsai@xxxxxxxxxx>