nvme-cli/list-ns: fix identifying active or allocated namespaces list
PATCH v2 1/1 nvme-cli/list-ns: fix identifying active or allocated namespaces list
The logic of the CNS field of identify namespace list is wrong. For example, nvme list-ns /dev/nvme0 -n 0 should return active namespaces list starting with id 1 (including), but currently this script command returns INVALID_OPCODE if the target doesn't support listing allocated namespaces or all the allocated attached namespaces id. So fix it by swaping the CNS flags of active and allocated list.
---
Changes sinse v1:
* Articulated the subject and commit comments
* Added signoff-by tag
* Added reviewed-by tag of Sagi
Quoted 1 line
8------------------------------------------------8<
nvme-ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nvme-ioctl.c +1 -1
@@ -353,7 +353,7 @@ int nvme_identify_ns(int fd, __u32 nsid, bool present, void *data)int nvme_identify_ns_list (int fd,__u32 nsid,bool all,void *data) { -int cns = all ?NVME_ID_CNS_NS_ACTIVE_LIST :NVME_ID_CNS_NS_PRESENT_LIST ; +int cns = all ?NVME_ID_CNS_NS_PRESENT_LIST :NVME_ID_CNS_NS_ACTIVE_LIST ;return nvme_identify (fd, nsid, cns, data); }
Signature · 1 line
2.6.4.windows.1
PATCH v2 1/1 nvme-cli/list-ns: fix identifying active or allocated namespaces list
Quoted 6 lines · Guan Junxiong
The logic of the CNS field of identify namespace list is wrong. For example, nvme list-ns
/dev/nvme0-n 0 should return active namespaces list starting with id 1 (including), but currently this script command returnsINVALID_OPCODEif the target doesn't support listing allocated namespaces or all the allocated attached namespaces id. So fix it by swaping the CNS flags of active and allocated list.
Thanks for the fix. Applied as-is, but I just want to point out that the status code for the situation you're describing should have been "Invalid Field in Command" rather than "Invalid Opcode".