From: Yihan Xin <xyh1996@gmail.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: Yihan Xin <xyh1996@gmail.com>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] nvme: Force ns info updates on validation if NID is bogus
Date: Tue, 10 Sep 2024 17:50:06 +0800 [thread overview]
Message-ID: <20240910095006.41027-1-xyh1996@gmail.com> (raw)
When validating a namespace, nvme_update_ns_info()
would be skipped if nsid changed. However, this
happens everytime the in-use controller is
reattached if NID is bogus, causing nsid not being
restored to the previous one, eg /dev/nvme0n2 ->
/dev/nvme0n1.
Don't skip ns info updates on this circumstance.
Signed-off-by: Yihan Xin <xyh1996@gmail.com>
---
drivers/nvme/host/core.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 1236e3aa00ed..c0875fb93b8d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3979,11 +3979,24 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_info *info)
int ret = NVME_SC_INVALID_NS | NVME_STATUS_DNR;
if (!nvme_ns_ids_equal(&ns->head->ids, &info->ids)) {
- dev_err(ns->ctrl->device,
- "identifiers changed for nsid %d\n", ns->head->ns_id);
- goto out;
+ /*
+ * Don't skip ns info updates if the NID is bogus as it
+ * changes everytime the in-use controller is reattached
+ * to the bus and thus the namespace is recognized as
+ * another one.
+ */
+ if (ns->ctrl->quirks & NVME_QUIRK_BOGUS_NID) {
+ dev_info(ns->ctrl->device,
+ "Ignoring nsid change for bogus ns\n");
+ } else {
+ dev_err(ns->ctrl->device,
+ "identifiers changed for nsid %d\n",
+ ns->head->ns_id);
+ goto out;
+ }
}
+
ret = nvme_update_ns_info(ns, info);
out:
/*
--
2.46.0
next reply other threads:[~2024-09-10 9:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 9:50 Yihan Xin [this message]
2024-09-10 12:45 ` [PATCH] nvme: Force ns info updates on validation if NID is bogus Hannes Reinecke
2024-09-12 9:40 ` Christoph Hellwig
2024-09-13 2:18 ` Yihan Xin
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=20240910095006.41027-1-xyh1996@gmail.com \
--to=xyh1996@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.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