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);