linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvme: Fix cntlid validation when not using NVMEoF
@ 2019-08-14 14:26 Guilherme G. Piccoli
  2019-08-14 19:26 ` Sagi Grimberg
  2019-08-15 17:24 ` Sagi Grimberg
  0 siblings, 2 replies; 4+ messages in thread
From: Guilherme G. Piccoli @ 2019-08-14 14:26 UTC (permalink / raw)
  To: linux-nvme; +Cc: linux-block, gpiccoli, kbusch, axboe, hch, sagi

Commit 1b1031ca63b2 ("nvme: validate cntlid during controller initialisation")
introduced a validation for controllers with duplicate cntlid that runs
on nvme_init_subsystem(). The problem is that the validation relies on
ctrl->cntlid, and this value is assigned (from id_ctrl value) after the
call for nvme_init_subsystem() in nvme_init_identify() for non-fabrics
scenario. That leads to ctrl->cntlid always being 0 in case we have a
physical set of controllers in the same subsystem.

This patch fixes that by loading the discovered cntlid id_ctrl value into
ctrl->cntlid before the subsystem initialization, only for the non-fabrics
case. The patch was tested with emulated nvme devices (qemu) having two
controllers in a single subsystem. Without the patch, we couldn't make
it work failing in the duplicate check; when running with the patch, we
could see the subsystem holding both controllers.

For the fabrics case we see ctrl->cntlid has a more intricate relation
with the admin connect, so we didn't change that.

Fixes: 1b1031ca63b2 ("nvme: validate cntlid during controller initialisation")
Signed-off-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
---
 drivers/nvme/host/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 8f3fbe5ca937..cca270836892 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2591,6 +2591,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 			goto out_free;
 	}
 
+	if (!(ctrl->ops->flags & NVME_F_FABRICS))
+		ctrl->cntlid = le16_to_cpu(id->cntlid);
+
 	if (!ctrl->identified) {
 		int i;
 
@@ -2691,7 +2694,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 			goto out_free;
 		}
 	} else {
-		ctrl->cntlid = le16_to_cpu(id->cntlid);
 		ctrl->hmpre = le32_to_cpu(id->hmpre);
 		ctrl->hmmin = le32_to_cpu(id->hmmin);
 		ctrl->hmminds = le32_to_cpu(id->hmminds);
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvme: Fix cntlid validation when not using NVMEoF
  2019-08-14 14:26 [PATCH] nvme: Fix cntlid validation when not using NVMEoF Guilherme G. Piccoli
@ 2019-08-14 19:26 ` Sagi Grimberg
  2019-08-15 17:24 ` Sagi Grimberg
  1 sibling, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2019-08-14 19:26 UTC (permalink / raw)
  To: Guilherme G. Piccoli, linux-nvme; +Cc: linux-block, kbusch, axboe, hch

This looks fine, wonder how this wasn't detected before
as this area was tested by Jon Derrick..

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvme: Fix cntlid validation when not using NVMEoF
  2019-08-14 14:26 [PATCH] nvme: Fix cntlid validation when not using NVMEoF Guilherme G. Piccoli
  2019-08-14 19:26 ` Sagi Grimberg
@ 2019-08-15 17:24 ` Sagi Grimberg
  2019-08-15 18:10   ` Guilherme G. Piccoli
  1 sibling, 1 reply; 4+ messages in thread
From: Sagi Grimberg @ 2019-08-15 17:24 UTC (permalink / raw)
  To: Guilherme G. Piccoli, linux-nvme; +Cc: linux-block, kbusch, axboe, hch

Pulling this to nvme-5.3-rc

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvme: Fix cntlid validation when not using NVMEoF
  2019-08-15 17:24 ` Sagi Grimberg
@ 2019-08-15 18:10   ` Guilherme G. Piccoli
  0 siblings, 0 replies; 4+ messages in thread
From: Guilherme G. Piccoli @ 2019-08-15 18:10 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme; +Cc: linux-block, kbusch, axboe, hch

On 15/08/2019 14:24, Sagi Grimberg wrote:
> Pulling this to nvme-5.3-rc

Thanks Sagi!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-15 18:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 14:26 [PATCH] nvme: Fix cntlid validation when not using NVMEoF Guilherme G. Piccoli
2019-08-14 19:26 ` Sagi Grimberg
2019-08-15 17:24 ` Sagi Grimberg
2019-08-15 18:10   ` Guilherme G. Piccoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).