From: Luis Chamberlain <mcgrof@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Klaus Jensen <its@irrelevant.dk>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, mcgrof@kernel.org
Subject: Re: [PATCH 4/4] nvme: check that EUI/GUID/UUID are globally unique
Date: Thu, 7 Apr 2022 18:04:59 -0700 [thread overview]
Message-ID: <Yk+KO8hEYpnKdGu3@garbanzo> (raw)
In-Reply-To: <20220224192845.1097602-5-hch@lst.de>
On Thu, Feb 24, 2022 at 08:28:45PM +0100, Christoph Hellwig wrote:
> Add a check to verify that the unique identifiers are unique globally
> in addition to the existing check that verifies that they are unique
> inside a single subsystem.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/nvme/host/core.c | 38 ++++++++++++++++++++++++++++++++++++--
> 1 file changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index cece987ba1691..f8084ded69e50 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3810,12 +3810,45 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
> return ERR_PTR(ret);
> }
>
> +static int nvme_global_check_duplicate_ids(struct nvme_subsystem *this,
> + struct nvme_ns_ids *ids)
> +{
> + struct nvme_subsystem *s;
> + int ret = 0;
> +
> + /*
> + * Note that this check is racy as we try to avoid holding the global
> + * lock over the whole ns_head creation. But it is only intended as
> + * a sanity check anyway.
> + */
> + mutex_lock(&nvme_subsystems_lock);
> + list_for_each_entry(s, &nvme_subsystems, entry) {
> + if (s == this)
> + continue;
> + mutex_lock(&s->lock);
> + ret = nvme_subsys_check_duplicate_ids(s, ids);
> + mutex_unlock(&s->lock);
> + if (ret)
> + break;
> + }
> + mutex_unlock(&nvme_subsystems_lock);
> +
> + return ret;
> +}
> +
> static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid,
> struct nvme_ns_ids *ids, bool is_shared)
> {
> struct nvme_ctrl *ctrl = ns->ctrl;
> struct nvme_ns_head *head = NULL;
> - int ret = 0;
> + int ret;
> +
> + ret = nvme_global_check_duplicate_ids(ctrl->subsys, ids);
> + if (ret) {
> + dev_err(ctrl->device,
> + "globally duplicate IDs for nsid %d\n", nsid);
So what sort of meachanisms would break in nvme if we don't (as it was
before this patch)? The reason I ask is that it would seem tons of
instantiated qemu guests used the default, and don't set the UUID,
and so this is auto-generated as per the documentation [0]. However,
I'm suspecting the auto-generation may just be... a single value:
root@kdevops ~ # cat
/sys/devices/pci0000:00/0000:00:08.0/nvme/nvme0/nvme0n1/uuid
00000001-0000-0000-0000-000000000000
root@kdevops ~ # cat
/sys/devices/pci0000:00/0000:00:0b.0/nvme/nvme3/nvme3n1/uuid
00000001-0000-0000-0000-000000000000
root@kdevops ~ # cat
/sys/devices/pci0000:00/0000:00:0b.0/nvme/nvme3/nvme3n1/uuid
00000001-0000-0000-0000-000000000000
root@kdevops ~ # cat
/sys/devices/pci0000:00/0000:00:0a.0/nvme/nvme2/nvme2n1/uuid
00000001-0000-0000-0000-000000000000
This means I have to go manually try to decipher this out on my
guests.
Printing a warning would only make sense if this really isn't critical.
But as of now this patch will even prevent boot as some filesystems now
can't mount which were set to mount on /etc/fstab.
[0] https://qemu-project.gitlab.io/qemu/system/devices/nvme.html
Luis
next prev parent reply other threads:[~2022-04-08 1:05 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 19:28 properly validate the nvme uniqueue identifiers are unique v2 Christoph Hellwig
2022-02-24 19:28 ` [PATCH 1/4] nvme: cleanup __nvme_check_ids Christoph Hellwig
2022-02-24 22:50 ` Chaitanya Kulkarni
2022-02-24 19:28 ` [PATCH 2/4] nvme: fix the check for duplicate unique identifiers Christoph Hellwig
2022-02-24 22:51 ` Chaitanya Kulkarni
2022-02-24 19:28 ` [PATCH 3/4] nvme: check for duplicate identifiers earlier Christoph Hellwig
2022-02-24 22:52 ` Chaitanya Kulkarni
2022-02-24 19:28 ` [PATCH 4/4] nvme: check that EUI/GUID/UUID are globally unique Christoph Hellwig
2022-02-24 22:54 ` Chaitanya Kulkarni
2022-04-08 1:04 ` Luis Chamberlain [this message]
2022-04-08 5:29 ` Christoph Hellwig
2022-04-08 7:19 ` Klaus Jensen
2022-04-08 16:10 ` Christoph Hellwig
2022-04-08 17:46 ` Luis Chamberlain
2022-04-11 5:05 ` Christoph Hellwig
2022-04-11 5:54 ` Christoph Hellwig
2022-04-11 6:01 ` Klaus Jensen
2022-04-11 6:09 ` Christoph Hellwig
2022-04-11 6:11 ` Klaus Jensen
2022-04-12 18:46 ` Luis Chamberlain
2022-04-18 23:30 ` Alan Adamson
2022-04-20 7:36 ` Christoph Hellwig
2022-06-06 20:35 ` Alan Adamson
2022-06-06 21:38 ` Keith Busch
2022-06-06 21:51 ` Alan Adamson
2022-06-06 21:58 ` Keith Busch
2022-06-06 23:11 ` Alan Adamson
2022-06-07 19:01 ` Keith Busch
2022-06-08 7:48 ` Christoph Hellwig
2022-06-08 7:52 ` Christoph Hellwig
2022-06-08 18:11 ` Alan Adamson
2022-06-08 19:04 ` Keith Busch
2022-06-09 0:30 ` Chaitanya Kulkarni
2022-06-09 15:11 ` Alan Adamson
2022-06-09 3:53 ` Christoph Hellwig
2022-06-10 0:27 ` Alan Adamson
2022-06-10 14:12 ` Keith Busch
2022-06-15 20:15 ` Alan Adamson
2022-06-17 9:01 ` Christoph Hellwig
2022-06-21 18:40 ` Alan Adamson
2022-06-21 19:11 ` Keith Busch
2022-06-21 20:39 ` Alan Adamson
2022-06-22 11:00 ` Christoph Hellwig
2022-06-22 15:45 ` Alan Adamson
2022-02-24 19:38 ` properly validate the nvme uniqueue identifiers are unique v2 Keith Busch
-- strict thread matches above, loose matches on Subject: below --
2022-06-05 1:58 [PATCH 4/4] nvme: check that EUI/GUID/UUID are globally unique Stefan
2022-06-06 6:40 ` Christoph Hellwig
2022-06-06 12:42 ` Stefan
2022-06-06 15:03 ` Christoph Hellwig
2022-06-06 14:51 ` Keith Busch
2022-06-06 15:06 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yk+KO8hEYpnKdGu3@garbanzo \
--to=mcgrof@kernel.org \
--cc=hch@lst.de \
--cc=its@irrelevant.dk \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox