From 48d643b829048db90e123a6df1250ca3051b6a49 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 22 Sep 2017 10:19:49 -0700 Subject: [PATCH] bdev/virtio: simplify READ/WRITE 10/16 logic Now that the bdev_io read and write branches of the union have been unified, the virtio-scsi bdev I/O code can be simplified a little bit. Change-Id: Iadbe55862770a1b0e7f854b724a70d94c704218e Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/379696 Reviewed-by: Dariusz Stojaczyk Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- lib/bdev/virtio/bdev_virtio.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/lib/bdev/virtio/bdev_virtio.c b/lib/bdev/virtio/bdev_virtio.c index c5582d2b8..f8e224b84 100644 --- a/lib/bdev/virtio/bdev_virtio.c +++ b/lib/bdev/virtio/bdev_virtio.c @@ -134,30 +134,17 @@ bdev_virtio_rw(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io) req->lun[0] = 1; req->lun[1] = 0; - if (is_read) { - vreq->iov = bdev_io->u.bdev.iovs; - vreq->iovcnt = bdev_io->u.bdev.iovcnt; - if (disk->num_blocks > (1ULL << 32)) { - req->cdb[0] = SPDK_SBC_READ_16; - to_be64(&req->cdb[2], bdev_io->u.bdev.offset_blocks); - to_be32(&req->cdb[10], bdev_io->u.bdev.num_blocks); - } else { - req->cdb[0] = SPDK_SBC_READ_10; - to_be32(&req->cdb[2], bdev_io->u.bdev.offset_blocks); - to_be16(&req->cdb[7], bdev_io->u.bdev.num_blocks); - } + vreq->iov = bdev_io->u.bdev.iovs; + vreq->iovcnt = bdev_io->u.bdev.iovcnt; + + if (disk->num_blocks > (1ULL << 32)) { + req->cdb[0] = is_read ? SPDK_SBC_READ_16 : SPDK_SBC_WRITE_16; + to_be64(&req->cdb[2], bdev_io->u.bdev.offset_blocks); + to_be32(&req->cdb[10], bdev_io->u.bdev.num_blocks); } else { - vreq->iov = bdev_io->u.bdev.iovs; - vreq->iovcnt = bdev_io->u.bdev.iovcnt; - if (disk->num_blocks > (1ULL << 32)) { - req->cdb[0] = SPDK_SBC_WRITE_16; - to_be64(&req->cdb[2], bdev_io->u.bdev.offset_blocks); - to_be32(&req->cdb[10], bdev_io->u.bdev.num_blocks); - } else { - req->cdb[0] = SPDK_SBC_WRITE_10; - to_be32(&req->cdb[2], bdev_io->u.bdev.offset_blocks); - to_be16(&req->cdb[7], bdev_io->u.bdev.num_blocks); - } + req->cdb[0] = is_read ? SPDK_SBC_READ_10 : SPDK_SBC_WRITE_10; + to_be32(&req->cdb[2], bdev_io->u.bdev.offset_blocks); + to_be16(&req->cdb[7], bdev_io->u.bdev.num_blocks); } virtio_xmit_pkts(disk->vdev->vqs[2], vreq);