Re: [PATCH] nvme-core: Fix subsystem instance mismatches

From: Keith Busch
Date: Wed Sep 04 2019 - 13:16:19 EST


On Wed, Sep 04, 2019 at 11:01:22AM -0600, Logan Gunthorpe wrote:
> Oh, yes that's simpler than the struct/kref method and looks like it
> will accomplish the same thing. I did some brief testing with it and it
> seems to work for me (though I don't have any subsystems with multiple
> controllers). If you want to make a patch out of it you can add my
>
> Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>

Thanks! I'll make it a proper patch and send shortly.

For testing multi-controller subsystems, I haven't got proper hardware
either, so I really like the nvme loop target. Here's a very simple json
defining a two namespace subsystem backed by two real nvme devices:

loop.json:
---
{
"ports": [
{
"addr": {
"adrfam": "",
"traddr": "",
"treq": "not specified",
"trsvcid": "",
"trtype": "loop"
},
"portid": 1,
"referrals": [],
"subsystems": [
"testnqn"
]
}
],
"subsystems": [
{
"attr": {
"allow_any_host": "1"
},
"namespaces": [
{
"device": {
"nguid": "ef90689c-6c46-d44c-89c1-4067801309a8",
"path": "/dev/nvme0n1"
},
"enable": 1,
"nsid": 1
},
{
"device": {
"nguid": "ef90689c-6c46-d44c-89c1-4067801309a9",
"path": "/dev/nvme1n1"
},
"enable": 1,
"nsid": 2
}
],
"nqn": "testnqn"
}
]
}
--

Configure the target:

# nvmetcli restore loop.json

Connect to it twice:

# nvme connect -n testnqn -t loop
# nvme connect -n testnqn -t loop

List the result:

# nvme list -v
NVM Express Subsystems

Subsystem Subsystem-NQN Controllers
---------------- ------------------------------------------------------------------------------------------------ ----------------
nvme-subsys0 nqn.2014.08.org.nvmexpress:8086108ePHLE7200015N6P4BGN-17335943:ICDPC5ED2ORA6.4T nvme0
nvme-subsys1 nqn.2014.08.org.nvmexpress:8086108ePHLE7200015N6P4BGN-27335943:ICDPC5ED2ORA6.4T nvme1
nvme-subsys2 testnqn nvme2, nvme3

NVM Express Controllers

Device SN MN FR TxPort Address Subsystem Namespaces
-------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------
nvme0 PHLE7200015N6P4BGN-1 7335943:ICDPC5ED2ORA6.4T QDV1RD07 pcie 0000:88:00.0 nvme-subsys0 nvme0n1
nvme1 PHLE7200015N6P4BGN-2 7335943:ICDPC5ED2ORA6.4T QDV1RD03 pcie 0000:89:00.0 nvme-subsys1 nvme1n1
nvme2 9eb72cbeecc6fdb0 Linux 5.3.0-rc loop nvme-subsys2 nvme2n1, nvme2n2
nvme3 9eb72cbeecc6fdb0 Linux 5.3.0-rc loop nvme-subsys2 nvme2n1, nvme2n2

NVM Express Namespaces

Device NSID Usage Format Controllers
------------ -------- -------------------------- ---------------- ----------------
nvme0n1 1 3.20 TB / 3.20 TB 512 B + 0 B nvme0
nvme1n1 1 3.20 TB / 3.20 TB 512 B + 0 B nvme1
nvme2n1 1 3.20 TB / 3.20 TB 512 B + 0 B nvme2, nvme3
nvme2n2 2 3.20 TB / 3.20 TB 512 B + 0 B nvme2, nvme3