Commit 48d643b8 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/379696


Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 1f935c7a
Loading
Loading
Loading
Loading
+10 −23
Original line number Diff line number Diff line
@@ -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;
			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);
		}
	} 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;
		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_WRITE_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);
	}
	}

	virtio_xmit_pkts(disk->vdev->vqs[2], vreq);
}