Skip to content

Conversation

@igaw
Copy link
Collaborator

@igaw igaw commented Jun 3, 2025

Depends on: linux-nvme/libnvme#1022
Fixes: #2830

@igaw igaw changed the title Fix filter Fix list-subsys filtering Jun 3, 2025
@igaw
Copy link
Collaborator Author

igaw commented Jun 10, 2025

the documentation should also be updated, that the device name is optional and just a filter.

@martin-gpy
Copy link
Contributor

I tried this from your fix-filter branches from both libnvme & nvme-cli, but do see some discrepancies in behavior here. For e.g. I have 5 NSs from 2 subsystems with one underlying path or controller each:

# nvme list
Node                  Generic               SN                   Model                                    Namespace  Usage                      Format           FW Rev
--------------------- --------------------- -------------------- ---------------------------------------- ---------- -------------------------- ---------------- --------
/dev/nvme1n1          /dev/ng1n1            81CYrBSoKGRJAAAAAAAN NetApp ONTAP Controller                  0x2          0.00   B /  10.74  GB    512   B +  0 B   9.18.1
/dev/nvme1n2          /dev/ng1n2            81CYrBSoKGRJAAAAAAAN NetApp ONTAP Controller                  0x1        330.56  MB /  10.74  GB      4 KiB +  0 B   9.18.1
/dev/nvme2n1          /dev/ng2n1            81CYrBSoKGRJAAAAAAAL NetApp ONTAP Controller                  0x2         20.48  kB /  10.74  GB      4 KiB +  0 B   9.18.1
/dev/nvme2n2          /dev/ng2n2            81CYrBSoKGRJAAAAAAAL NetApp ONTAP Controller                  0x3          0.00   B /  10.74  GB      4 KiB +  0 B   9.18.1
/dev/nvme2n3          /dev/ng2n3            81CYrBSoKGRJAAAAAAAL NetApp ONTAP Controller                  0x1        219.47  MB /  10.74  GB    512   B +  0 B   9.18.1

Now when I run list-subsys on a non-existent device from the 1st subsystem, I get the following blank output:

# nvme list-subsys /dev/nvme1n5
# echo $?
0

I get the same blank output for a non-existent device from a non-existent subsystem too:

# nvme list-subsys /dev/nvme3n1
# echo $?
0

So your patches are working as expected. But I see a problem when I run list-subsys on a valid device. For e.g.

# nvme list-subsys
nvme-subsys1 - NQN=nqn.1992-08.com.netapp:sn.48391d66c0a611ecaaa5d039ea165514:subsystem.subsys_CLIENT116_0
               hostnqn=nqn.2014-08.org.nvmexpress:uuid:e6550026-173e-4959-ba74-be367844bd8a
\
 +- nvme1 tcp traddr=192.168.1.116,trsvcid=4420,host_traddr=192.168.1.6,src_addr=192.168.1.6 live

nvme-subsys2 - NQN=nqn.1992-08.com.netapp:sn.48391d66c0a611ecaaa5d039ea165514:subsystem.subsys_CLIENT116
               hostnqn=nqn.2014-08.org.nvmexpress:uuid:e6550026-173e-4959-ba74-be367844bd8a
\
 +- nvme2 tcp traddr=192.168.1.116,trsvcid=4420,host_traddr=192.168.1.6,src_addr=192.168.1.6 live

No issues here when no devices are passed to list-subsys, as seen above. But when I run list-subsys on a valid device, I see the following discrepancy:

# nvme list-subsys /dev/nvme1n1
nvme-subsys1 - NQN=nqn.1992-08.com.netapp:sn.48391d66c0a611ecaaa5d039ea165514:subsystem.subsys_CLIENT116_0
               hostnqn=nqn.2014-08.org.nvmexpress:uuid:e6550026-173e-4959-ba74-be367844bd8a
\
 +- nvme1 tcp traddr=192.168.1.116,trsvcid=4420,host_traddr=192.168.1.6,src_addr=192.168.1.6 live optimized

nvme-subsys2 - NQN=nqn.1992-08.com.netapp:sn.48391d66c0a611ecaaa5d039ea165514:subsystem.subsys_CLIENT116
               hostnqn=nqn.2014-08.org.nvmexpress:uuid:e6550026-173e-4959-ba74-be367844bd8a
\

i.e. it mistakenly displays nvme-subsys2 as well above in addition to nvme-subsys1, which is wrong.

igaw added 2 commits June 30, 2025 17:17
nvme_match_device_filter is used by list-subsys where it is possible to
limit the output by providing a block device.

The current implementation only matches on subsystem ID level, but this
is not what the expectation is from the user. It is expected to limit
the output by the block device name.

Change the match to use the block device name instead.

Signed-off-by: Daniel Wagner <[email protected]>
When using list-subsys with the optional device filter argument, the
subsystem might not have any controller associated anymore, it was
filtered out. Avoid outputting any whitespace (or empty json data
structures) in this case.

Signed-off-by: Daniel Wagner <[email protected]>
@igaw
Copy link
Collaborator Author

igaw commented Jun 30, 2025

Thanks, I fixed the patch, works for me now:

# .build/nvme list-subsys  /dev/nvme0n1
nvme-subsys0 - NQN=nqn.1994-11.com.samsung:nvme:PM9B1:M.2:S67VNF0W218998
               hostnqn=nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36
\
 +- nvme0 pcie 0000:02:00.0 live

nvme-subsys1 - NQN=nqn.io-1
               hostnqn=nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36
\

after the update

# .build/nvme list-subsys /dev/nvme0n1
nvme-subsys0 - NQN=nqn.1994-11.com.samsung:nvme:PM9B1:M.2:S67VNF0W218998
               hostnqn=nqn.2014-08.org.nvmexpress:uuid:befdec4c-2234-11b2-a85c-ca77c773af36
\
 +- nvme0 pcie 0000:02:00.0 live

@igaw igaw merged commit c3b1f65 into linux-nvme:master Jul 1, 2025
17 checks passed
@igaw igaw deleted the fix-filter branch July 1, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nvme list-subsys fails to error out if invalid device is passed to it

2 participants