public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Christoph Hellwig" <hch@lst.de>,
	"Linux regressions mailing list" <regressions@lists.linux.dev>,
	"Pankaj Raghav" <p.raghav@samsung.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Bagas Sanjaya" <bagasdotme@gmail.com>,
	"Jens Axboe" <axboe@kernel.dk>,
	"Sagi Grimberg" <sagi@grimberg.me>,
	"Clemens S." <cspringsguth@gmail.com>,
	"Martin Belanger" <martin.belanger@dell.com>,
	"Chaitanya Kulkarni" <kch@nvidia.com>,
	"John Meneghini" <jmeneghi@redhat.com>,
	"Hannes Reinecke" <hare@suse.de>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Linux NVMe" <linux-nvme@lists.infradead.org>,
	"Kanchan Joshi" <joshi.k@samsung.com>,
	"Javier Gonzalez" <javier.gonz@samsung.com>,
	박진환 <jh.i.park@samsung.com>
Subject: Re: Fwd: Need NVME QUIRK BOGUS for SAMSUNG MZ1WV480HCGL-000MV (Samsung SM-953 Datacenter SSD)
Date: Wed, 12 Jul 2023 18:45:46 +0200	[thread overview]
Message-ID: <20230712164546.GA31434@lst.de> (raw)
In-Reply-To: <CAHk-=whXh9sgLo24RO02JjfD0m3HE5NADRPWoEd+dW6bruFhVA@mail.gmail.com>

On Tue, Jul 11, 2023 at 09:47:00AM -0700, Linus Torvalds wrote:
> Anybody who expected unique ID's is frankly completely incompetent.
> People should have *known* not to do this.

Except that storage software really does rely on them.  Not your
laptop (or mine) but all kinds of data center software.  Where these
IDs have worked fine for decades.  It just turns out nvme has the
misfortune of trying to deal with both that and cheap consumer crap.

> and we have NEVER EVER seen devices with reliably unique IDs. Really.

Sorry, but that's bullshit. 

> iow, the code even checks for and *notices* that there are duplicate
> IDs, and what does it do? It then errors out.

Yes.  Because we have applications which will lose data if they
suddently get the wrong device.  

> I think the code should *default* to "unreliable uuid", and then if
> you're sure it's actually ok, then you use it. Then some rare
> enterprise user with multipathing  - who is going to be very very
> careful about which device to use anyway - can use the "approved
> list".

That doesn't scale either.

> Or "Oh, I noticed a non-unique UUID, let me generate one for you based
> on physical location".
> 
> But this "my disk doesn't work in v6.0 and later because some clown
> added a duplicate check that shouldn't be there" is not a good thing
> to then try to make excuses for.

Well, let's try something like this (co-developed with Sagi) that
allows it for non-multipath PCIe devices, hich covers the quirks
we've added so far, but also add a big fat warning, because we know
people rely on the /dev/disk/by-id/ links.  Probably not on these
devices, but who knows.

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 47d7ba2827ff29..37b6fa74666204 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3431,10 +3431,40 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
 
 	ret = nvme_global_check_duplicate_ids(ctrl->subsys, &info->ids);
 	if (ret) {
-		dev_err(ctrl->device,
-			"globally duplicate IDs for nsid %d\n", info->nsid);
+		/*
+		 * We've found two different namespaces on two different
+		 * subsystems that report the same ID.  This is pretty nasty
+		 * for anything that actually requires unique device
+		 * identification.  In the kernel we need this for multipathing,
+		 * and in user space the /dev/disk/by-id/ links rely on it.
+		 *
+		 * If the device also claims to be multi-path capable back off
+		 * here now and refuse the probe the second device as this is a
+		 * recipe for data corruption.  If not this is probably a
+		 * cheap consumer device if on the PCIe bus, so let the user
+		 * proceed and use the shiny toy, but warn that with changing
+		 * probing order (which due to our async probing could just be
+		 * device taking longer to startup) the other device could show
+		 * up at any time.
+		 */
 		nvme_print_device_info(ctrl);
-		return ret;
+		if ((ns->ctrl->ops->flags & NVME_F_FABRICS) || /* !PCIe */
+		    ((ns->ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) &&
+		     info->is_shared)) {
+			dev_err(ctrl->device,
+				"ignoring nsid %d because of duplicate IDs\n",
+				info->nsid);
+			return ret;
+		}
+
+		dev_err(ctrl->device,
+			"clearing duplicate IDs for nsid %d\n", info->nsid);
+		dev_err(ctrl->device,
+			"use of /dev/disk/by-id/ may cause data corruption\n");
+		memset(&info->ids.nguid, 0, sizeof(info->ids.nguid));
+		memset(&info->ids.uuid, 0, sizeof(info->ids.uuid));
+		memset(&info->ids.eui64, 0, sizeof(info->ids.eui64));
+		ctrl->quirks |= NVME_QUIRK_BOGUS_NID;
 	}
 
 	mutex_lock(&ctrl->subsys->lock);

  parent reply	other threads:[~2023-07-12 16:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26  1:15 Fwd: Need NVME QUIRK BOGUS for SAMSUNG MZ1WV480HCGL-000MV (Samsung SM-953 Datacenter SSD) Bagas Sanjaya
     [not found] ` <8f4e6d32-55b3-9df5-de91-1afbcb30ce13@nvidia.com>
2023-06-26 18:26   ` Linux regression tracking (Thorsten Leemhuis)
2023-06-27 16:10 ` Keith Busch
     [not found]   ` <9b778d59-c8d5-b037-0eb7-34cee5f273cc@samsung.com>
2023-06-30 15:18     ` Clemens Springsguth
2023-06-30 16:21       ` Pankaj Raghav
2023-07-03 13:25         ` Clemens Springsguth
2023-07-10  8:52   ` Linux regression tracking (Thorsten Leemhuis)
2023-07-10 15:58     ` Keith Busch
     [not found]       ` <f0fdf86e-4293-8e07-835d-b5a866252068@samsung.com>
2023-07-11  9:39         ` Linux regression tracking (Thorsten Leemhuis)
2023-07-11 12:06           ` Christoph Hellwig
2023-07-11 12:14             ` Sagi Grimberg
2023-07-11 14:12               ` Greg KH
2023-07-11 14:39                 ` Sagi Grimberg
2023-07-11 15:33             ` Keith Busch
2023-07-11 16:47             ` Linus Torvalds
2023-07-11 17:21               ` Keith Busch
2023-07-11 22:07                 ` John Meneghini
2023-07-12  7:38                 ` Sagi Grimberg
2023-07-12 16:48                   ` Linus Torvalds
2023-07-12 16:45               ` Christoph Hellwig [this message]
2023-07-12 16:51                 ` Linus Torvalds
2023-07-12 16:57                   ` Christoph Hellwig
2023-07-12 17:34                     ` Linus Torvalds
2023-07-13 11:44                       ` Christoph Hellwig
2023-07-13 16:53                         ` Linus Torvalds
2023-07-16 19:19         ` August Wikerfors

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=20230712164546.GA31434@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=bagasdotme@gmail.com \
    --cc=cspringsguth@gmail.com \
    --cc=hare@suse.de \
    --cc=javier.gonz@samsung.com \
    --cc=jh.i.park@samsung.com \
    --cc=jmeneghi@redhat.com \
    --cc=joshi.k@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.belanger@dell.com \
    --cc=p.raghav@samsung.com \
    --cc=regressions@lists.linux.dev \
    --cc=sagi@grimberg.me \
    --cc=torvalds@linux-foundation.org \
    /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