* [PATCH] nvme: unregister when pr_register() is given a zero new key
@ 2026-10-29 0:51 Daejun Park via B4 Relay
2026-10-29 12:13 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Daejun Park via B4 Relay @ 2026-10-29 0:51 UTC (permalink / raw)
To: Keith Busch, Christoph Hellwig, Sagi Grimberg
Cc: Jens Axboe, Mike Christie, linux-nvme, linux-kernel, stable,
Daejun Park
From: Daejun Park <daejun7.park@samsung.com>
The block layer PR API defines a zero new_key in pr_register() as
unregistering old_key. nvme_pr_register() sends Replace Reservation
Key with a zero NRKEY instead. The host stays registered with key 0,
and its next registration with another key fails with Reservation
Conflict.
The pNFS SCSI layout client unregisters this way at umount. A later
mount cannot register and sends all I/O through the metadata server.
Send Unregister Reservation Key when new_key is zero.
Fixes: 1d277a637a71 ("NVMe: Add persistent reservation ops")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
---
Tested with IOC_PR_REGISTER on an nvmet nvme-loop namespace and on
dm-linear over it. Registering a new key after unregister now works.
A wrong old_key still gets Reservation Conflict.
---
drivers/nvme/host/pr.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/pr.c b/drivers/nvme/host/pr.c
index fe7dbe2648..d8b6ac4d83 100644
--- a/drivers/nvme/host/pr.c
+++ b/drivers/nvme/host/pr.c
@@ -128,8 +128,12 @@ static int nvme_pr_register(struct block_device *bdev, u64 old_key, u64 new_key,
data.crkey = cpu_to_le64(old_key);
data.nrkey = cpu_to_le64(new_key);
- cdw10 = old_key ? NVME_PR_REGISTER_ACT_REPLACE :
- NVME_PR_REGISTER_ACT_REG;
+ if (!new_key)
+ cdw10 = NVME_PR_REGISTER_ACT_UNREG;
+ else if (old_key)
+ cdw10 = NVME_PR_REGISTER_ACT_REPLACE;
+ else
+ cdw10 = NVME_PR_REGISTER_ACT_REG;
cdw10 |= (flags & PR_FL_IGNORE_KEY) ? NVME_PR_IGNORE_KEY : 0;
cdw10 |= NVME_PR_CPTPL_PERSIST;
---
base-commit: 65ba8f34ec886ec72b2c07ddc8cf3d815c32869d
change-id: 20261028-nvme-pr-unreg-24fa60ffe3c3
Best regards,
--
Daejun Park <daejun7.park@samsung.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvme: unregister when pr_register() is given a zero new key
2026-10-29 0:51 [PATCH] nvme: unregister when pr_register() is given a zero new key Daejun Park via B4 Relay
@ 2026-10-29 12:13 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2026-10-29 12:13 UTC (permalink / raw)
To: daejun7.park
Cc: Keith Busch, Christoph Hellwig, Sagi Grimberg, Jens Axboe,
Mike Christie, linux-nvme, linux-kernel, stable
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-29 12:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29 0:51 [PATCH] nvme: unregister when pr_register() is given a zero new key Daejun Park via B4 Relay
2026-10-29 12:13 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox