Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvme_ctrl_alloc() can't handle duplicate connections #154

Closed
tbzatek opened this issue Dec 21, 2021 · 7 comments
Closed

nvme_ctrl_alloc() can't handle duplicate connections #154

tbzatek opened this issue Dec 21, 2021 · 7 comments
Labels
bug Something isn't working
Milestone

Comments

@tbzatek
Copy link
Contributor

tbzatek commented Dec 21, 2021

Okay, I admit my use case is a little weird and might not reflect real world scenario: loop transport, two (duplicate) connections, resulting in a single subsystem and two controllers in sysfs. The libnvme scanning logic would however only find one controller.

libnvme/src/nvme/tree.c

Lines 1270 to 1271 in ddd725e

c = nvme_lookup_ctrl(s, transport, traddr,
host_traddr, host_iface, trsvcid);

Looking at how nvme_lookup_ctrl() is called and how are the keys matched inside I see no way to distinguish seemingly duplicate controller entries, just having different name and sysfs path.

This is a broader issue, posting now in light of ongoing tree scanning logic rewrite in #108 to get some consideration.


# old/nvme list -v
NVM Express Subsystems

Subsystem        Subsystem-NQN                                                                                    Controllers
---------------- ------------------------------------------------------------------------------------------------ ----------------
nvme-subsys0     test_subnqn                                                                                      nvme0, nvme1

NVM Express Controllers

Device   SN                   MN                                       FR       TxPort Address        Subsystem    Namespaces      
-------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------
nvme0    cce1b445357e708d9d62 Linux                                    5.14.17- loop                  nvme-subsys0 nvme0n1, nvme0n2, nvme0n3
nvme1    cce1b445357e708d9d62 Linux                                    5.14.17- loop                  nvme-subsys0 nvme0n1, nvme0n2, nvme0n3

NVM Express Namespaces

Device       NSID     Usage                      Format           Controllers     
------------ -------- -------------------------- ---------------- ----------------
nvme0n1      1          1.07  GB /   1.07  GB    512   B +  0 B   nvme0, nvme1
nvme0n2      2          1.07  GB /   1.07  GB    512   B +  0 B   nvme0, nvme1
nvme0n3      3          1.07  GB /   1.07  GB    512   B +  0 B   nvme0, nvme1
# git-master/nvme list -v
Subsystem        Subsystem-NQN                                                                                    Controllers
---------------- ------------------------------------------------------------------------------------------------ ----------------
nvme-subsys0     test_subnqn                                                                                      nvme1

Device   SN                   MN                                       FR       TxPort Address        Subsystem    Namespaces      
-------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------
nvme1    cce1b445357e708d9d62 Linux                                    5.14.17- loop   (null)         nvme-subsys0 nvme0n3, nvme0n2, nvme0n1, nvme0n3, nvme0n2, nvme0n1

Device       Generic      NSID     Usage                      Format           Controllers     
------------ ------------ -------- -------------------------- ---------------- ----------------
nvme0n3      ng0n3        3          1.07  GB /   1.07  GB    512   B +  0 B   nvme1
nvme0n2      ng0n2        2          1.07  GB /   1.07  GB    512   B +  0 B   nvme1
nvme0n1      ng0n1        1          1.07  GB /   1.07  GB    512   B +  0 B   nvme1
@keithbusch
Copy link
Contributor

Thanks for the report! I don't think your setup is at all unusual for a fabrics target (even if it is "loop"). I'll take a look.

@hreinecke
Copy link
Collaborator

Hmm. That is true, we don't have a way of distinguish between them.
Typically we wouldn't notice it as we don't allow for duplicate connections.

Guess the only way to fix this is to return a list of controllers ...

@igaw igaw added the bug Something isn't working label Dec 23, 2021
@igaw
Copy link
Collaborator

igaw commented Feb 2, 2022

Ah, in this case we should at least change the current API so it is possible to return several controllers before we do our 1.0 release.

@igaw igaw added this to the 1.0 milestone Feb 2, 2022
@hreinecke
Copy link
Collaborator

I've now prepared PR #219, which should address this issue. Can you test with that?

@hreinecke
Copy link
Collaborator

With PR #219 I now get:

/tmp/nvme list -v

Subsystem Subsystem-NQN Controllers


nvme-subsys0 nqn.2014-08.org.nvmexpress:NVMf:uuid:95096971-6a11-46a0-8fbc-c301194c5857 nvme2, nvme1, nvme0

Device SN MN FR TxPort Address Subsystem Namespaces


nvme2 f51d6e34723a74bea185 Linux 5.16.0-r loop traddr=2 nvme-subsys0
nvme1 f51d6e34723a74bea185 Linux 5.16.0-r loop traddr=2 nvme-subsys0
nvme0 f51d6e34723a74bea185 Linux 5.16.0-r loop traddr=1 nvme-subsys0

@hreinecke
Copy link
Collaborator

PR has been merged.

@tbzatek
Copy link
Contributor Author

tbzatek commented Feb 4, 2022

Works fine now in my original scenario, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants