bdev_virtio: set proper bdev_io status on I/O completion
Change-Id: I5d30ce273031b8025b2705c458eb4b1cc123dcb6 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/375576 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
d3828a23ec
commit
76bbfcbc44
@ -192,13 +192,42 @@ static const struct spdk_bdev_fn_table virtio_fn_table = {
|
||||
.get_io_channel = bdev_virtio_get_io_channel,
|
||||
};
|
||||
|
||||
static void
|
||||
get_scsi_status(struct virtio_scsi_cmd_resp *resp, int *sk, int *asc, int *ascq)
|
||||
{
|
||||
/* see spdk_scsi_task_build_sense_data() for sense data details */
|
||||
*sk = 0;
|
||||
*asc = 0;
|
||||
*ascq = 0;
|
||||
|
||||
if (resp->sense_len < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
*sk = resp->sense[2] & 0xf;
|
||||
|
||||
if (resp->sense_len < 13) {
|
||||
return;
|
||||
}
|
||||
|
||||
*asc = resp->sense[12];
|
||||
|
||||
if (resp->sense_len < 14) {
|
||||
return;
|
||||
}
|
||||
|
||||
*ascq = resp->sense[13];
|
||||
}
|
||||
|
||||
static void
|
||||
bdev_virtio_io_cpl(struct virtio_req *req)
|
||||
{
|
||||
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);
|
||||
int sk, asc, ascq;
|
||||
|
||||
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_SUCCESS);
|
||||
get_scsi_status(&io_ctx->resp, &sk, &asc, &ascq);
|
||||
spdk_bdev_io_complete_scsi_status(bdev_io, io_ctx->resp.status, sk, asc, ascq);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user