Skip to content

nvmet: fix FID 82h status codes for invalid NSIDs

Guixin Liu linux-nvme 2 versions – Applied

Status from this message: Thanks, applied to nvme-7.3.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 9 repliesApplied
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- drop the comments above the status translation.(Christoph Hellwig)
- return Invalid Field in Command directly instead of assigning it to status first, which also removes the braces and the overly long (Christoph Hellwig)

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2nvmet: return Invalid Field for invalid NSIDs in Set Features 82hdrivers/nvme/target/pr.c+2 -06 replies
2/2nvmet: return Invalid Field for invalid NSIDs in Get Features 82hdrivers/nvme/target/pr.c+2 -02 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchChristoph HellwigNilay Shroff
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] nvmet: fix FID 82h status codes for invalid NSIDs

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.

Changes since v1:

- drop the comments above the status translation.(Christoph Hellwig)
- return Invalid Field in Command directly instead of assigning it to status first, which also removes the braces and the overly long (Christoph Hellwig)

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 | 4 ++++
 1 file changed, 4 insertions(+)
Signature · 1 line
2.43.7