From: Xiang Chen <chenxiang66@xxxxxxxxxxxxx> If formatting a normal SAS disk to a DIF disk, it will revalidate the disk through function bdev_disk_changed() at last which will call disk->fops->revalidate_disk() (sd_revalidate_disk() for sd driver). It is DIF type if querying the disk. Log is as follows: [root@Euler ~]# sg_format --format --fmtpinfo=2 /dev/sdb HGST HUSMM1640ASS204 C2D0 peripheral_type: disk [0x0] << supports protection information>> Mode Sense (block descriptor) data, prior to changes: Number of blocks=781422768 [0x2e9390b0] Block size=512 [0x200] A FORMAT will commence in 10 seconds ALL data on /dev/sdb will be DESTROYED Press control-C to abort A FORMAT will commence in 5 seconds ALL data on /dev/sdb will be DESTROYED Press control-C to abort Format has started FORMAT Complete [ 140.082146] sd 3:0:1:0: [sdb] Disabling DIF Type 1 protection [root@Euler ~]# lsscsi -p [3:0:0:0] disk ATA ST4000NM0035-1V4 TN03 /dev/sda - none [3:0:1:0] disk HGST HUSMM1640ASS204 C2D0 /dev/sdb DIF/Type1 none [3:0:2:0] disk HGST HUSMM1640ASS204 C2D0 /dev/sdc - none [3:0:3:0] disk HGST HUSMM1640ASS204 C2D0 /dev/sdd - none [3:0:4:0] disk HGST HUSMM1640ASS204 C2D0 /dev/sde - none [3:0:5:0] disk HGST HUSMM1640ASS204 C2D0 /dev/sdf - none But as the commit (471bd0af544b ("sd: use bdev_check_media_change")), it removes the interface revalidate_disk of sd_fops, so it will not revalidate the disk after formatting the disk, so if querying the disk, it is still not DIF type but actually it is already formatted as DIF disk. To solve the issue, still use sd_revalidate_disk() to fill the interface revalidate_disk of sd_fops. Fixes: 471bd0af544b ("sd: use bdev_check_media_change") Signed-off-by: Xiang Chen <chenxiang66@xxxxxxxxxxxxx> --- drivers/scsi/sd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 656bcf4..01eaac1 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1888,6 +1888,7 @@ static const struct block_device_operations sd_fops = { .compat_ioctl = sd_compat_ioctl, #endif .check_events = sd_check_events, + .revalidate_disk = sd_revalidate_disk, .unlock_native_capacity = sd_unlock_native_capacity, .report_zones = sd_zbc_report_zones, .pr_ops = &sd_pr_ops, -- 2.8.1