bdev/virtio/scsi: extract virtio response error handling to common func
Virtio response codes other than OK, BAD_TARGET or INCORRECT_LUN indicate an intermittent device/transport failure and don't need to be handled by each message response handler separately. Change-Id: Iab0b03b3c7b377d2b346344c32e5df143df528b0 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/402119 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
72d72f503c
commit
def268e6a4
@ -1114,7 +1114,7 @@ process_scan_start_stop_unit(struct virtio_scsi_scan_base *base)
|
||||
{
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
if (resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
return send_inquiry_vpd(base, SPDK_SPC_VPD_SUPPORTED_VPD_PAGES);
|
||||
}
|
||||
|
||||
@ -1130,7 +1130,7 @@ process_scan_test_unit_ready(struct virtio_scsi_scan_base *base)
|
||||
get_scsi_status(resp, &sk, &asc, &ascq);
|
||||
|
||||
/* check response, get VPD if spun up otherwise send SSU */
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
if (resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
return send_inquiry_vpd(base, SPDK_SPC_VPD_SUPPORTED_VPD_PAGES);
|
||||
} else if (resp->response == VIRTIO_SCSI_S_OK &&
|
||||
resp->status == SPDK_SCSI_STATUS_CHECK_CONDITION &&
|
||||
@ -1149,7 +1149,7 @@ process_scan_inquiry_standard(struct virtio_scsi_scan_base *base)
|
||||
struct spdk_scsi_cdb_inquiry_data *inquiry_data =
|
||||
(struct spdk_scsi_cdb_inquiry_data *)base->payload;
|
||||
|
||||
if (resp->response != VIRTIO_SCSI_S_OK || resp->status != SPDK_SCSI_STATUS_GOOD) {
|
||||
if (resp->status != SPDK_SCSI_STATUS_GOOD) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1171,7 +1171,7 @@ process_scan_inquiry_vpd_supported_vpd_pages(struct virtio_scsi_scan_base *base)
|
||||
struct virtio_scsi_cmd_resp *resp = &base->io_ctx.resp;
|
||||
bool block_provisioning_page_supported = false;
|
||||
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
if (resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
const uint8_t *vpd_data = base->payload;
|
||||
const uint8_t *supported_vpd_pages = vpd_data + 4;
|
||||
uint16_t page_length;
|
||||
@ -1203,7 +1203,7 @@ process_scan_inquiry_vpd_block_thin_provision(struct virtio_scsi_scan_base *base
|
||||
|
||||
base->info.unmap_supported = false;
|
||||
|
||||
if (resp->response == VIRTIO_SCSI_S_OK && resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
if (resp->status == SPDK_SCSI_STATUS_GOOD) {
|
||||
uint8_t *vpd_data = base->payload;
|
||||
|
||||
base->info.unmap_supported = !!(vpd_data[5] & SPDK_SCSI_UNMAP_LBPU);
|
||||
@ -1376,9 +1376,15 @@ process_scan_resp(struct virtio_scsi_scan_base *base)
|
||||
get_scsi_status(resp, &sk, &asc, &ascq);
|
||||
target_id = req->lun[1];
|
||||
|
||||
if (resp->response == VIRTIO_SCSI_S_OK &&
|
||||
resp->status == SPDK_SCSI_STATUS_CHECK_CONDITION &&
|
||||
sk != SPDK_SCSI_SENSE_ILLEGAL_REQUEST) {
|
||||
if (resp->response == VIRTIO_SCSI_S_BAD_TARGET ||
|
||||
resp->response == VIRTIO_SCSI_S_INCORRECT_LUN) {
|
||||
_virtio_scsi_dev_scan_next(base);
|
||||
return;
|
||||
}
|
||||
|
||||
if (resp->response != VIRTIO_SCSI_S_OK ||
|
||||
(resp->status == SPDK_SCSI_STATUS_CHECK_CONDITION &&
|
||||
sk != SPDK_SCSI_SENSE_ILLEGAL_REQUEST)) {
|
||||
assert(base->retries > 0);
|
||||
base->retries--;
|
||||
if (base->retries == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user