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 <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/379696
Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2017-09-22 10:19:49 -07:00 committed by Jim Harris
parent 1f935c7a9b
commit 48d643b829

View File

@ -134,31 +134,18 @@ 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;
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 {
req->cdb[0] = SPDK_SBC_READ_10;
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);
}
} 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);
}
}
virtio_xmit_pkts(disk->vdev->vqs[2], vreq);
}