[PATCH v1 2/3] nvme: Fix incorrect block integrity sysfs values for non-PI namespaces
Anuj Gupta
anuj20.g at samsung.com
Mon Feb 24 20:46:52 PST 2025
Commit 9f4aa46f2a74
("block: invert the BLK_INTEGRITY{GENERATE,VERIFY} flags") caused
read_verify and write_generate to report 1 for NVMe namespaces
without PI support. This happens because BLK_INTEGRITY_NOGENERATE and
BLK_INTEGRITY_NOVERIFY were not explicitly set.
Fix this by initializing these flags by default and clearing them only
when the namespace supports PI.
Fixes: 9f4aa46f2a74 ("block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags")
Signed-off-by: Anuj Gupta <anuj20.g at samsung.com>
---
drivers/nvme/host/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 818d4e49aab5..fe599a811d38 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1799,6 +1799,7 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
memset(bi, 0, sizeof(*bi));
+ bi->flags = BLK_INTEGRITY_NOGENERATE | BLK_INTEGRITY_NOVERIFY;
if (!head->ms)
return true;
@@ -1850,6 +1851,9 @@ static bool nvme_init_integrity(struct nvme_ns_head *head,
break;
}
+ if (bi->flags & BLK_INTEGRITY_DEVICE_CAPABLE)
+ bi->flags &= ~(BLK_INTEGRITY_NOGENERATE |
+ BLK_INTEGRITY_NOVERIFY);
bi->tuple_size = head->ms;
bi->pi_offset = info->pi_offset;
return true;
--
2.25.1
More information about the Linux-nvme
mailing list