Skip to contentSkip to conversation

nvme: module parameter to disable pi with offsets

PATCH Superseded Keith Busch 2 participants 2 messages Oct 24, 2024 NVMe

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme: module parameter to disable pi with offsets

From: Keith Busch <[email protected]>

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")

---
v1->v2:

Restrict the disabling only to the pi formats that have offsets

Disable the pi_type in the head rather than just with blk-integrity

 drivers/nvme/host/core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvme/host/core.c +6 -0
index 84cb859a911d0..2054535d7c2ef 100644
@@ -91,6 +91,10 @@ module_param(apst_secondary_latency_tol_us, ulong, 0644);
 MODULE_PARM_DESC(apst_secondary_latency_tol_us,
 	"secondary APST latency tolerance in us");
 
+static bool disable_pi = false;
+module_param(disable_pi, bool, 0444);
+MODULE_PARM_DESC(disable_pi, "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 +1919,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) {
 		/*
Signature · 1 line
2.43.5
#1 lore raw

drivers/nvme/host/core.c module_param(apst_secondary_latency_tol_us, ulong, 0644); · line 97

Quoted 4 lines · Keith Busch
drivers/nvme/host/core.c +4 -0
+static bool disable_pi = false;
+module_param(disable_pi, bool, 0444);
+MODULE_PARM_DESC(disable_pi, "disable protection information if it has an offset");
+

The variable and module paramter are a bit misnamed now. Also please add a comment explaining why we have this seemingly odd flag.