svn commit: r311417 - stable/10/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Thu Jan 5 11:36:53 UTC 2017
Author: mav
Date: Thu Jan 5 11:36:52 2017
New Revision: 311417
URL: https://svnweb.freebsd.org/changeset/base/311417
Log:
MFC r310285:
When reporting "Logical block address out of range" error, report the LBA
in sense data INFORMATION field.
Modified:
stable/10/sys/cam/ctl/ctl.c
stable/10/sys/cam/ctl/ctl_error.c
stable/10/sys/cam/ctl/ctl_error.h
stable/10/sys/cam/ctl/ctl_tpc.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cam/ctl/ctl.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl.c Thu Jan 5 11:36:08 2017 (r311416)
+++ stable/10/sys/cam/ctl/ctl.c Thu Jan 5 11:36:52 2017 (r311417)
@@ -5353,7 +5353,8 @@ ctl_sync_cache(struct ctl_scsiio *ctsio)
* to see an error for an out of range LBA.
*/
if ((starting_lba + block_count) > (lun->be_lun->maxlba + 1)) {
- ctl_set_lba_out_of_range(ctsio);
+ ctl_set_lba_out_of_range(ctsio,
+ MAX(starting_lba, lun->be_lun->maxlba + 1));
ctl_done((union ctl_io *)ctsio);
goto bailout;
}
@@ -5669,7 +5670,8 @@ ctl_write_same(struct ctl_scsiio *ctsio)
*/
if (((lba + num_blocks) > (lun->be_lun->maxlba + 1))
|| ((lba + num_blocks) < lba)) {
- ctl_set_lba_out_of_range(ctsio);
+ ctl_set_lba_out_of_range(ctsio,
+ MAX(lba, lun->be_lun->maxlba + 1));
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
@@ -5782,7 +5784,8 @@ ctl_unmap(struct ctl_scsiio *ctsio)
num_blocks = scsi_4btoul(range->length);
if (((lba + num_blocks) > (lun->be_lun->maxlba + 1))
|| ((lba + num_blocks) < lba)) {
- ctl_set_lba_out_of_range(ctsio);
+ ctl_set_lba_out_of_range(ctsio,
+ MAX(lba, lun->be_lun->maxlba + 1));
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
@@ -6986,7 +6989,7 @@ ctl_get_lba_status(struct ctl_scsiio *ct
alloc_len = scsi_4btoul(cdb->alloc_len);
if (lba > lun->be_lun->maxlba) {
- ctl_set_lba_out_of_range(ctsio);
+ ctl_set_lba_out_of_range(ctsio, lba);
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
@@ -8776,7 +8779,8 @@ ctl_read_write(struct ctl_scsiio *ctsio)
*/
if (((lba + num_blocks) > (lun->be_lun->maxlba + 1))
|| ((lba + num_blocks) < lba)) {
- ctl_set_lba_out_of_range(ctsio);
+ ctl_set_lba_out_of_range(ctsio,
+ MAX(lba, lun->be_lun->maxlba + 1));
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
@@ -8885,7 +8889,8 @@ ctl_cnw(struct ctl_scsiio *ctsio)
*/
if (((lba + num_blocks) > (lun->be_lun->maxlba + 1))
|| ((lba + num_blocks) < lba)) {
- ctl_set_lba_out_of_range(ctsio);
+ ctl_set_lba_out_of_range(ctsio,
+ MAX(lba, lun->be_lun->maxlba + 1));
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
@@ -8996,7 +9001,8 @@ ctl_verify(struct ctl_scsiio *ctsio)
*/
if (((lba + num_blocks) > (lun->be_lun->maxlba + 1))
|| ((lba + num_blocks) < lba)) {
- ctl_set_lba_out_of_range(ctsio);
+ ctl_set_lba_out_of_range(ctsio,
+ MAX(lba, lun->be_lun->maxlba + 1));
ctl_done((union ctl_io *)ctsio);
return (CTL_RETVAL_COMPLETE);
}
Modified: stable/10/sys/cam/ctl/ctl_error.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_error.c Thu Jan 5 11:36:08 2017 (r311416)
+++ stable/10/sys/cam/ctl/ctl_error.c Thu Jan 5 11:36:52 2017 (r311417)
@@ -181,8 +181,8 @@ ctl_sense_to_desc(struct scsi_sense_data
/*asc*/ sense_src->add_sense_code,
/*ascq*/ sense_src->add_sense_code_qual,
- /* Information Bytes */
- (scsi_4btoul(sense_src->info) != 0) ?
+ /* Information Bytes */
+ (sense_src->error_code & SSD_ERRCODE_VALID) ?
SSD_ELEM_INFO : SSD_ELEM_SKIP,
sizeof(sense_src->info),
sense_src->info,
@@ -727,14 +727,20 @@ ctl_set_aborted(struct ctl_scsiio *ctsio
}
void
-ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio)
+ctl_set_lba_out_of_range(struct ctl_scsiio *ctsio, uint64_t lba)
{
+ uint8_t info[8];
+
+ scsi_u64to8b(lba, info);
+
/* "Logical block address out of range" */
ctl_set_sense(ctsio,
/*current_error*/ 1,
/*sense_key*/ SSD_KEY_ILLEGAL_REQUEST,
/*asc*/ 0x21,
/*ascq*/ 0x00,
+ /*type*/ (lba != 0) ? SSD_ELEM_INFO : SSD_ELEM_SKIP,
+ /*size*/ sizeof(info), /*data*/ &info,
SSD_ELEM_NONE);
}
Modified: stable/10/sys/cam/ctl/ctl_error.h
==============================================================================
--- stable/10/sys/cam/ctl/ctl_error.h Thu Jan 5 11:36:08 2017 (r311416)
+++ stable/10/sys/cam/ctl/ctl_error.h Thu Jan 5 11:36:52 2017 (r311417)
@@ -76,7 +76,7 @@ void ctl_set_internal_failure(struct ctl
uint16_t retry_count);
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_lba_out_of_range(struct ctl_scsiio *ctsio, uint64_t lba);
void ctl_set_lun_stopped(struct ctl_scsiio *ctsio);
void ctl_set_lun_int_reqd(struct ctl_scsiio *ctsio);
void ctl_set_lun_ejected(struct ctl_scsiio *ctsio);
Modified: stable/10/sys/cam/ctl/ctl_tpc.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_tpc.c Thu Jan 5 11:36:08 2017 (r311416)
+++ stable/10/sys/cam/ctl/ctl_tpc.c Thu Jan 5 11:36:52 2017 (r311417)
@@ -1104,7 +1104,8 @@ tpc_ranges_length(struct scsi_range_desc
}
static int
-tpc_check_ranges_l(struct scsi_range_desc *range, int nrange, uint64_t maxlba)
+tpc_check_ranges_l(struct scsi_range_desc *range, int nrange, uint64_t maxlba,
+ uint64_t *lba)
{
uint64_t b1;
uint32_t l1;
@@ -1113,8 +1114,10 @@ tpc_check_ranges_l(struct scsi_range_des
for (i = 0; i < nrange; i++) {
b1 = scsi_8btou64(range[i].lba);
l1 = scsi_4btoul(range[i].length);
- if (b1 + l1 < b1 || b1 + l1 > maxlba + 1)
+ if (b1 + l1 < b1 || b1 + l1 > maxlba + 1) {
+ *lba = MAX(b1, maxlba + 1);
return (-1);
+ }
}
return (0);
}
@@ -1952,6 +1955,7 @@ ctl_populate_token(struct ctl_scsiio *ct
struct ctl_port *port;
struct tpc_list *list, *tlist;
struct tpc_token *token;
+ uint64_t lba;
int len, lendata, lendesc;
CTL_DEBUG_PRINT(("ctl_populate_token\n"));
@@ -2032,8 +2036,8 @@ ctl_populate_token(struct ctl_scsiio *ct
if (tpc_check_ranges_l(&data->desc[0],
scsi_2btoul(data->range_descriptor_length) /
sizeof(struct scsi_range_desc),
- lun->be_lun->maxlba) != 0) {
- ctl_set_lba_out_of_range(ctsio);
+ lun->be_lun->maxlba, &lba) != 0) {
+ ctl_set_lba_out_of_range(ctsio, lba);
goto done;
}
if (tpc_check_ranges_x(&data->desc[0],
@@ -2118,6 +2122,7 @@ ctl_write_using_token(struct ctl_scsiio
struct ctl_lun *lun;
struct tpc_list *list, *tlist;
struct tpc_token *token;
+ uint64_t lba;
int len, lendata, lendesc;
CTL_DEBUG_PRINT(("ctl_write_using_token\n"));
@@ -2180,8 +2185,8 @@ ctl_write_using_token(struct ctl_scsiio
if (tpc_check_ranges_l(&data->desc[0],
scsi_2btoul(data->range_descriptor_length) /
sizeof(struct scsi_range_desc),
- lun->be_lun->maxlba) != 0) {
- ctl_set_lba_out_of_range(ctsio);
+ lun->be_lun->maxlba, &lba) != 0) {
+ ctl_set_lba_out_of_range(ctsio, lba);
goto done;
}
if (tpc_check_ranges_x(&data->desc[0],
More information about the svn-src-stable
mailing list