Message ID | 20250225044653.6867-3-anuj20.g@samsung.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v1,1/3] block: Fix incorrect integrity sysfs reporting for DM devices | expand |
On Tue, Feb 25, 2025 at 10:16:52AM +0530, Anuj Gupta wrote: > 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); I don't think the driver is the proper place to do this, this should be done in blk_validate_integrity_limits. That should also take care or the stacked devices and remove the need for the last hunk in the previous patch.
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;
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@samsung.com> --- drivers/nvme/host/core.c | 4 ++++ 1 file changed, 4 insertions(+)