From: Guixin Liu <kanie@linux.alibaba.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Nilay Shroff <nilay@linux.ibm.com>,
Daniel Wagner <dwagner@suse.de>, Hannes Reinecke <hare@suse.de>
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH] nvmet: don't abort the preempting host itself
Date: Fri, 20 Nov 2026 16:06:42 +0800 [thread overview]
Message-ID: <20261120080642.1179691-1-kanie@linux.alibaba.com> (raw)
When a host issues a Reservation Acquire with the Preempt and Abort
action and its own reservation key matches the Preempt Reservation Key
(PRKEY), the host unregisters itself as the specification requires:
all paths in NVMe Base Specification section 8.1.25.7 that unregister
registrants by PRKEY (no reservation held, All Registrants types with
a non-zero PRKEY, and a PRKEY that does not match the holder's key)
apply to every registrant whose key matches, without excluding the
host that issued the command.
But nvmet also adds the issuing host's controllers to the abort set.
The abort flow kills the per-controller ref of every controller in the
set and waits for their counts to drop to zero before completing the
preempt command. The preempt command itself holds a reference on its
own controller's per-controller ref until it completes, so the abort
flow ends up waiting for the very command it is supposed to complete
afterwards. The namespace's pr_sem is never released and all further
reservation commands on the namespace hang.
The abort of commands as a side effect of preempting a reservation is
best effort, so skip the issuing host's controllers and just unregister
the registrant.
Fixes: 5a47c2080a73 ("nvmet: support reservation feature")
Cc: stable@vger.kernel.org
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
drivers/nvme/target/pr.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
index 8c818f24815b..ed530d7362f5 100644
--- a/drivers/nvme/target/pr.c
+++ b/drivers/nvme/target/pr.c
@@ -502,7 +502,14 @@ static u16 nvmet_pr_unreg_all_host_by_prkey(struct nvmet_req *req, u64 prkey,
if (reg->rkey == prkey) {
status = NVME_SC_SUCCESS;
uuid_copy(&hostid, ®->hostid);
- if (abort)
+ /*
+ * Aborting is best effort (NVMe Base Specification
+ * section 8.1.25.7): skip the issuing host, as the
+ * abort flow would otherwise wait for the preempt
+ * command itself, which holds a reference on its
+ * controller's per-controller ref until it completes.
+ */
+ if (abort && !uuid_equal(&hostid, send_hostid))
nvmet_pr_set_ctrl_to_abort(req, &hostid);
nvmet_pr_unregister_one(pr, reg);
if (!uuid_equal(&hostid, send_hostid))
--
2.43.7
next reply other threads:[~2026-11-20 8:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 8:06 Guixin Liu [this message]
2026-11-20 8:18 ` [PATCH] nvmet: don't abort the preempting host itself sashiko-bot
2026-11-20 8:32 ` Guixin Liu
2026-11-20 17:24 ` Christoph Hellwig
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=20261120080642.1179691-1-kanie@linux.alibaba.com \
--to=kanie@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
/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