From: Hannes Reinecke <hare@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 4/4] nvme: remove existing namespace on ID mismatch
Date: Mon, 2 Sep 2024 13:15:48 +0200 [thread overview]
Message-ID: <20240902111548.41430-5-hare@kernel.org> (raw)
In-Reply-To: <20240902111548.41430-1-hare@kernel.org>
When the namespace IDs mismatch during rescan we clearly ran out of
sync with the target, but we really can't know whether our local copy
of the NSID is correct, and that one found by scanning is not.
But clearly something is wrong with the namespaces, so we should remove
the existing one, too, to avoid accidental data corruption.
Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
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 0dc8bcc664f2..626718bbf3a5 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -136,6 +136,7 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
unsigned nsid);
static void nvme_update_keep_alive(struct nvme_ctrl *ctrl,
struct nvme_command *cmd);
+static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid);
void nvme_queue_scan(struct nvme_ctrl *ctrl)
{
@@ -3746,8 +3747,9 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
}
if (!nvme_ns_ids_equal(&head->ids, &info->ids)) {
dev_err(ctrl->device,
- "IDs don't match for shared namespace %d\n",
+ "IDs don't match for shared namespace %d, removing\n",
info->nsid);
+ nvme_ns_remove_by_nsid(ctrl, info->nsid);
goto out_put_ns_head;
}
--
2.35.3
next prev parent reply other threads:[~2024-09-02 11:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 11:15 [PATCH 0/4] nvme: NSHEAD_DISK_LIVE fixes Hannes Reinecke
2024-09-02 11:15 ` [PATCH 1/4] nvme-multipath: fixup typo when clearing DISK_LIVE Hannes Reinecke
2024-09-02 16:48 ` Sagi Grimberg
2024-09-02 11:15 ` [PATCH 2/4] nvme-multipath: clear 'NVME_NSHEAD_DISK_LIVE' bit on shutdown Hannes Reinecke
2024-09-02 16:51 ` Sagi Grimberg
2024-09-02 11:15 ` [PATCH 3/4] nvme-multipath: check for NVME_NSHEAD_DISK_LIVE when selecting paths Hannes Reinecke
2024-09-02 16:53 ` Sagi Grimberg
2024-09-02 11:15 ` Hannes Reinecke [this message]
2024-09-02 17:01 ` [PATCH 4/4] nvme: remove existing namespace on ID mismatch Sagi Grimberg
2024-09-03 12:30 ` Hannes Reinecke
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=20240902111548.41430-5-hare@kernel.org \
--to=hare@kernel.org \
--cc=hch@lst.de \
--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 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.