* [PATCH] nvme: duplicate NQNs check if devices needed
@ 2021-11-29 11:18 Liguang Zhang
2021-11-29 16:34 ` Keith Busch
0 siblings, 1 reply; 6+ messages in thread
From: Liguang Zhang @ 2021-11-29 11:18 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
Cc: linux-nvme, linux-kernel, Liguang Zhang
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.
Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com>
---
drivers/nvme/host/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 4c63564adeaa..80abb4526932 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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.
--
2.19.1.6.gb485710b
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: duplicate NQNs check if devices needed
2021-11-29 11:18 [PATCH] nvme: duplicate NQNs check if devices needed Liguang Zhang
@ 2021-11-29 16:34 ` Keith Busch
2021-11-29 18:48 ` Chaitanya Kulkarni
2021-11-30 5:04 ` luanshi
0 siblings, 2 replies; 6+ messages in thread
From: Keith Busch @ 2021-11-29 16:34 UTC (permalink / raw)
To: Liguang Zhang
Cc: Jens Axboe, Christoph Hellwig, Sagi Grimberg, linux-nvme, linux-kernel
On Mon, Nov 29, 2021 at 07:18:54PM +0800, Liguang Zhang wrote:
> @@ -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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: duplicate NQNs check if devices needed
2021-11-29 16:34 ` Keith Busch
@ 2021-11-29 18:48 ` Chaitanya Kulkarni
2021-11-30 5:04 ` luanshi
1 sibling, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2021-11-29 18:48 UTC (permalink / raw)
To: Liguang Zhang
Cc: Jens Axboe, Christoph Hellwig, Sagi Grimberg, linux-nvme,
linux-kernel, Keith Busch
Liguang,
On 11/29/21 8:34 AM, Keith Busch wrote:
> On Mon, Nov 29, 2021 at 07:18:54PM +0800, Liguang Zhang wrote:
>> @@ -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?
>
Please add t he quirk for a specific controller(s) as mentioned
by Keith.
-ck
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: duplicate NQNs check if devices needed
2021-11-29 16:34 ` Keith Busch
2021-11-29 18:48 ` Chaitanya Kulkarni
@ 2021-11-30 5:04 ` luanshi
2021-11-30 6:40 ` Christoph Hellwig
1 sibling, 1 reply; 6+ messages in thread
From: luanshi @ 2021-11-30 5:04 UTC (permalink / raw)
To: Keith Busch
Cc: Jens Axboe, Christoph Hellwig, Sagi Grimberg, linux-nvme, linux-kernel
Hi Keith,
在 2021/11/30 0:34, Keith Busch 写道:
> On Mon, Nov 29, 2021 at 07:18:54PM +0800, Liguang Zhang wrote:
>> @@ -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?
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:
https://pci-ids.ucw.cz/
"nqn." prefix is a required naming, so i used this way.
Thanks,
Liguang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: duplicate NQNs check if devices needed
2021-11-30 5:04 ` luanshi
@ 2021-11-30 6:40 ` Christoph Hellwig
2021-11-30 6:58 ` luanshi
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2021-11-30 6:40 UTC (permalink / raw)
To: luanshi
Cc: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
linux-nvme, linux-kernel
On Tue, Nov 30, 2021 at 01:04:55PM +0800, luanshi wrote:
> Hi Keith,
>
> 在 2021/11/30 0:34, Keith Busch 写道:
>> On Mon, Nov 29, 2021 at 07:18:54PM +0800, Liguang Zhang wrote:
>>> @@ -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?
>
> 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
What does this broken device report in the subnqn field?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nvme: duplicate NQNs check if devices needed
2021-11-30 6:40 ` Christoph Hellwig
@ 2021-11-30 6:58 ` luanshi
0 siblings, 0 replies; 6+ messages in thread
From: luanshi @ 2021-11-30 6:58 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Keith Busch, Jens Axboe, Sagi Grimberg, linux-nvme, linux-kernel
Hi Christoph,
在 2021/11/30 14:40, Christoph Hellwig 写道:
> On Tue, Nov 30, 2021 at 01:04:55PM +0800, luanshi wrote:
>> Hi Keith,
>>
>> 在 2021/11/30 0:34, Keith Busch 写道:
>>> On Mon, Nov 29, 2021 at 07:18:54PM +0800, Liguang Zhang wrote:
>>>> @@ -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?
>> 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
> 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
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e1e574ecf031..d043f4506c37 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-30 6:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 11:18 [PATCH] nvme: duplicate NQNs check if devices needed Liguang Zhang
2021-11-29 16:34 ` Keith Busch
2021-11-29 18:48 ` Chaitanya Kulkarni
2021-11-30 5:04 ` luanshi
2021-11-30 6:40 ` Christoph Hellwig
2021-11-30 6:58 ` luanshi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.