public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@meta.com>
To: <linux-nvme@lists.infradead.org>, <hch@lst.de>
Cc: <martin.petersen@oracle.com>, <joshi.k@samsung.com>,
	Keith Busch <kbusch@kernel.org>, David Wei <dw@davidwei.uk>
Subject: [PATCHv3] nvme: module parameter to disable pi with offsets
Date: Thu, 24 Oct 2024 08:49:23 -0700	[thread overview]
Message-ID: <20241024154923.3156803-1-kbusch@meta.com> (raw)

From: Keith Busch <kbusch@kernel.org>

A recent commit enables integrity checks for formats the previous kernel
versions registered with the "nop" integrity profile. This means
namespaces using that format become unreadable when upgrading the kernel
past that commit.

Introduce a module parameter to restore the "nop" integrity profile so
that storage can be readable once again. This could be a boot device, so
the setting needs to happen at module load time.

Fixes: 921e81db524d17 ("nvme: allow integrity when PI is not in first bytes")
Reported-by: David Wei <dw@davidwei.uk>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
v2->v3:

  Updated name and added a comment to explain why the parameter exists
 
 drivers/nvme/host/core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 84cb859a911d0..4ae878b86f2ba 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -91,6 +91,17 @@ module_param(apst_secondary_latency_tol_us, ulong, 0644);
 MODULE_PARM_DESC(apst_secondary_latency_tol_us,
 	"secondary APST latency tolerance in us");
 
+/*
+ * Older kernels didn't enable protection information if it was at an offset.
+ * Newer kernels do, so it breaks reads on the upgrade if such formats were
+ * used in prior kernels since the metadata written did not contain a valid
+ * checksum.
+ */
+static bool disable_pi_offsets = false;
+module_param(disable_pi_offsets, bool, 0444);
+MODULE_PARM_DESC(disable_pi_offsets,
+	"disable protection information if it has an offset");
+
 /*
  * nvme_wq - hosts nvme related works that are not reset or delete
  * nvme_reset_wq - hosts nvme reset works
@@ -1915,6 +1926,8 @@ static void nvme_configure_metadata(struct nvme_ctrl *ctrl,
 		head->pi_type = id->dps & NVME_NS_DPS_PI_MASK;
 	if (!(id->dps & NVME_NS_DPS_PI_FIRST))
 		info->pi_offset = head->ms - head->pi_size;
+	if (info->pi_offset && disable_pi)
+		head->pi_type = 0;
 
 	if (ctrl->ops->flags & NVME_F_FABRICS) {
 		/*
-- 
2.43.5



             reply	other threads:[~2024-10-24 15:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-24 15:49 Keith Busch [this message]
2024-10-24 15:53 ` [PATCHv3] nvme: module parameter to disable pi with offsets Christoph Hellwig
2024-10-24 16:44 ` Keith Busch
2024-10-24 17:29   ` Kanchan Joshi
2024-10-24 18:11   ` Chaitanya Kulkarni
2024-10-24 19:08 ` Tokunori Ikegami
2024-10-30 14:18 ` Keith Busch

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=20241024154923.3156803-1-kbusch@meta.com \
    --to=kbusch@meta.com \
    --cc=dw@davidwei.uk \
    --cc=hch@lst.de \
    --cc=joshi.k@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    /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