From 2e1a8b6c2e139c8fb69193659da31151ba0dae49 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Tue, 5 Sep 2017 18:01:00 +0200 Subject: [PATCH] bdev_virtio: add SCSI READ/WRITE 16 support Change-Id: I458dc865744ed2dd7fcf8e838029add090ff85fa Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/377170 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Reviewed-by: Pawel Wodkowski Reviewed-by: Daniel Verkamp --- lib/bdev/virtio/bdev_virtio.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/bdev/virtio/bdev_virtio.c b/lib/bdev/virtio/bdev_virtio.c index b9af17655..c130fea26 100644 --- a/lib/bdev/virtio/bdev_virtio.c +++ b/lib/bdev/virtio/bdev_virtio.c @@ -137,15 +137,27 @@ bdev_virtio_rw(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io) if (is_read) { vreq->iov = bdev_io->u.read.iovs; vreq->iovcnt = bdev_io->u.read.iovcnt; - req->cdb[0] = SPDK_SBC_READ_10; - to_be32(&req->cdb[2], bdev_io->u.read.offset_blocks); - to_be16(&req->cdb[7], bdev_io->u.read.num_blocks); + if (disk->num_blocks > (1ULL << 32)) { + req->cdb[0] = SPDK_SBC_READ_16; + to_be64(&req->cdb[2], bdev_io->u.read.offset_blocks); + to_be32(&req->cdb[10], bdev_io->u.read.num_blocks); + } else { + req->cdb[0] = SPDK_SBC_READ_10; + to_be32(&req->cdb[2], bdev_io->u.read.offset_blocks); + to_be16(&req->cdb[7], bdev_io->u.read.num_blocks); + } } else { vreq->iov = bdev_io->u.write.iovs; vreq->iovcnt = bdev_io->u.write.iovcnt; - req->cdb[0] = SPDK_SBC_WRITE_10; - to_be32(&req->cdb[2], bdev_io->u.write.offset_blocks); - to_be16(&req->cdb[7], bdev_io->u.write.num_blocks); + if (disk->num_blocks > (1ULL << 32)) { + req->cdb[0] = SPDK_SBC_WRITE_16; + to_be64(&req->cdb[2], bdev_io->u.write.offset_blocks); + to_be32(&req->cdb[10], bdev_io->u.write.num_blocks); + } else { + req->cdb[0] = SPDK_SBC_WRITE_10; + to_be32(&req->cdb[2], bdev_io->u.write.offset_blocks); + to_be16(&req->cdb[7], bdev_io->u.write.num_blocks); + } } virtio_xmit_pkts(disk->vdev->vqs[2], vreq);