nvme: duplicate NQNs check if devices needed
PATCH 1/1 nvme: duplicate NQNs check if devices needed
If a device provides an NQN it is expected to be globally unique. Unfortunately some firmware revisions for Intel P4500/P4510 and some other old devices did not satisfy this requirement. If devices have the same subnqn field, after a kernel upgrade from 4.19 to 5.10, if a system has >1 affected device then only one device is enabled. Error like this:
nvme nvme2: Duplicate cntlid 0 with nvme0, rejecting nvme nvme3: Duplicate cntlid 1 with nvme1, rejecting
In these circumstances, if subnqn did not begin with "nqn.", we assume that devices did not need subnqn check.
--- drivers/nvme/host/core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/nvme/host/core.c +3 -0
@@ -2587,6 +2587,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)lockdep_assert_held (&nvme_subsystems_lock); +if (strncmp (subsysnqn,"nqn." ,4 )) +return NULL ; +/* * Fail matches for discovery subsystems. This results * in each discovery controller bound to a unique subsystem.
Signature · 1 line
2.19.1.6.gb485710b
Keith Busch
maintainerdrivers/nvme/host/core.c static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) · line 2591
Quoted 6 lines · Liguang Zhang
drivers/nvme/host/core.c +2
-0@@ -2587,6 +2587,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)lockdep_assert_held (&nvme_subsystems_lock); +if (strncmp (subsysnqn,"nqn." ,4 )) +return NULL ;
This seems like an arbitrary way to decide not to check for duplicates. Shouldn't we just add the NVME_QUIRK_IGNORE_DEV_SUBNQN quirk for the broken controllers?
Liguang,
Quoted 12 lines · Keith Busch
drivers/nvme/host/core.c static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) · line 2591
Quoted 6 lines · Liguang Zhang
drivers/nvme/host/core.c +2
-0@@ -2587,6 +2587,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)lockdep_assert_held (&nvme_subsystems_lock); +if (strncmp (subsysnqn,"nqn." ,4 )) +return NULL ;This seems like an arbitrary way to decide not to check for duplicates. Shouldn't we just add the
NVME_QUIRK_IGNORE_DEV_SUBNQNquirk for the broken controllers?
Please add t he quirk for a specific controller(s) as mentioned by Keith.
-ck
Hi Keith,
Quoted 10 lines · Keith Busch
drivers/nvme/host/core.c static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) · line 2591
Quoted 6 lines · Liguang Zhang
drivers/nvme/host/core.c +2
-0@@ -2587,6 +2587,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)lockdep_assert_held (&nvme_subsystems_lock); +if (strncmp (subsysnqn,"nqn." ,4 )) +return NULL ;This seems like an arbitrary way to decide not to check for duplicates. Shouldn't we just add the
NVME_QUIRK_IGNORE_DEV_SUBNQNquirk for the broken controllers?
Yeah, add the NVME_QUIRK_IGNORE_DEV_SUBNQN quirk is a way to resolve the problem. I do not
have enough controller in my hand, I don't make sure all the controller are covered. And there are some
Weird devices from partners are not registered in pci id table:
"nqn." prefix is a required naming, so i used this way.
Thanks,
Liguang
Christoph Hellwig
maintainerQuoted 12 lines · luanshi
Hi Keith,
Quoted 8 lines · Keith Busch
drivers/nvme/host/core.c static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) · line 2589
Quoted 4 lines · Liguang Zhang
drivers/nvme/host/core.c +1
-0@@ -2587,6 +2587,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn)lockdep_assert_held (&nvme_subsystems_lock); + if (strncmp(subsysnqn, "nqn.", 4)) +return NULL ;This seems like an arbitrary way to decide not to check for duplicates. Shouldn't we just add the
NVME_QUIRK_IGNORE_DEV_SUBNQNquirk for the broken controllers?
Quoted 5 lines
Yeah, add the
NVME_QUIRK_IGNORE_DEV_SUBNQNquirk is a way to resolve the problem. I do nothave enough controller in my hand, I don't make sure all the controller are covered. And there are some
What does this broken device report in the subnqn field?
Hi Christoph,
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · luanshi
Hi Keith,
Quoted 8 lines · Keith Busch
Review static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) · line 2589
Quoted 4 lines · Liguang Zhang
(quoted diff) +1
-0@@ -2587,6 +2587,9 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) lockdep_assert_held(&nvme_subsystems_lock); + if (strncmp(subsysnqn, "nqn.", 4)) + return NULL;This seems like an arbitrary way to decide not to check for duplicates. Shouldn't we just add the
NVME_QUIRK_IGNORE_DEV_SUBNQNquirk for the broken controllers?
Quoted 6 lines
Quoted 5 lines
Yeah, add the
NVME_QUIRK_IGNORE_DEV_SUBNQNquirk is a way to resolve the problem. I do nothave enough controller in my hand, I don't make sure all the controller are covered. And there are some
What does this broken device report in the subnqn field?
In function nvme_init_subnqn, i add some printk info,
#git diff drivers/nvme/host/core.c
drivers/nvme/host/core.c +0 -0
@@ -2708,6 +2708,7 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct
if(!(ctrl->quirks & NVME_QUIRK_IGNORE_DEV_SUBNQN)) {
nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE);
+ printk("%s: nqnlen=%d, subnqn=%s\n", __func__, nqnlen, id->subnqn); if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) { strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE); return;
I found that:
nqnlen is 1, subnqn filed is filled by space.
nvme_init_subnqn: nqnlen=1 subnqn=
Thanks,
Liguang