On Fri, Feb 21, 2025 at 04:07:55PM +0530, Anuj gupta wrote: > > I don't see any change in what's reported with block/for-next in a > > regular SCSI HBA/disk setup. Will have to look at whether there is a > > stacking issue wrt. multipathing. > > Hi Martin, Christoph, > > It seems this change in behaviour is not limited to SCSI only. As Nikhil > mentioned an earlier commit > [9f4aa46f2a74 ("block: invert the BLK_INTEGRITY_{GENERATE,VERIFY} flags")] > causes this change in behaviour. On my setup with a NVMe drive not formatted > with PI, I see that: > > Without this commit: > Value reported by read_verify and write_generate sysfs entries is 0. > > With this commit: > Value reported by read_verify and write_generate sysfs entries is 1. > > Diving a bit deeper, both these flags got inverted due to this commit. > But during init (in nvme_init_integrity) these values get initialized to 0, > inturn setting the sysfs entries to 1. In order to fix this, the driver has to > initialize both these flags to 1 in nvme_init_integrity if PI is not supported. > That way, the value in sysfs for these entries would become 0 again. Tried this > approach in my setup, and I am able to see the right values now. Then something > like this would also need to be done for SCSI too. > I tried to make it work for SCSI too. However my testing is limited as I don't have a SCSI device. With scsi_debug I see this currently: # modprobe scsi_debug dev_size_mb=128 dix=0 dif=0 # cat /sys/block/sda/integrity/write_generate 1 # cat /sys/block/sda/integrity/read_verify 1 # cat /sys/class/scsi_host/host0/prot_capabilities 0 To fix this, I added this. Nikhil can you try below patch? Martin, can you please take a look as well. After this patch, with the same scsi_debug device, I see sysfs entries populated as 0. diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c index ae6ce6f5d622..be2cd06f500b 100644 --- a/drivers/scsi/sd_dif.c +++ b/drivers/scsi/sd_dif.c @@ -40,8 +40,10 @@ void sd_dif_config_host(struct scsi_disk *sdkp, struct queue_limits *lim) dif = 0; dix = 1; } - if (!dix) + if (!dix) { + bi->flags |= BLK_INTEGRITY_NOGENERATE | BLK_INTEGRITY_NOVERIFY; return; + } /* Enable DMA of protection information */ if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP)