diff options
author | mav <mav@FreeBSD.org> | 2015-10-05 09:26:52 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-10-05 09:26:52 +0000 |
commit | d3014f47f47534519cbb44457e428d58e7b2a407 (patch) | |
tree | e3ed1c020b489879dfbf643767cbc0b71ab65d05 /sys/cam | |
parent | c45abe20442cc1352a834efd7d05f664ce23c2d6 (diff) | |
download | FreeBSD-src-d3014f47f47534519cbb44457e428d58e7b2a407.zip FreeBSD-src-d3014f47f47534519cbb44457e428d58e7b2a407.tar.gz |
MFC r287912: Report proper medium error code for VERIFY commands.
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/ctl/ctl.c | 4 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_backend_block.c | 23 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_error.c | 4 | ||||
-rw-r--r-- | sys/cam/ctl/ctl_error.h | 2 |
4 files changed, 18 insertions, 15 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 01cdf33..82c9863 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -12048,7 +12048,9 @@ ctl_inject_error(struct ctl_lun *lun, union ctl_io *io) ctl_set_aborted(&io->scsiio); break; case CTL_LUN_INJ_MEDIUM_ERR: - ctl_set_medium_error(&io->scsiio); + ctl_set_medium_error(&io->scsiio, + (io->io_hdr.flags & CTL_FLAG_DATA_MASK) != + CTL_FLAG_DATA_OUT); break; case CTL_LUN_INJ_UA: /* 29h/00h POWER ON, RESET, OR BUS DEVICE RESET diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index aa794a6..140bdc8 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -545,8 +545,10 @@ ctl_be_block_biodone(struct bio *bio) ctl_set_internal_failure(&io->scsiio, /*sks_valid*/ 1, /*retry_count*/ 0xbad2); - } else - ctl_set_medium_error(&io->scsiio); + } else { + ctl_set_medium_error(&io->scsiio, + beio->bio_cmd == BIO_READ); + } ctl_complete_beio(beio); return; } @@ -761,17 +763,14 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, * return the I/O to the user. */ if (error != 0) { - char path_str[32]; - - ctl_scsi_path_string(io, path_str, sizeof(path_str)); - printf("%s%s command returned errno %d\n", path_str, - (beio->bio_cmd == BIO_READ) ? "READ" : "WRITE", error); if (error == ENOSPC || error == EDQUOT) { ctl_set_space_alloc_fail(&io->scsiio); } else if (error == EROFS || error == EACCES) { ctl_set_hw_write_protected(&io->scsiio); - } else - ctl_set_medium_error(&io->scsiio); + } else { + ctl_set_medium_error(&io->scsiio, + beio->bio_cmd == BIO_READ); + } ctl_complete_beio(beio); return; } @@ -937,8 +936,10 @@ ctl_be_block_dispatch_zvol(struct ctl_be_block_lun *be_lun, ctl_set_space_alloc_fail(&io->scsiio); } else if (error == EROFS || error == EACCES) { ctl_set_hw_write_protected(&io->scsiio); - } else - ctl_set_medium_error(&io->scsiio); + } else { + ctl_set_medium_error(&io->scsiio, + beio->bio_cmd == BIO_READ); + } ctl_complete_beio(beio); return; } diff --git a/sys/cam/ctl/ctl_error.c b/sys/cam/ctl/ctl_error.c index 4eec276..8e6fcdf 100644 --- a/sys/cam/ctl/ctl_error.c +++ b/sys/cam/ctl/ctl_error.c @@ -686,9 +686,9 @@ ctl_set_internal_failure(struct ctl_scsiio *ctsio, int sks_valid, } void -ctl_set_medium_error(struct ctl_scsiio *ctsio) +ctl_set_medium_error(struct ctl_scsiio *ctsio, int read) { - if ((ctsio->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) { + if (read) { /* "Unrecovered read error" */ ctl_set_sense(ctsio, /*current_error*/ 1, diff --git a/sys/cam/ctl/ctl_error.h b/sys/cam/ctl/ctl_error.h index 942def1..064f621 100644 --- a/sys/cam/ctl/ctl_error.h +++ b/sys/cam/ctl/ctl_error.h @@ -73,7 +73,7 @@ void ctl_set_lun_standby(struct ctl_scsiio *ctsio); void ctl_set_lun_unavail(struct ctl_scsiio *ctsio); void ctl_set_internal_failure(struct ctl_scsiio *ctsio, int sks_valid, uint16_t retry_count); -void ctl_set_medium_error(struct ctl_scsiio *ctsio); +void ctl_set_medium_error(struct ctl_scsiio *ctsio, int read); void ctl_set_aborted(struct ctl_scsiio *ctsio); void ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio); void ctl_set_lun_stopped(struct ctl_scsiio *ctsio); |