Skip to content

Commit 42ab37e

Browse files
committed
nvme: module parameter to disable pi with offsets
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: 921e81d ("nvme: allow integrity when PI is not in first bytes") Reported-by: David Wei <dw@davidwei.uk> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kanchan Joshi <joshi.k@samsung.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent f54f0d0 commit 42ab37e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/nvme/host/core.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ module_param(apst_secondary_latency_tol_us, ulong, 0644);
9191
MODULE_PARM_DESC(apst_secondary_latency_tol_us,
9292
"secondary APST latency tolerance in us");
9393

94+
/*
95+
* Older kernels didn't enable protection information if it was at an offset.
96+
* Newer kernels do, so it breaks reads on the upgrade if such formats were
97+
* used in prior kernels since the metadata written did not contain a valid
98+
* checksum.
99+
*/
100+
static bool disable_pi_offsets = false;
101+
module_param(disable_pi_offsets, bool, 0444);
102+
MODULE_PARM_DESC(disable_pi_offsets,
103+
"disable protection information if it has an offset");
104+
94105
/*
95106
* nvme_wq - hosts nvme related works that are not reset or delete
96107
* nvme_reset_wq - hosts nvme reset works
@@ -1926,8 +1937,12 @@ static void nvme_configure_metadata(struct nvme_ctrl *ctrl,
19261937

19271938
if (head->pi_size && head->ms >= head->pi_size)
19281939
head->pi_type = id->dps & NVME_NS_DPS_PI_MASK;
1929-
if (!(id->dps & NVME_NS_DPS_PI_FIRST))
1930-
info->pi_offset = head->ms - head->pi_size;
1940+
if (!(id->dps & NVME_NS_DPS_PI_FIRST)) {
1941+
if (disable_pi_offsets)
1942+
head->pi_type = 0;
1943+
else
1944+
info->pi_offset = head->ms - head->pi_size;
1945+
}
19311946

19321947
if (ctrl->ops->flags & NVME_F_FABRICS) {
19331948
/*

0 commit comments

Comments
 (0)