[PATCH] nvme: module parameter to disable pi checks
Keith Busch
kbusch at meta.com
Wed Oct 23 08:50:48 PDT 2024
From: Keith Busch <kbusch at 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 at davidwei.uk>
Signed-off-by: Keith Busch <kbusch at kernel.org>
---
drivers/nvme/host/core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ba6508455e185..67f8125df96a9 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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 used");
+
/*
* nvme_wq - hosts nvme related works that are not reset or delete
* nvme_reset_wq - hosts nvme reset works
@@ -1763,6 +1767,7 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
struct queue_limits *lim, struct nvme_ns_info *info)
{
struct blk_integrity *bi = &lim->integrity;
+ int pi_type = head->pi_type;
memset(bi, 0, sizeof(*bi));
@@ -1777,7 +1782,10 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
!(head->features & NVME_NS_METADATA_SUPPORTED))
return nvme_ns_has_pi(head);
- switch (head->pi_type) {
+ if (disable_pi)
+ pi_type = 0;
+
+ switch (pi_type) {
case NVME_NS_DPS_PI_TYPE3:
switch (head->guard_type) {
case NVME_NVM_NS_16B_GUARD:
--
2.43.5
More information about the Linux-nvme
mailing list