bdev/virtio: send scan I/O payload descriptor only when necessary
SCSI doesn't specify any payload associated with TEST_UNIT_READY and START_STOP_UNIT commands. Sending a payload didn't cause any troubles so far, but still it's not SCSI compliant and hence has been removed. It is now assumed that iov_len of 0 means that no payload should be sent. Change-Id: Ibdfa7cd77af6049132278911d872cd52c10be6c7 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/391868 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
36e34144f5
commit
a27d7bc188
@ -892,19 +892,20 @@ send_scan_io(struct virtio_scsi_scan_base *base)
|
||||
struct virtio_scsi_io_ctx *io_ctx = &base->io_ctx;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtqueue *vq = base->channel->vq;
|
||||
int payload_iov_cnt = base->iov.iov_len > 0 ? 1 : 0;
|
||||
int rc;
|
||||
|
||||
req->lun[0] = 1;
|
||||
req->lun[1] = base->info.target;
|
||||
|
||||
rc = virtqueue_req_start(vq, io_ctx, 3);
|
||||
rc = virtqueue_req_start(vq, io_ctx, 2 + payload_iov_cnt);
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
virtqueue_req_add_iovs(vq, &io_ctx->iov_req, 1, SPDK_VIRTIO_DESC_RO);
|
||||
virtqueue_req_add_iovs(vq, &io_ctx->iov_resp, 1, SPDK_VIRTIO_DESC_WR);
|
||||
virtqueue_req_add_iovs(vq, &base->iov, 1, SPDK_VIRTIO_DESC_WR);
|
||||
virtqueue_req_add_iovs(vq, &base->iov, payload_iov_cnt, SPDK_VIRTIO_DESC_WR);
|
||||
|
||||
virtqueue_req_flush(vq);
|
||||
return 0;
|
||||
@ -913,14 +914,12 @@ send_scan_io(struct virtio_scsi_scan_base *base)
|
||||
static int
|
||||
send_inquiry(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct iovec *iov = &base->iov;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct spdk_scsi_cdb_inquiry *cdb;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
|
||||
iov->iov_len = BDEV_VIRTIO_SCAN_PAYLOAD_SIZE;
|
||||
|
||||
base->iov.iov_len = BDEV_VIRTIO_SCAN_PAYLOAD_SIZE;
|
||||
cdb = (struct spdk_scsi_cdb_inquiry *)req->cdb;
|
||||
cdb->opcode = SPDK_SPC_INQUIRY;
|
||||
to_be16(cdb->alloc_len, BDEV_VIRTIO_SCAN_PAYLOAD_SIZE);
|
||||
@ -931,18 +930,17 @@ send_inquiry(struct virtio_scsi_scan_base *base)
|
||||
static void
|
||||
send_inquiry_vpd(struct virtio_scsi_scan_base *base, uint8_t page_code)
|
||||
{
|
||||
struct iovec *iov = &base->iov;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct spdk_scsi_cdb_inquiry *inquiry_cdb = (struct spdk_scsi_cdb_inquiry *)req->cdb;
|
||||
int rc;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
|
||||
iov[0].iov_len = BDEV_VIRTIO_SCAN_PAYLOAD_SIZE;
|
||||
base->iov.iov_len = BDEV_VIRTIO_SCAN_PAYLOAD_SIZE;
|
||||
inquiry_cdb->opcode = SPDK_SPC_INQUIRY;
|
||||
inquiry_cdb->evpd = 1;
|
||||
inquiry_cdb->page_code = page_code;
|
||||
to_be16(inquiry_cdb->alloc_len, iov[0].iov_len);
|
||||
to_be16(inquiry_cdb->alloc_len, base->iov.iov_len);
|
||||
|
||||
rc = send_scan_io(base);
|
||||
if (rc != 0) {
|
||||
@ -953,13 +951,12 @@ send_inquiry_vpd(struct virtio_scsi_scan_base *base, uint8_t page_code)
|
||||
static void
|
||||
send_read_cap_10(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct iovec *iov = &base->iov;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
int rc;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
|
||||
iov[0].iov_len = 8;
|
||||
base->iov.iov_len = 8;
|
||||
req->cdb[0] = SPDK_SBC_READ_CAPACITY_10;
|
||||
|
||||
rc = send_scan_io(base);
|
||||
@ -971,16 +968,15 @@ send_read_cap_10(struct virtio_scsi_scan_base *base)
|
||||
static void
|
||||
send_read_cap_16(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct iovec *iov = &base->iov;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
int rc;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
|
||||
iov[0].iov_len = 32;
|
||||
base->iov.iov_len = 32;
|
||||
req->cdb[0] = SPDK_SPC_SERVICE_ACTION_IN_16;
|
||||
req->cdb[1] = SPDK_SBC_SAI_READ_CAPACITY_16;
|
||||
to_be32(&req->cdb[10], iov[0].iov_len);
|
||||
to_be32(&req->cdb[10], base->iov.iov_len);
|
||||
|
||||
rc = send_scan_io(base);
|
||||
if (rc != 0) {
|
||||
@ -996,6 +992,7 @@ send_test_unit_ready(struct virtio_scsi_scan_base *base)
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
req->cdb[0] = SPDK_SPC_TEST_UNIT_READY;
|
||||
base->iov.iov_len = 0;
|
||||
|
||||
rc = send_scan_io(base);
|
||||
if (rc != 0) {
|
||||
@ -1012,6 +1009,7 @@ send_start_stop_unit(struct virtio_scsi_scan_base *base)
|
||||
memset(req, 0, sizeof(*req));
|
||||
req->cdb[0] = SPDK_SBC_START_STOP_UNIT;
|
||||
req->cdb[4] = SPDK_SBC_START_STOP_UNIT_START_BIT;
|
||||
base->iov.iov_len = 0;
|
||||
|
||||
rc = send_scan_io(base);
|
||||
if (rc != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user