bdev/virtio: minimize virtio_req usages
The struct is about to be removed. This is a preliminary patch towards the removal. Change-Id: I5a479678790b8758634bdb0bb2e6facfde514aa1 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/391945 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
8d26e7e24a
commit
d2374e5e4c
@ -147,8 +147,7 @@ static void virtio_scsi_dev_unregister_cb(void *io_device);
|
||||
static void virtio_scsi_dev_remove(struct virtio_scsi_dev *svdev);
|
||||
static int bdev_virtio_scsi_ch_create_cb(void *io_device, void *ctx_buf);
|
||||
static void bdev_virtio_scsi_ch_destroy_cb(void *io_device, void *ctx_buf);
|
||||
static void process_scan_resp(struct virtio_scsi_scan_base *base,
|
||||
struct virtio_req *vreq);
|
||||
static void process_scan_resp(struct virtio_scsi_scan_base *base);
|
||||
static void bdev_virtio_ctrlq_poll(void *arg);
|
||||
|
||||
static int
|
||||
@ -291,7 +290,7 @@ virtio_dev_to_scsi(struct virtio_dev *vdev)
|
||||
return SPDK_CONTAINEROF(vdev, struct virtio_scsi_dev, vdev);
|
||||
}
|
||||
|
||||
static struct virtio_req *
|
||||
static struct virtio_scsi_io_ctx *
|
||||
bdev_virtio_init_io_vreq(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
struct virtio_req *vreq;
|
||||
@ -316,10 +315,10 @@ bdev_virtio_init_io_vreq(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i
|
||||
req->lun[0] = 1;
|
||||
req->lun[1] = disk->info.target;
|
||||
|
||||
return vreq;
|
||||
return io_ctx;
|
||||
}
|
||||
|
||||
static struct virtio_req *
|
||||
static struct virtio_scsi_io_ctx *
|
||||
bdev_virtio_init_tmf_vreq(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
struct virtio_req *vreq;
|
||||
@ -344,7 +343,7 @@ bdev_virtio_init_tmf_vreq(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_
|
||||
tmf_req->lun[0] = 1;
|
||||
tmf_req->lun[1] = disk->info.target;
|
||||
|
||||
return vreq;
|
||||
return io_ctx;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -369,8 +368,9 @@ static void
|
||||
bdev_virtio_rw(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
struct virtio_scsi_disk *disk = SPDK_CONTAINEROF(bdev_io->bdev, struct virtio_scsi_disk, bdev);
|
||||
struct virtio_req *vreq = bdev_virtio_init_io_vreq(ch, bdev_io);
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_io_ctx *io_ctx = bdev_virtio_init_io_vreq(ch, bdev_io);
|
||||
struct virtio_req *vreq = &io_ctx->vreq;
|
||||
struct virtio_scsi_cmd_req *req = &io_ctx->req;
|
||||
|
||||
vreq->iov = bdev_io->u.bdev.iovs;
|
||||
vreq->iovcnt = bdev_io->u.bdev.iovcnt;
|
||||
@ -392,8 +392,8 @@ static void
|
||||
bdev_virtio_reset(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
struct bdev_virtio_io_channel *virtio_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct virtio_req *vreq = bdev_virtio_init_tmf_vreq(ch, bdev_io);
|
||||
struct virtio_scsi_ctrl_tmf_req *tmf_req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_io_ctx *io_ctx = bdev_virtio_init_tmf_vreq(ch, bdev_io);
|
||||
struct virtio_scsi_ctrl_tmf_req *tmf_req = &io_ctx->tmf_req;
|
||||
struct virtio_dev *vdev = &virtio_ch->svdev->vdev;
|
||||
struct spdk_ring *ctrlq_send_ring = vdev->vqs[VIRTIO_SCSI_CONTROLQ]->poller_ctx;
|
||||
size_t enqueued_count;
|
||||
@ -401,7 +401,7 @@ bdev_virtio_reset(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
tmf_req->type = VIRTIO_SCSI_T_TMF;
|
||||
tmf_req->subtype = VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET;
|
||||
|
||||
enqueued_count = spdk_ring_enqueue(ctrlq_send_ring, (void **)&vreq, 1);
|
||||
enqueued_count = spdk_ring_enqueue(ctrlq_send_ring, (void **)&bdev_io, 1);
|
||||
if (spdk_likely(enqueued_count == 1)) {
|
||||
return;
|
||||
} else {
|
||||
@ -412,8 +412,9 @@ bdev_virtio_reset(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static void
|
||||
bdev_virtio_unmap(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
struct virtio_req *vreq = bdev_virtio_init_io_vreq(ch, bdev_io);
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_io_ctx *io_ctx = bdev_virtio_init_io_vreq(ch, bdev_io);
|
||||
struct virtio_req *vreq = &io_ctx->vreq;
|
||||
struct virtio_scsi_cmd_req *req = &io_ctx->req;
|
||||
struct spdk_scsi_unmap_bdesc *desc, *first_desc;
|
||||
uint8_t *buf;
|
||||
uint64_t offset_blocks, num_blocks;
|
||||
@ -613,7 +614,7 @@ bdev_virtio_poll(void *arg)
|
||||
for (i = 0; i < cnt; ++i) {
|
||||
if (spdk_unlikely(svdev->scan_ctx &&
|
||||
req[i] == &svdev->scan_ctx->io_ctx.vreq)) {
|
||||
process_scan_resp(svdev->scan_ctx, req[i]);
|
||||
process_scan_resp(svdev->scan_ctx);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -661,10 +662,8 @@ bdev_virtio_tmf_abort_ioerr_cb(void *ctx)
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_virtio_tmf_abort(struct virtio_req *req, int status)
|
||||
bdev_virtio_tmf_abort(struct spdk_bdev_io *bdev_io, int status)
|
||||
{
|
||||
struct virtio_scsi_io_ctx *io_ctx = SPDK_CONTAINEROF(req, struct virtio_scsi_io_ctx, vreq);
|
||||
struct spdk_bdev_io *bdev_io = spdk_bdev_io_from_ctx(io_ctx);
|
||||
spdk_thread_fn fn;
|
||||
|
||||
if (status == -ENOMEM) {
|
||||
@ -676,25 +675,34 @@ bdev_virtio_tmf_abort(struct virtio_req *req, int status)
|
||||
spdk_thread_send_msg(spdk_bdev_io_get_thread(bdev_io), fn, bdev_io);
|
||||
}
|
||||
|
||||
static int
|
||||
bdev_virtio_send_tmf_io(struct virtqueue *ctrlq, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
struct virtio_scsi_io_ctx *io_ctx = (struct virtio_scsi_io_ctx *)bdev_io->driver_ctx;
|
||||
struct virtio_req *vreq = &io_ctx->vreq;
|
||||
|
||||
return virtio_xmit_pkt(ctrlq, vreq);
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_virtio_ctrlq_poll(void *arg)
|
||||
{
|
||||
struct virtio_dev *vdev = arg;
|
||||
struct virtqueue *ctrlq = vdev->vqs[VIRTIO_SCSI_CONTROLQ];
|
||||
struct spdk_ring *send_ring = ctrlq->poller_ctx;
|
||||
struct virtio_req *req[16];
|
||||
void *req[16];
|
||||
uint16_t i, cnt;
|
||||
int rc;
|
||||
|
||||
cnt = spdk_ring_dequeue(send_ring, (void **)req, SPDK_COUNTOF(req));
|
||||
cnt = spdk_ring_dequeue(send_ring, req, SPDK_COUNTOF(req));
|
||||
for (i = 0; i < cnt; ++i) {
|
||||
rc = virtio_xmit_pkt(ctrlq, req[i]);
|
||||
rc = bdev_virtio_send_tmf_io(ctrlq, req[i]);
|
||||
if (rc != 0) {
|
||||
bdev_virtio_tmf_abort(req[i], rc);
|
||||
}
|
||||
}
|
||||
|
||||
cnt = virtio_recv_pkts(ctrlq, req, SPDK_COUNTOF(req));
|
||||
cnt = virtio_recv_pkts(ctrlq, (struct virtio_req **)req, SPDK_COUNTOF(req));
|
||||
for (i = 0; i < cnt; ++i) {
|
||||
bdev_virtio_tmf_cpl(req[i]);
|
||||
}
|
||||
@ -801,11 +809,10 @@ _virtio_scsi_dev_scan_finish(struct virtio_scsi_scan_base *base)
|
||||
}
|
||||
|
||||
static void
|
||||
send_inquiry_vpd(struct virtio_scsi_scan_base *base, uint8_t target_id, struct virtio_req *vreq,
|
||||
uint8_t page_code)
|
||||
send_inquiry_vpd(struct virtio_scsi_scan_base *base, uint8_t target_id, uint8_t page_code)
|
||||
{
|
||||
struct iovec *iov = vreq->iov;
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
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;
|
||||
|
||||
@ -819,17 +826,17 @@ send_inquiry_vpd(struct virtio_scsi_scan_base *base, uint8_t target_id, struct v
|
||||
inquiry_cdb->page_code = page_code;
|
||||
to_be16(inquiry_cdb->alloc_len, iov[0].iov_len);
|
||||
|
||||
rc = virtio_xmit_pkt(base->channel->vq, vreq);
|
||||
rc = virtio_xmit_pkt(base->channel->vq, &base->io_ctx.vreq);
|
||||
if (rc != 0) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
send_read_cap_10(struct virtio_scsi_scan_base *base, uint8_t target_id, struct virtio_req *vreq)
|
||||
send_read_cap_10(struct virtio_scsi_scan_base *base, uint8_t target_id)
|
||||
{
|
||||
struct iovec *iov = vreq->iov;
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct iovec *iov = &base->iov;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
int rc;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
@ -839,17 +846,17 @@ send_read_cap_10(struct virtio_scsi_scan_base *base, uint8_t target_id, struct v
|
||||
iov[0].iov_len = 8;
|
||||
req->cdb[0] = SPDK_SBC_READ_CAPACITY_10;
|
||||
|
||||
rc = virtio_xmit_pkt(base->channel->vq, vreq);
|
||||
rc = virtio_xmit_pkt(base->channel->vq, &base->io_ctx.vreq);
|
||||
if (rc != 0) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
send_read_cap_16(struct virtio_scsi_scan_base *base, uint8_t target_id, struct virtio_req *vreq)
|
||||
send_read_cap_16(struct virtio_scsi_scan_base *base, uint8_t target_id)
|
||||
{
|
||||
struct iovec *iov = vreq->iov;
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct iovec *iov = &base->iov;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
int rc;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
@ -861,16 +868,16 @@ send_read_cap_16(struct virtio_scsi_scan_base *base, uint8_t target_id, struct v
|
||||
req->cdb[1] = SPDK_SBC_SAI_READ_CAPACITY_16;
|
||||
to_be32(&req->cdb[10], iov[0].iov_len);
|
||||
|
||||
rc = virtio_xmit_pkt(base->channel->vq, vreq);
|
||||
rc = virtio_xmit_pkt(base->channel->vq, &base->io_ctx.vreq);
|
||||
if (rc != 0) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
send_test_unit_ready(struct virtio_scsi_scan_base *base, uint8_t target_id, struct virtio_req *vreq)
|
||||
send_test_unit_ready(struct virtio_scsi_scan_base *base, uint8_t target_id)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
int rc;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
@ -878,16 +885,16 @@ send_test_unit_ready(struct virtio_scsi_scan_base *base, uint8_t target_id, stru
|
||||
req->lun[1] = target_id;
|
||||
req->cdb[0] = SPDK_SPC_TEST_UNIT_READY;
|
||||
|
||||
rc = virtio_xmit_pkt(base->channel->vq, vreq);
|
||||
rc = virtio_xmit_pkt(base->channel->vq, &base->io_ctx.vreq);
|
||||
if (rc != 0) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
send_start_stop_unit(struct virtio_scsi_scan_base *base, uint8_t target_id, struct virtio_req *vreq)
|
||||
send_start_stop_unit(struct virtio_scsi_scan_base *base, uint8_t target_id)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
int rc;
|
||||
|
||||
memset(req, 0, sizeof(*req));
|
||||
@ -896,22 +903,22 @@ send_start_stop_unit(struct virtio_scsi_scan_base *base, uint8_t target_id, stru
|
||||
req->cdb[0] = SPDK_SBC_START_STOP_UNIT;
|
||||
req->cdb[4] = SPDK_SBC_START_STOP_UNIT_START_BIT;
|
||||
|
||||
rc = virtio_xmit_pkt(base->channel->vq, vreq);
|
||||
rc = virtio_xmit_pkt(base->channel->vq, &base->io_ctx.vreq);
|
||||
if (rc != 0) {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
process_scan_start_stop_unit(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
process_scan_start_stop_unit(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
uint8_t target_id = req->lun[1];
|
||||
int rc = 0;
|
||||
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
send_inquiry_vpd(base, target_id, vreq, SPDK_SPC_VPD_SUPPORTED_VPD_PAGES);
|
||||
send_inquiry_vpd(base, target_id, SPDK_SPC_VPD_SUPPORTED_VPD_PAGES);
|
||||
} else {
|
||||
rc = -1;
|
||||
}
|
||||
@ -920,10 +927,10 @@ process_scan_start_stop_unit(struct virtio_scsi_scan_base *base, struct virtio_r
|
||||
}
|
||||
|
||||
static int
|
||||
process_scan_test_unit_ready(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
process_scan_test_unit_ready(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
uint8_t target_id = req->lun[1];
|
||||
int sk, asc, ascq;
|
||||
int rc = 0;
|
||||
@ -932,12 +939,12 @@ process_scan_test_unit_ready(struct virtio_scsi_scan_base *base, struct virtio_r
|
||||
|
||||
/* check response, get VPD if spun up otherwise send SSU */
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
send_inquiry_vpd(base, target_id, vreq, SPDK_SPC_VPD_SUPPORTED_VPD_PAGES);
|
||||
send_inquiry_vpd(base, target_id, SPDK_SPC_VPD_SUPPORTED_VPD_PAGES);
|
||||
} else if (resp->response == VIRTIO_SCSI_S_OK &&
|
||||
resp->status == SPDK_SCSI_STATUS_CHECK_CONDITION &&
|
||||
sk == SPDK_SCSI_SENSE_UNIT_ATTENTION &&
|
||||
asc == SPDK_SCSI_ASC_LOGICAL_UNIT_NOT_READY) {
|
||||
send_start_stop_unit(base, target_id, vreq);
|
||||
send_start_stop_unit(base, target_id);
|
||||
} else {
|
||||
rc = -1;
|
||||
}
|
||||
@ -946,11 +953,12 @@ process_scan_test_unit_ready(struct virtio_scsi_scan_base *base, struct virtio_r
|
||||
}
|
||||
|
||||
static int
|
||||
process_scan_inquiry_standard(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
process_scan_inquiry_standard(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct spdk_scsi_cdb_inquiry_data *inquiry_data = vreq->iov[0].iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
struct spdk_scsi_cdb_inquiry_data *inquiry_data =
|
||||
(struct spdk_scsi_cdb_inquiry_data *)base->payload;
|
||||
uint8_t target_id = req->lun[1];
|
||||
|
||||
if (resp->response != VIRTIO_SCSI_S_OK || resp->status != SPDK_SCSI_STATUS_GOOD) {
|
||||
@ -966,28 +974,27 @@ process_scan_inquiry_standard(struct virtio_scsi_scan_base *base, struct virtio_
|
||||
return -1;
|
||||
}
|
||||
|
||||
send_test_unit_ready(base, target_id, vreq);
|
||||
send_test_unit_ready(base, target_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
process_scan_inquiry_vpd_supported_vpd_pages(struct virtio_scsi_scan_base *base,
|
||||
struct virtio_req *vreq)
|
||||
process_scan_inquiry_vpd_supported_vpd_pages(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
uint8_t target_id;
|
||||
bool block_provisioning_page_supported = false;
|
||||
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
const uint8_t *vpd_data = vreq->iov[0].iov_base;
|
||||
const uint8_t *vpd_data = base->payload;
|
||||
const uint8_t *supported_vpd_pages = vpd_data + 4;
|
||||
uint16_t page_length;
|
||||
uint16_t num_supported_pages;
|
||||
uint16_t i;
|
||||
|
||||
page_length = from_be16(vpd_data + 2);
|
||||
num_supported_pages = spdk_min(page_length, vreq->iov[0].iov_len - 4);
|
||||
num_supported_pages = spdk_min(page_length, base->io_ctx.vreq.iov->iov_len - 4);
|
||||
|
||||
for (i = 0; i < num_supported_pages; i++) {
|
||||
if (supported_vpd_pages[i] == SPDK_SPC_VPD_BLOCK_THIN_PROVISION) {
|
||||
@ -999,25 +1006,24 @@ process_scan_inquiry_vpd_supported_vpd_pages(struct virtio_scsi_scan_base *base,
|
||||
|
||||
target_id = req->lun[1];
|
||||
if (block_provisioning_page_supported) {
|
||||
send_inquiry_vpd(base, target_id, vreq, SPDK_SPC_VPD_BLOCK_THIN_PROVISION);
|
||||
send_inquiry_vpd(base, target_id, SPDK_SPC_VPD_BLOCK_THIN_PROVISION);
|
||||
} else {
|
||||
send_read_cap_10(base, target_id, vreq);
|
||||
send_read_cap_10(base, target_id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
process_scan_inquiry_vpd_block_thin_provision(struct virtio_scsi_scan_base *base,
|
||||
struct virtio_req *vreq)
|
||||
process_scan_inquiry_vpd_block_thin_provision(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
uint8_t target_id;
|
||||
|
||||
base->info.unmap_supported = false;
|
||||
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
uint8_t *vpd_data = vreq->iov[0].iov_base;
|
||||
uint8_t *vpd_data = base->payload;
|
||||
|
||||
base->info.unmap_supported = !!(vpd_data[5] & SPDK_SCSI_UNMAP_LBPU);
|
||||
}
|
||||
@ -1026,25 +1032,25 @@ process_scan_inquiry_vpd_block_thin_provision(struct virtio_scsi_scan_base *base
|
||||
base->info.target, (int)base->info.unmap_supported);
|
||||
|
||||
target_id = req->lun[1];
|
||||
send_read_cap_10(base, target_id, vreq);
|
||||
send_read_cap_10(base, target_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
process_scan_inquiry(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
process_scan_inquiry(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct spdk_scsi_cdb_inquiry *inquiry_cdb = (struct spdk_scsi_cdb_inquiry *)req->cdb;
|
||||
|
||||
if ((inquiry_cdb->evpd & 1) == 0) {
|
||||
return process_scan_inquiry_standard(base, vreq);
|
||||
return process_scan_inquiry_standard(base);
|
||||
}
|
||||
|
||||
switch (inquiry_cdb->page_code) {
|
||||
case SPDK_SPC_VPD_SUPPORTED_VPD_PAGES:
|
||||
return process_scan_inquiry_vpd_supported_vpd_pages(base, vreq);
|
||||
return process_scan_inquiry_vpd_supported_vpd_pages(base);
|
||||
case SPDK_SPC_VPD_BLOCK_THIN_PROVISION:
|
||||
return process_scan_inquiry_vpd_block_thin_provision(base, vreq);
|
||||
return process_scan_inquiry_vpd_block_thin_provision(base);
|
||||
default:
|
||||
SPDK_DEBUGLOG(SPDK_LOG_VIRTIO, "Unexpected VPD page 0x%02x\n", inquiry_cdb->page_code);
|
||||
return -1;
|
||||
@ -1089,10 +1095,10 @@ alloc_virtio_disk(struct virtio_scsi_scan_base *base)
|
||||
}
|
||||
|
||||
static int
|
||||
process_read_cap_10(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
process_read_cap_10(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
uint64_t max_block;
|
||||
uint32_t block_size;
|
||||
uint8_t target_id = req->lun[1];
|
||||
@ -1102,11 +1108,11 @@ process_read_cap_10(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
return -1;
|
||||
}
|
||||
|
||||
block_size = from_be32((uint8_t *)vreq->iov[0].iov_base + 4);
|
||||
max_block = from_be32(vreq->iov[0].iov_base);
|
||||
block_size = from_be32(base->payload + 4);
|
||||
max_block = from_be32(base->payload);
|
||||
|
||||
if (max_block == 0xffffffff) {
|
||||
send_read_cap_16(base, target_id, vreq);
|
||||
send_read_cap_16(base, target_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1117,10 +1123,10 @@ process_read_cap_10(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
}
|
||||
|
||||
static int
|
||||
process_read_cap_16(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
process_read_cap_16(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
uint8_t target_id = req->lun[1];
|
||||
|
||||
if (resp->response != VIRTIO_SCSI_S_OK || resp->status != SPDK_SCSI_STATUS_GOOD) {
|
||||
@ -1128,21 +1134,21 @@ process_read_cap_16(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
return -1;
|
||||
}
|
||||
|
||||
base->info.num_blocks = from_be64((uint64_t *)(vreq->iov[0].iov_base)) + 1;
|
||||
base->info.block_size = from_be32((uint32_t *)(vreq->iov[0].iov_base + 8));
|
||||
base->info.num_blocks = from_be64(base->payload) + 1;
|
||||
base->info.block_size = from_be32(base->payload + 8);
|
||||
return alloc_virtio_disk(base);
|
||||
}
|
||||
|
||||
static void
|
||||
process_scan_resp(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
process_scan_resp(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_req *req = vreq->iov_req.iov_base;
|
||||
struct virtio_scsi_cmd_resp *resp = vreq->iov_resp.iov_base;
|
||||
struct virtio_scsi_cmd_req *req = &base->io_ctx.req;
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
int rc, sk, asc, ascq;
|
||||
uint8_t target_id;
|
||||
|
||||
if (vreq->iov_req.iov_len < sizeof(struct virtio_scsi_cmd_req) ||
|
||||
vreq->iov_resp.iov_len < sizeof(struct virtio_scsi_cmd_resp)) {
|
||||
if (base->io_ctx.vreq.iov_req.iov_len < sizeof(struct virtio_scsi_cmd_req) ||
|
||||
base->io_ctx.vreq.iov_resp.iov_len < sizeof(struct virtio_scsi_cmd_resp)) {
|
||||
SPDK_ERRLOG("Received target scan message with invalid length.\n");
|
||||
_virtio_scsi_dev_scan_finish(base);
|
||||
return;
|
||||
@ -1165,7 +1171,7 @@ process_scan_resp(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
}
|
||||
|
||||
/* resend the same request */
|
||||
rc = virtio_xmit_pkt(base->channel->vq, vreq);
|
||||
rc = virtio_xmit_pkt(base->channel->vq, &base->io_ctx.vreq);
|
||||
if (rc != 0) {
|
||||
assert(false);
|
||||
}
|
||||
@ -1176,19 +1182,19 @@ process_scan_resp(struct virtio_scsi_scan_base *base, struct virtio_req *vreq)
|
||||
|
||||
switch (req->cdb[0]) {
|
||||
case SPDK_SPC_INQUIRY:
|
||||
rc = process_scan_inquiry(base, vreq);
|
||||
rc = process_scan_inquiry(base);
|
||||
break;
|
||||
case SPDK_SPC_TEST_UNIT_READY:
|
||||
rc = process_scan_test_unit_ready(base, vreq);
|
||||
rc = process_scan_test_unit_ready(base);
|
||||
break;
|
||||
case SPDK_SBC_START_STOP_UNIT:
|
||||
rc = process_scan_start_stop_unit(base, vreq);
|
||||
rc = process_scan_start_stop_unit(base);
|
||||
break;
|
||||
case SPDK_SBC_READ_CAPACITY_10:
|
||||
rc = process_read_cap_10(base, vreq);
|
||||
rc = process_read_cap_10(base);
|
||||
break;
|
||||
case SPDK_SPC_SERVICE_ACTION_IN_16:
|
||||
rc = process_read_cap_16(base, vreq);
|
||||
rc = process_read_cap_16(base);
|
||||
break;
|
||||
default:
|
||||
SPDK_ERRLOG("Received invalid target scan message: cdb[0] = %"PRIu8".\n", req->cdb[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user