]> Git Repo - linux.git/commitdiff
nvme: module parameter to disable pi with offsets
authorKeith Busch <[email protected]>
Wed, 23 Oct 2024 15:40:26 +0000 (08:40 -0700)
committerKeith Busch <[email protected]>
Wed, 30 Oct 2024 14:19:18 +0000 (07:19 -0700)
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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Kanchan Joshi <[email protected]>
Reviewed-by: Chaitanya Kulkarni <[email protected]>
Signed-off-by: Keith Busch <[email protected]>
drivers/nvme/host/core.c

index 09466e2087299f81d141654d4ae29b5c73119aae..ce20b916301a3700e3b5d3bd08a9ae38a4d7c87c 100644 (file)
@@ -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
@@ -1926,8 +1937,12 @@ static void nvme_configure_metadata(struct nvme_ctrl *ctrl,
 
        if (head->pi_size && head->ms >= head->pi_size)
                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 (!(id->dps & NVME_NS_DPS_PI_FIRST)) {
+               if (disable_pi_offsets)
+                       head->pi_type = 0;
+               else
+                       info->pi_offset = head->ms - head->pi_size;
+       }
 
        if (ctrl->ops->flags & NVME_F_FABRICS) {
                /*
This page took 0.051455 seconds and 4 git commands to generate.