From: "Denis V. Lunev" <den@openvz.org>
To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com,
dm-devel@lists.linux.dev
Cc: bmarzins@redhat.com, thornber@redhat.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
den@openvz.org
Subject: [PATCH 2/3] dm era: refuse metadata rpcs once the target is suspended
Date: Wed, 18 Nov 2026 12:02:38 +0100 [thread overview]
Message-ID: <20261118110239.2910290-3-den@openvz.org> (raw)
In-Reply-To: <20261118110239.2910290-1-den@openvz.org>
From: Denis V. Lunev <den@openvz.org>
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@vger.kernel.org
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
drivers/md/dm-era-target.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
index ea499adca4ce..29b0602e7849 100644
--- a/drivers/md/dm-era-target.c
+++ b/drivers/md/dm-era-target.c
@@ -1389,10 +1389,14 @@ static int perform_rpc(struct era *era, struct rpc *rpc)
init_completion(&rpc->complete);
spin_lock(&era->rpc_lock);
+ if (atomic_read(&era->suspended)) {
+ spin_unlock(&era->rpc_lock);
+ return -EBUSY;
+ }
list_add(&rpc->list, &era->rpc_calls);
+ queue_work(era->wq, &era->worker);
spin_unlock(&era->rpc_lock);
- wake_worker(era);
wait_for_completion(&rpc->complete);
return rpc->result;
@@ -1427,7 +1431,10 @@ static void start_worker(struct era *era)
static void stop_worker(struct era *era)
{
+ spin_lock(&era->rpc_lock);
atomic_set(&era->suspended, 1);
+ spin_unlock(&era->rpc_lock);
+
drain_workqueue(era->wq);
}
--
2.55.0
next prev parent reply other threads:[~2026-11-18 11:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 11:02 [PATCH 0/3] dm era: a metadata device that never comes back Denis V. Lunev
2026-11-18 11:02 ` [PATCH 1/3] dm persistent data: drop the original block only once it is copied Denis V. Lunev
2026-11-18 11:02 ` Denis V. Lunev [this message]
2026-11-18 11:02 ` [PATCH 3/3] dm era: construct the target suspended Denis V. Lunev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118110239.2910290-3-den@openvz.org \
--to=den@openvz.org \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
--cc=stable@vger.kernel.org \
--cc=thornber@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®