Skip to content

Commit cdcdcaa

Browse files
g-edwardsaxboe
authored andcommitted
scsi: virtio_scsi: fix pi_bytes{out,in} on 4 KiB block size devices
When the underlying device is a 4 KiB logical block size device with a protection interval exponent of 0, i.e. 4096 bytes data + 8 bytes PI, the driver miscalculates the pi_bytes{out,in} by a factor of 8x (64 bytes). This leads to errors on all reads and writes on 4 KiB logical block size devices when CONFIG_BLK_DEV_INTEGRITY is enabled and the VIRTIO_SCSI_F_T10_PI feature bit has been negotiated. Fixes: e6dc783 ("virtio-scsi: Enable DIF/DIX modes in SCSI host LLD") Acked-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Edwards <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 359f642 commit cdcdcaa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/scsi/virtio_scsi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,12 @@ static void virtio_scsi_init_hdr_pi(struct virtio_device *vdev,
513513

514514
if (sc->sc_data_direction == DMA_TO_DEVICE)
515515
cmd_pi->pi_bytesout = cpu_to_virtio32(vdev,
516-
blk_rq_sectors(rq) *
517-
bi->tuple_size);
516+
bio_integrity_bytes(bi,
517+
blk_rq_sectors(rq)));
518518
else if (sc->sc_data_direction == DMA_FROM_DEVICE)
519519
cmd_pi->pi_bytesin = cpu_to_virtio32(vdev,
520-
blk_rq_sectors(rq) *
521-
bi->tuple_size);
520+
bio_integrity_bytes(bi,
521+
blk_rq_sectors(rq)));
522522
}
523523
#endif
524524

0 commit comments

Comments
 (0)