mbox series

[0/2] virtio_scsi pi_bytes{out,in} miscalculated on 4 KiB devices

Message ID 20180725142259.20562-1-gedwards@ddn.com (mailing list archive)
Headers show
Series virtio_scsi pi_bytes{out,in} miscalculated on 4 KiB devices | expand

Message

Greg Edwards July 25, 2018, 2:22 p.m. UTC
When the VIRTIO_SCSI_F_T10_PI feature bit is enabled, the virtio_scsi driver
does not correctly calculate pi_bytes{out,in} when the underlying device has a
4 KiB logical block size.  The current code assumes a 512 byte logical block
size and protection interval exponent of 0 (512 bytes + 8 bytes PI).

The first patch moves bio_integrity_intervals() and bio_integrity_bytes() into
blkdev.h so drivers can make use of them.  The second patch modifies
virtio_scsi to call bio_integrity_bytes() to get the values for
pi_bytes{out,in}.

Greg Edwards (2):
  block: move bio_integrity_{intervals,bytes} into blkdev.h
  scsi: virtio_scsi: fix pi_bytes{out,in} on 4 KiB block size devices

 block/bio-integrity.c      | 22 ----------------------
 drivers/scsi/virtio_scsi.c |  8 ++++----
 include/linux/blkdev.h     | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 26 deletions(-)

Comments

Jens Axboe July 26, 2018, 9:49 p.m. UTC | #1
On 7/25/18 7:22 AM, Greg Edwards wrote:
> When the VIRTIO_SCSI_F_T10_PI feature bit is enabled, the virtio_scsi driver
> does not correctly calculate pi_bytes{out,in} when the underlying device has a
> 4 KiB logical block size.  The current code assumes a 512 byte logical block
> size and protection interval exponent of 0 (512 bytes + 8 bytes PI).
> 
> The first patch moves bio_integrity_intervals() and bio_integrity_bytes() into
> blkdev.h so drivers can make use of them.  The second patch modifies
> virtio_scsi to call bio_integrity_bytes() to get the values for
> pi_bytes{out,in}.

Applied, thanks.