* [PATCH 0/2] nvmet: fix FID 82h status codes for invalid NSIDs
@ 2026-09-18 3:39 Guixin Liu
2026-09-18 3:39 ` [PATCH 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h Guixin Liu
2026-09-18 3:39 ` [PATCH 2/2] nvmet: return Invalid Field for invalid NSIDs in Get " Guixin Liu
0 siblings, 2 replies; 8+ messages in thread
From: Guixin Liu @ 2026-09-18 3:39 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Nilay Shroff, Daniel Wagner, John Garry, Hannes Reinecke
Cc: linux-nvme
The Reservation Notification Mask feature (FID 82h) defines its own
status code for NSIDs that do not name a namespace supporting
reservations:
"A Get Features command that uses a namespace ID of FFFFFFFFh
shall be aborted with status code of Invalid Field in Command. [...]
If a Set Features command or a Get Features command attempts to
access the Reservation Notification Mask on a namespace that does
not support reservations or is invalid, then that command is
aborted with status code of Invalid Field in Command."
-- NVMe Base Specification, section 5.2.26.1.33
nvmet routes the namespace lookup of both handlers through
nvmet_req_find_ns(), which returns Invalid Namespace or Format for an
unknown NSID. That is the correct status for the generic
namespace-scoped admin commands, but not for this feature. A Set
Features 82h naming a nonexistent NSID, a Get Features 82h naming a
nonexistent NSID, and a Get Features 82h using the broadcast NSID are
all aborted with Invalid Namespace or Format instead of Invalid Field
in Command.
Each patch fixes one handler and translates the lookup failure to
Invalid Field in Command. The Set Features broadcast, the
namespace-without-reservations case, the disabled namespace path
(Internal Path Error, commit 505363957fad ("nvmet: fix nvme status
code when namespace is disabled")) and everything else keep their
current behavior.
Verified with two hosts (distinct host identifiers) connected over
NVMe/TCP to an nvmet subsystem exporting two reservation-enabled
null_blk namespaces: all three rejected cases now return 0x6002,
while Set/Get Features on an active namespace, the Set Features
broadcast and the reservation commands behave as before, with no
splat in dmesg.
Guixin Liu (2):
nvmet: return Invalid Field for invalid NSIDs in Set Features 82h
nvmet: return Invalid Field for invalid NSIDs in Get Features 82h
drivers/nvme/target/pr.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--
2.43.7
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h
2026-09-18 3:39 [PATCH 0/2] nvmet: fix FID 82h status codes for invalid NSIDs Guixin Liu
@ 2026-09-18 3:39 ` Guixin Liu
2026-09-18 12:05 ` Christoph Hellwig
2026-09-18 3:39 ` [PATCH 2/2] nvmet: return Invalid Field for invalid NSIDs in Get " Guixin Liu
1 sibling, 1 reply; 8+ messages in thread
From: Guixin Liu @ 2026-09-18 3:39 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Nilay Shroff, Daniel Wagner, John Garry, Hannes Reinecke
Cc: linux-nvme
The Reservation Notification Mask feature (FID 82h) defines its own
status code for namespaces that do not support reservations:
"If a Set Features command or a Get Features command attempts to
access the Reservation Notification Mask on a namespace that does
not support reservations or is invalid, then that command is
aborted with status code of Invalid Field in Command."
-- NVMe Base Specification, section 5.2.26.1.33
The Set Features handler routes the namespace lookup through
nvmet_req_find_ns(), which returns Invalid Namespace or Format for an
unknown NSID. That is the correct status for the generic
namespace-scoped admin commands, but not for this feature: a Set
Features 82h naming a nonexistent NSID is aborted with Invalid
Namespace or Format instead of Invalid Field in Command.
Translate the lookup failure to Invalid Field in Command. The
broadcast NSID, the namespace-without-reservations case and everything
else keep their current behavior.
Fixes: 5a47c2080a73 ("nvmet: support reservation feature")
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
drivers/nvme/target/pr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
index 0948a690a1c0..927e3c44952b 100644
--- a/drivers/nvme/target/pr.c
+++ b/drivers/nvme/target/pr.c
@@ -51,8 +51,12 @@ u16 nvmet_set_feat_resv_notif_mask(struct nvmet_req *req, u32 mask)
if (nsid != U32_MAX) {
status = nvmet_req_find_ns(req);
- if (status)
+ if (status) {
+ /* 82h is Invalid Field for invalid NSIDs, not Invalid NS */
+ if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
+ status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
return status;
+ }
if (!req->ns->pr.enable)
return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
--
2.43.7
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h
2026-09-18 3:39 ` [PATCH 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h Guixin Liu
@ 2026-09-18 12:05 ` Christoph Hellwig
2026-09-20 1:57 ` Guixin Liu
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2026-09-18 12:05 UTC (permalink / raw)
To: Guixin Liu
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Nilay Shroff, Daniel Wagner, John Garry, Hannes Reinecke,
linux-nvme
On Fri, Sep 18, 2026 at 11:39:31AM +0800, Guixin Liu wrote:
> - if (status)
> + if (status) {
> + /* 82h is Invalid Field for invalid NSIDs, not Invalid NS */
Overly long line, but I don't this comment is very helpful as-is anyway.
For one mentioning the value while the code uses symbolic names is
confusing, but otherwise it also doesn't really say why we care.
IMHO we can just drop it?
> + if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
no need for the braces.
> + status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
Another overly long line. Easily fixed by just directly returning:
return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h
2026-09-18 12:05 ` Christoph Hellwig
@ 2026-09-20 1:57 ` Guixin Liu
0 siblings, 0 replies; 8+ messages in thread
From: Guixin Liu @ 2026-09-20 1:57 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Keith Busch, Jens Axboe, Sagi Grimberg, Nilay Shroff,
Daniel Wagner, John Garry, Hannes Reinecke, linux-nvme
在 2026/9/18 20:05, Christoph Hellwig 写道:
> On Fri, Sep 18, 2026 at 11:39:31AM +0800, Guixin Liu wrote:
>> - if (status)
>> + if (status) {
>> + /* 82h is Invalid Field for invalid NSIDs, not Invalid NS */
> Overly long line, but I don't this comment is very helpful as-is anyway.
> For one mentioning the value while the code uses symbolic names is
> confusing, but otherwise it also doesn't really say why we care.
> IMHO we can just drop it?
Yeah, sure, removed in v2.
>
>> + if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
> no need for the braces.
Sure.
>
>> + status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
> Another overly long line. Easily fixed by just directly returning:
>
> return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
Changed in v2, and also in patch2, thanks.
Best Regards,
Guixin Liu
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] nvmet: return Invalid Field for invalid NSIDs in Get Features 82h
2026-09-18 3:39 [PATCH 0/2] nvmet: fix FID 82h status codes for invalid NSIDs Guixin Liu
2026-09-18 3:39 ` [PATCH 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h Guixin Liu
@ 2026-09-18 3:39 ` Guixin Liu
2026-09-18 12:05 ` Christoph Hellwig
1 sibling, 1 reply; 8+ messages in thread
From: Guixin Liu @ 2026-09-18 3:39 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Nilay Shroff, Daniel Wagner, John Garry, Hannes Reinecke
Cc: linux-nvme
The Reservation Notification Mask feature (FID 82h) rejects the same
NSIDs for Get Features as for Set Features, plus the broadcast NSID:
"A Get Features command that uses a namespace ID of FFFFFFFFh
shall be aborted with status code of Invalid Field in Command.
If a Set Features command or a Get Features command attempts to
access the Reservation Notification Mask on a namespace that does
not support reservations or is invalid, then that command is
aborted with status code of Invalid Field in Command."
-- NVMe Base Specification, section 5.2.26.1.33
The Get Features handler routes the namespace lookup through
nvmet_req_find_ns(), which returns Invalid Namespace or Format for an
unknown NSID. Both rejected cases land there: a nonexistent NSID
fails the lookup, and so does the broadcast NSID, which never names a
namespace. Both are aborted with Invalid Namespace or Format instead
of Invalid Field in Command.
Translate the lookup failure to Invalid Field in Command, as was done
for Set Features.
Fixes: 5a47c2080a73 ("nvmet: support reservation feature")
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
drivers/nvme/target/pr.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
index 927e3c44952b..8762ef64aa46 100644
--- a/drivers/nvme/target/pr.c
+++ b/drivers/nvme/target/pr.c
@@ -79,8 +79,12 @@ u16 nvmet_get_feat_resv_notif_mask(struct nvmet_req *req)
u16 status;
status = nvmet_req_find_ns(req);
- if (status)
+ if (status) {
+ /* 82h is Invalid Field for invalid and broadcast NSIDs */
+ if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
+ status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
return status;
+ }
if (!req->ns->pr.enable)
return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
--
2.43.7
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 2/2] nvmet: return Invalid Field for invalid NSIDs in Get Features 82h
2026-09-18 3:39 ` [PATCH 2/2] nvmet: return Invalid Field for invalid NSIDs in Get " Guixin Liu
@ 2026-09-18 12:05 ` Christoph Hellwig
0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2026-09-18 12:05 UTC (permalink / raw)
To: Guixin Liu
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Nilay Shroff, Daniel Wagner, John Garry, Hannes Reinecke,
linux-nvme
On Fri, Sep 18, 2026 at 11:39:32AM +0800, Guixin Liu wrote:
> The Reservation Notification Mask feature (FID 82h) rejects the same
> NSIDs for Get Features as for Set Features, plus the broadcast NSID:
>
> "A Get Features command that uses a namespace ID of FFFFFFFFh
> shall be aborted with status code of Invalid Field in Command.
> If a Set Features command or a Get Features command attempts to
> access the Reservation Notification Mask on a namespace that does
> not support reservations or is invalid, then that command is
> aborted with status code of Invalid Field in Command."
>
> -- NVMe Base Specification, section 5.2.26.1.33
>
> The Get Features handler routes the namespace lookup through
> nvmet_req_find_ns(), which returns Invalid Namespace or Format for an
> unknown NSID. Both rejected cases land there: a nonexistent NSID
> fails the lookup, and so does the broadcast NSID, which never names a
> namespace. Both are aborted with Invalid Namespace or Format instead
> of Invalid Field in Command.
>
> Translate the lookup failure to Invalid Field in Command, as was done
> for Set Features.
>
> Fixes: 5a47c2080a73 ("nvmet: support reservation feature")
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
> drivers/nvme/target/pr.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
> index 927e3c44952b..8762ef64aa46 100644
> --- a/drivers/nvme/target/pr.c
> +++ b/drivers/nvme/target/pr.c
> @@ -79,8 +79,12 @@ u16 nvmet_get_feat_resv_notif_mask(struct nvmet_req *req)
> u16 status;
>
> status = nvmet_req_find_ns(req);
> - if (status)
> + if (status) {
> + /* 82h is Invalid Field for invalid and broadcast NSIDs */
> + if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
> + status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
> return status;
> + }
Same thing about the comment, and I guess a direct return would
also make this a tiny bit more readable.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/2] nvmet: fix FID 82h status codes for invalid NSIDs
@ 2026-09-18 3:38 Guixin Liu
0 siblings, 0 replies; 8+ messages in thread
From: Guixin Liu @ 2026-09-18 3:38 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Nilay Shroff, Daniel Wagner, John Garry, Hannes Reinecke
Cc: linux-nvme
The Reservation Notification Mask feature (FID 82h) defines its own
status code for NSIDs that do not name a namespace supporting
reservations:
"A Get Features command that uses a namespace ID of FFFFFFFFh
shall be aborted with status code of Invalid Field in Command. [...]
If a Set Features command or a Get Features command attempts to
access the Reservation Notification Mask on a namespace that does
not support reservations or is invalid, then that command is
aborted with status code of Invalid Field in Command."
-- NVMe Base Specification, section 5.2.26.1.33
nvmet routes the namespace lookup of both handlers through
nvmet_req_find_ns(), which returns Invalid Namespace or Format for an
unknown NSID. That is the correct status for the generic
namespace-scoped admin commands, but not for this feature. A Set
Features 82h naming a nonexistent NSID, a Get Features 82h naming a
nonexistent NSID, and a Get Features 82h using the broadcast NSID are
all aborted with Invalid Namespace or Format instead of Invalid Field
in Command.
Each patch fixes one handler and translates the lookup failure to
Invalid Field in Command. The Set Features broadcast, the
namespace-without-reservations case, the disabled namespace path
(Internal Path Error, commit 505363957fad ("nvmet: fix nvme status
code when namespace is disabled")) and everything else keep their
current behavior.
Verified with two hosts (distinct host identifiers) connected over
NVMe/TCP to an nvmet subsystem exporting two reservation-enabled
null_blk namespaces: all three rejected cases now return 0x6002,
while Set/Get Features on an active namespace, the Set Features
broadcast and the reservation commands behave as before, with no
splat in dmesg.
Guixin Liu (2):
nvmet: return Invalid Field for invalid NSIDs in Set Features 82h
nvmet: return Invalid Field for invalid NSIDs in Get Features 82h
drivers/nvme/target/pr.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--
2.43.7
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 0/2] nvmet: fix FID 82h status codes for invalid NSIDs
@ 2026-09-18 3:37 Guixin Liu
0 siblings, 0 replies; 8+ messages in thread
From: Guixin Liu @ 2026-09-18 3:37 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
Nilay Shroff, Daniel Wagner, John Garry, Hannes Reinecke
Cc: linux-nvme
The Reservation Notification Mask feature (FID 82h) defines its own
status code for NSIDs that do not name a namespace supporting
reservations:
"A Get Features command that uses a namespace ID of FFFFFFFFh
shall be aborted with status code of Invalid Field in Command. [...]
If a Set Features command or a Get Features command attempts to
access the Reservation Notification Mask on a namespace that does
not support reservations or is invalid, then that command is
aborted with status code of Invalid Field in Command."
-- NVMe Base Specification, section 5.2.26.1.33
nvmet routes the namespace lookup of both handlers through
nvmet_req_find_ns(), which returns Invalid Namespace or Format for an
unknown NSID. That is the correct status for the generic
namespace-scoped admin commands, but not for this feature. A Set
Features 82h naming a nonexistent NSID, a Get Features 82h naming a
nonexistent NSID, and a Get Features 82h using the broadcast NSID are
all aborted with Invalid Namespace or Format instead of Invalid Field
in Command.
Each patch fixes one handler and translates the lookup failure to
Invalid Field in Command. The Set Features broadcast, the
namespace-without-reservations case, the disabled namespace path
(Internal Path Error, commit 505363957fad ("nvmet: fix nvme status
code when namespace is disabled")) and everything else keep their
current behavior.
Verified with two hosts (distinct host identifiers) connected over
NVMe/TCP to an nvmet subsystem exporting two reservation-enabled
null_blk namespaces: all three rejected cases now return 0x6002,
while Set/Get Features on an active namespace, the Set Features
broadcast and the reservation commands behave as before, with no
splat in dmesg.
Guixin Liu (2):
nvmet: return Invalid Field for invalid NSIDs in Set Features 82h
nvmet: return Invalid Field for invalid NSIDs in Get Features 82h
drivers/nvme/target/pr.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--
2.43.7
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-09-20 1:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-18 3:39 [PATCH 0/2] nvmet: fix FID 82h status codes for invalid NSIDs Guixin Liu
2026-09-18 3:39 ` [PATCH 1/2] nvmet: return Invalid Field for invalid NSIDs in Set Features 82h Guixin Liu
2026-09-18 12:05 ` Christoph Hellwig
2026-09-20 1:57 ` Guixin Liu
2026-09-18 3:39 ` [PATCH 2/2] nvmet: return Invalid Field for invalid NSIDs in Get " Guixin Liu
2026-09-18 12:05 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2026-09-18 3:38 [PATCH 0/2] nvmet: fix FID 82h status codes for invalid NSIDs Guixin Liu
2026-09-18 3:37 Guixin Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox