Use defined 16-bits ASC/ASCQ combinations
Damien Le Moal
maintainerv2 cover Use defined 16-bits ASC/ASCQ combinations
Martin, James,
This patch series defines as macros all ASC/ASCQ combinations present in
https://www.t10.org/lists/asc-num.txt and converts the SCSI core code and SCSI low level drivers to use these macros instead of hard-coded ASC/ASCQs. To do this, struct scsi_sense_hdr and struct scsi_failure are modified to replace the asc and ascq 8-bits fields with a 16-bits sense_code field.
This cleans up the code in many places and makes it easier, and self documented, to test sense codes in the case of errors.
Overall, there should be no functional chnages here.
Changes from v1:
- Addressed Sashiko comments signaling missing "ASC_" prefix when using the named macros for ASC codes.
- Fixed up patch 7 to correct trace event print of asc/ascq. Also extended the use of scsi_set_sense() in place of scsi_build_sense().
- Modified patch 37 to extend the use of scsi_set_sense_buffer() in place of scsi_build_sense_buffer().
- Added patch 34 and 38 to extend the use of scsi_set_sense() in place of scsi_build_sense().
- Added patch 40 to remove scsi_build_sense() and scsi_build_sense_buffer().
Damien Le Moal (40):
scsi: define all additional sense codes and their qualifiers
scsi: constants: use defined sense codes
scsi: constants: rename internal struct field names
scsi: rename sense field of struct scsi_failure
scsi: prepare for using 16-bits defined sense codes
scsi: use struct scsi_sense_hdr to log sense keys and codes
scsi: core: use 16-bits defined sense codes
scsi: sd: use 16-bits defined sense codes
scsi: sr: use 16-bits defined sense codes
scsi: ses: use 16-bits defined sense codes
scsi: ch: use 16-bits defined sense codes
scsi: st: use 16-bits defined sense codes
scsi: device_handlers: hp_sw: use 16-bits defined sense codes
scsi: device_handlers: rdac: use 16-bits defined sense codes
scsi: device_handlers: emc: use 16-bits defined sense codes
scsi: device_handlers: alua: use 16-bits defined sense codes
scsi: mpt3sas: use 16-bits defined sense codes
scsi: mpi3mr: use 16-bits defined sense codes
scsi: 3w-xxxx: use 16-bits defined sense codes
scsi: leapraid: use 16-bits defined sense codes
scsi: megaraid: use 16-bits defined sense codes
scsi: myrX: use 16-bits defined sense codes
scsi: smartpqi: use 16-bits defined sense codes
scsi: qla2xxx: use 16-bits defined sense codes
scsi: ps3rom: use 16-bits defined sense codes
scsi: lpfc: use 16-bits defined sense codes
scsi: stex: use 16-bits defined sense codes
scsi: mvumi: use 16-bits defined sense codes
scsi: libiscsi: use 16-bits defined sense codes
scsi: ibmvscsi_tgt: use 16-bits defined sense codes
scsi: scsi_debug: use 16-bits defined sense codes
scsi: hpsa: use 16-bits defined sense codes
scsi: storvsc: use 16-bits defined sense codes
target: use 16-bits defined sense codes
usb: storage: use 16-bits defined sense codes
cdrom: use 16-bits defined sense codes
ata: libata: use 16-bits defined sense codes
s390: scsi: use 16-bits defined sense codes
scsi: cleanup scsi_proto.h
scsi: remove scsi_build_sense() and scsi_build_sense_buffer()
drivers/ata/libata-eh.c | 13 +- drivers/ata/libata-sata.c | 20 +- drivers/ata/libata-scsi.c | 346 ++- drivers/ata/libata.h | 5 +- drivers/cdrom/cdrom.c | 10 +- drivers/s390/scsi/zfcp_scsi.c | 3 +- drivers/scsi/3w-xxxx.c | 3 +- drivers/scsi/ch.c | 55 +- drivers/scsi/constants.c | 61 +- drivers/scsi/device_handler/scsi_dh_alua.c | 55 +- drivers/scsi/device_handler/scsi_dh_emc.c | 28 +- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 29 +- drivers/scsi/device_handler/scsi_dh_rdac.c | 55 +- drivers/scsi/hpsa.c | 69 +- drivers/scsi/hpsa_cmd.h | 23 - drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 +- drivers/scsi/leapraid/leapraid_func.h | 7 - drivers/scsi/leapraid/leapraid_os.c | 15 +- drivers/scsi/libiscsi.c | 3 +- drivers/scsi/lpfc/lpfc_scsi.c | 18 +- drivers/scsi/megaraid.c | 8 +- drivers/scsi/megaraid/mega_common.h | 2 - drivers/scsi/megaraid/megaraid_mbox.c | 12 +- drivers/scsi/mpi3mr/mpi3mr_fw.c | 3 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 50 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 69 +- drivers/scsi/mvumi.c | 2 +- drivers/scsi/myrb.c | 67 +- drivers/scsi/myrs.c | 23 +- drivers/scsi/ps3rom.c | 5 +- drivers/scsi/qla2xxx/qla_isr.c | 9 +- drivers/scsi/scsi.c | 3 +- drivers/scsi/scsi_common.c | 24 +- drivers/scsi/scsi_debug.c | 332 +-- drivers/scsi/scsi_error.c | 94 +- drivers/scsi/scsi_ioctl.c | 3 +- drivers/scsi/scsi_lib.c | 130 +- drivers/scsi/scsi_lib_test.c | 96 +- drivers/scsi/scsi_logging.c | 22 +- drivers/scsi/scsi_scan.c | 22 +- drivers/scsi/scsi_transport_spi.c | 12 +- drivers/scsi/sd.c | 126 +- drivers/scsi/sd_zbc.c | 2 +- drivers/scsi/sense_codes.h | 2496 ++++++++++++------ drivers/scsi/ses.c | 23 +- drivers/scsi/smartpqi/smartpqi_init.c | 31 +- drivers/scsi/sr.c | 3 +- drivers/scsi/sr_ioctl.c | 29 +- drivers/scsi/st.c | 35 +- drivers/scsi/stex.c | 3 +- drivers/scsi/storvsc_drv.c | 15 +- drivers/target/target_core_spc.c | 11 +- drivers/target/target_core_transport.c | 11 +- drivers/target/target_core_ua.c | 28 +- drivers/target/target_core_ua.h | 7 +- drivers/usb/gadget/function/f_mass_storage.c | 34 +- drivers/usb/gadget/function/storage_common.h | 71 +- drivers/usb/storage/debug.c | 12 +- drivers/usb/storage/debug.h | 4 +- drivers/usb/storage/transport.c | 7 +- include/scsi/scsi_cmnd.h | 3 +- include/scsi/scsi_common.h | 16 +- include/scsi/scsi_dbg.h | 6 +- include/scsi/scsi_device.h | 26 +- include/scsi/scsi_proto.h | 71 +- include/scsi/scsi_sense.h | 943 +++++++ include/trace/events/scsi.h | 4 +- 67 files changed, 3821 insertions(+), 2007 deletions(-) create mode 100644 include/scsi/scsi_sense.h
Signature · 1 line
2.55.0
Damien Le Moal
maintainerPATCH v2 1/40 scsi: define all additional sense codes and their qualifiers
Introduce the file include/scsi/scsi_sense.h to define all existing additional sense codes and their combinations with additional sense code qualifiers, according to the most current T10 list available at
https://www.t10.org/lists/asc-num.txt.
Additional sense codes (ASCs) are individually defined as an 8-bit value with the ASC_ name prefix. The combination of all ASCs with T10 defined possible non-zero code qualifiers are defined as 16-bits values. The 16-bits value for ASCs with a zero ASCQ are defined together with the ASC 8-code using the ASC() macro.
The sense key macro definitions in include/scsi/scsi_proto.h are also moved into this new file and scsi_sense.h is included in scsi_proto.h. The helper function scsi_sense_code() is defined to facilitate generating a 16-bits sense code from 8-bits ASC and ASCQ. The accessors scsi_sense_code_asc() and scsi_sense_code_ascq() are defined for the reverse operation, that is, to respectively extract an ASC and an ASCQ from a 16-bits sense code.
--- include/scsi/scsi_proto.h | 20 +- include/scsi/scsi_sense.h | 943 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 944 insertions(+), 19 deletions(-) create mode 100644 include/scsi/scsi_sense.h
include/scsi/scsi_proto.h +1 -19
@@ -12,6 +12,7 @@#include <linux/build_bug.h> #include <linux/types.h> +#include <scsi/scsi_sense.h> /* * SCSI opcodes
@@ -218,25 +219,6 @@ enum sam_status {#define STATUS_MASK 0xfe -/* -* SENSE KEYS -*/ -#define NO_SENSE 0x00 -#define RECOVERED_ERROR 0x01 -#define NOT_READY 0x02 -#define MEDIUM_ERROR 0x03 -#define HARDWARE_ERROR 0x04 -#define ILLEGAL_REQUEST 0x05 -#define UNIT_ATTENTION 0x06 -#define DATA_PROTECT 0x07 -#define BLANK_CHECK 0x08 -#define VENDOR_SPECIFIC 0x09 -#define COPY_ABORTED 0x0a -#define ABORTED_COMMAND 0x0b -#define VOLUME_OVERFLOW 0x0d -#define MISCOMPARE 0x0e -#define COMPLETED 0x0f -/* * Additional Sense Codes (ASC). */
include/scsi/scsi_sense.h new file +943 -0
943 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 01/40] scsi: define all additional sense codes and their qualifiers
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 lines
Introduce the file
include/scsi/scsi_sense.hto define all existing additional sense codes and their combinations with additional sense code qualifiers, according to the most current T10 list available at
https://www.t10.org/lists/asc-num.txt.Additional sense codes (ASCs) are individually defined as an 8-bit value with the
ASC_name prefix. The combination of all ASCs with T10 defined possible non-zero code qualifiers are defined as 16-bits values. The 16-bits value for ASCs with a zero ASCQ are defined together with the ASC 8-code using theASC()macro.The sense key macro definitions in
include/scsi/scsi_proto.hare also moved into this new file andscsi_sense.his included inscsi_proto.h. The helper functionscsi_sense_code()is defined to facilitate generating a 16-bits sense code from 8-bits ASC and ASCQ. The accessorsscsi_sense_code_asc()andscsi_sense_code_ascq()are defined for the reverse operation, that is, to respectively extract an ASC and an ASCQ from a 16-bits sense code.
Quoted 1 line
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2 01/40] scsi: define all additional sense codes and their qualifiers
In reply to Damien Le MoalLooks good (I think)
Re: [PATCH v2 01/40] scsi: define all additional sense codes and their qualifiers
In reply to Damien Le MoalQuoted 19 lines · Damien Le Moal
Introduce the file
include/scsi/scsi_sense.hto define all existing additional sense codes and their combinations with additional sense code qualifiers, according to the most current T10 list available at
https://www.t10.org/lists/asc-num.txt.Additional sense codes (ASCs) are individually defined as an 8-bit value with the
ASC_name prefix. The combination of all ASCs with T10 defined possible non-zero code qualifiers are defined as 16-bits values. The 16-bits value for ASCs with a zero ASCQ are defined together with the ASC 8-code using theASC()macro.The sense key macro definitions in
include/scsi/scsi_proto.hare also moved into this new file andscsi_sense.his included inscsi_proto.h. The helper functionscsi_sense_code()is defined to facilitate generating a 16-bits sense code from 8-bits ASC and ASCQ. The accessorsscsi_sense_code_asc()andscsi_sense_code_ascq()are defined for the reverse operation, that is, to respectively extract an ASC and an ASCQ from a 16-bits sense code.
Quoted 7 lines
Signed-off-by Damien Le Moal <[email protected]>--- include/scsi/scsi_proto.h | 20 +- include/scsi/scsi_sense.h | 943 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 944 insertions(+), 19 deletions(-)create mode 100644
include/scsi/scsi_sense.h
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 2/40 scsi: constants: use defined sense codes
In reply to Damien Le MoalThe SENSE_CODE() macro is used for defining the array of struct error_info which associates a string description to an additional sense code and its combinations with additional sense code qualifiers. These are however hardcoded values.
Now that all 16-bits sense codes are defined as macros in include/scsi/scsi_sense.h, modify sense_codes.h to use the defined sense code macros. While doing this, 2 missing entries are added for the codes OVERLAPPING_ATOMIC_COMMAND_IN_PROGRESS and DEPOPULATION_RESTORATION_INTERRUPTED.
--- drivers/scsi/sense_codes.h | 2496 +++++++++++++++++++++++------------- 1 file changed, 1631 insertions(+), 865 deletions(-)
drivers/scsi/sense_codes.h +1631 -865
@@ -4,876 +4,1642 @@* http://www.t10.org/lists/asc-num.txt [most recent: 20200817] */ -SENSE_CODE(0x0000, "No additional sense information") -SENSE_CODE(0x0001, "Filemark detected") -SENSE_CODE(0x0002, "End-of-partition/medium detected") -SENSE_CODE(0x0003, "Setmark detected") -SENSE_CODE(0x0004, "Beginning-of-partition/medium detected") -SENSE_CODE(0x0005, "End-of-data detected") -SENSE_CODE(0x0006, "I/O process terminated") -SENSE_CODE(0x0007, "Programmable early warning detected") -SENSE_CODE(0x0011, "Audio play operation in progress") -SENSE_CODE(0x0012, "Audio play operation paused") -SENSE_CODE(0x0013, "Audio play operation successfully completed") -SENSE_CODE(0x0014, "Audio play operation stopped due to error") -SENSE_CODE(0x0015, "No current audio status to return") -SENSE_CODE(0x0016, "Operation in progress") -SENSE_CODE(0x0017, "Cleaning requested") -SENSE_CODE(0x0018, "Erase operation in progress") -SENSE_CODE(0x0019, "Locate operation in progress") -SENSE_CODE(0x001A, "Rewind operation in progress") -SENSE_CODE(0x001B, "Set capacity operation in progress") -SENSE_CODE(0x001C, "Verify operation in progress") -SENSE_CODE(0x001D, "ATA pass through information available") -SENSE_CODE(0x001E, "Conflicting SA creation request") -SENSE_CODE(0x001F, "Logical unit transitioning to another power condition") -SENSE_CODE(0x0020, "Extended copy information available") -SENSE_CODE(0x0021, "Atomic command aborted due to ACA") -SENSE_CODE(0x0022, "Deferred microcode is pending") - -SENSE_CODE(0x0100, "No index/sector signal") - -SENSE_CODE(0x0200, "No seek complete") - -SENSE_CODE(0x0300, "Peripheral device write fault") -SENSE_CODE(0x0301, "No write current") -SENSE_CODE(0x0302, "Excessive write errors") - -SENSE_CODE(0x0400, "Logical unit not ready, cause not reportable") -SENSE_CODE(0x0401, "Logical unit is in process of becoming ready") -SENSE_CODE(0x0402, "Logical unit not ready, initializing command required") -SENSE_CODE(0x0403, "Logical unit not ready, manual intervention required") -SENSE_CODE(0x0404, "Logical unit not ready, format in progress") -SENSE_CODE(0x0405, "Logical unit not ready, rebuild in progress") -SENSE_CODE(0x0406, "Logical unit not ready, recalculation in progress") -SENSE_CODE(0x0407, "Logical unit not ready, operation in progress") -SENSE_CODE(0x0408, "Logical unit not ready, long write in progress") -SENSE_CODE(0x0409, "Logical unit not ready, self-test in progress") -SENSE_CODE(0x040A, "Logical unit not accessible, asymmetric access state transition") -SENSE_CODE(0x040B, "Logical unit not accessible, target port in standby state") -SENSE_CODE(0x040C, "Logical unit not accessible, target port in unavailable state") -SENSE_CODE(0x040D, "Logical unit not ready, structure check required") -SENSE_CODE(0x040E, "Logical unit not ready, security session in progress") -SENSE_CODE(0x0410, "Logical unit not ready, auxiliary memory not accessible") -SENSE_CODE(0x0411, "Logical unit not ready, notify (enable spinup) required") -SENSE_CODE(0x0412, "Logical unit not ready, offline") -SENSE_CODE(0x0413, "Logical unit not ready, SA creation in progress") -SENSE_CODE(0x0414, "Logical unit not ready, space allocation in progress") -SENSE_CODE(0x0415, "Logical unit not ready, robotics disabled") -SENSE_CODE(0x0416, "Logical unit not ready, configuration required") -SENSE_CODE(0x0417, "Logical unit not ready, calibration required") -SENSE_CODE(0x0418, "Logical unit not ready, a door is open") -SENSE_CODE(0x0419, "Logical unit not ready, operating in sequential mode") -SENSE_CODE(0x041A, "Logical unit not ready, start stop unit command in progress") -SENSE_CODE(0x041B, "Logical unit not ready, sanitize in progress") -SENSE_CODE(0x041C, "Logical unit not ready, additional power use not yet granted") -SENSE_CODE(0x041D, "Logical unit not ready, configuration in progress") -SENSE_CODE(0x041E, "Logical unit not ready, microcode activation required") -SENSE_CODE(0x041F, "Logical unit not ready, microcode download required") -SENSE_CODE(0x0420, "Logical unit not ready, logical unit reset required") -SENSE_CODE(0x0421, "Logical unit not ready, hard reset required") -SENSE_CODE(0x0422, "Logical unit not ready, power cycle required") -SENSE_CODE(0x0423, "Logical unit not ready, affiliation required") -SENSE_CODE(0x0424, "Depopulation in progress") -SENSE_CODE(0x0425, "Depopulation restoration in progress") - -SENSE_CODE(0x0500, "Logical unit does not respond to selection") - -SENSE_CODE(0x0600, "No reference position found") - -SENSE_CODE(0x0700, "Multiple peripheral devices selected") - -SENSE_CODE(0x0800, "Logical unit communication failure") -SENSE_CODE(0x0801, "Logical unit communication time-out") -SENSE_CODE(0x0802, "Logical unit communication parity error") -SENSE_CODE(0x0803, "Logical unit communication CRC error (Ultra-DMA/32)") -SENSE_CODE(0x0804, "Unreachable copy target") - -SENSE_CODE(0x0900, "Track following error") -SENSE_CODE(0x0901, "Tracking servo failure") -SENSE_CODE(0x0902, "Focus servo failure") -SENSE_CODE(0x0903, "Spindle servo failure") -SENSE_CODE(0x0904, "Head select fault") -SENSE_CODE(0x0905, "Vibration induced tracking error") - -SENSE_CODE(0x0A00, "Error log overflow") - -SENSE_CODE(0x0B00, "Warning") -SENSE_CODE(0x0B01, "Warning - specified temperature exceeded") -SENSE_CODE(0x0B02, "Warning - enclosure degraded") -SENSE_CODE(0x0B03, "Warning - background self-test failed") -SENSE_CODE(0x0B04, "Warning - background pre-scan detected medium error") -SENSE_CODE(0x0B05, "Warning - background medium scan detected medium error") -SENSE_CODE(0x0B06, "Warning - non-volatile cache now volatile") -SENSE_CODE(0x0B07, "Warning - degraded power to non-volatile cache") -SENSE_CODE(0x0B08, "Warning - power loss expected") -SENSE_CODE(0x0B09, "Warning - device statistics notification active") -SENSE_CODE(0x0B0A, "Warning - high critical temperature limit exceeded") -SENSE_CODE(0x0B0B, "Warning - low critical temperature limit exceeded") -SENSE_CODE(0x0B0C, "Warning - high operating temperature limit exceeded") -SENSE_CODE(0x0B0D, "Warning - low operating temperature limit exceeded") -SENSE_CODE(0x0B0E, "Warning - high critical humidity limit exceeded") -SENSE_CODE(0x0B0F, "Warning - low critical humidity limit exceeded") -SENSE_CODE(0x0B10, "Warning - high operating humidity limit exceeded") -SENSE_CODE(0x0B11, "Warning - low operating humidity limit exceeded") -SENSE_CODE(0x0B12, "Warning - microcode security at risk") -SENSE_CODE(0x0B13, "Warning - microcode digital signature validation failure") -SENSE_CODE(0x0B14, "Warning - physical element status change") - -SENSE_CODE(0x0C00, "Write error") -SENSE_CODE(0x0C01, "Write error - recovered with auto reallocation") -SENSE_CODE(0x0C02, "Write error - auto reallocation failed") -SENSE_CODE(0x0C03, "Write error - recommend reassignment") -SENSE_CODE(0x0C04, "Compression check miscompare error") -SENSE_CODE(0x0C05, "Data expansion occurred during compression") -SENSE_CODE(0x0C06, "Block not compressible") -SENSE_CODE(0x0C07, "Write error - recovery needed") -SENSE_CODE(0x0C08, "Write error - recovery failed") -SENSE_CODE(0x0C09, "Write error - loss of streaming") -SENSE_CODE(0x0C0A, "Write error - padding blocks added") -SENSE_CODE(0x0C0B, "Auxiliary memory write error") -SENSE_CODE(0x0C0C, "Write error - unexpected unsolicited data") -SENSE_CODE(0x0C0D, "Write error - not enough unsolicited data") -SENSE_CODE(0x0C0E, "Multiple write errors") -SENSE_CODE(0x0C0F, "Defects in error window") -SENSE_CODE(0x0C10, "Incomplete multiple atomic write operations") -SENSE_CODE(0x0C11, "Write error - recovery scan needed") -SENSE_CODE(0x0C12, "Write error - insufficient zone resources") - -SENSE_CODE(0x0D00, "Error detected by third party temporary initiator") -SENSE_CODE(0x0D01, "Third party device failure") -SENSE_CODE(0x0D02, "Copy target device not reachable") -SENSE_CODE(0x0D03, "Incorrect copy target device type") -SENSE_CODE(0x0D04, "Copy target device data underrun") -SENSE_CODE(0x0D05, "Copy target device data overrun") - -SENSE_CODE(0x0E00, "Invalid information unit") -SENSE_CODE(0x0E01, "Information unit too short") -SENSE_CODE(0x0E02, "Information unit too long") -SENSE_CODE(0x0E03, "Invalid field in command information unit") - -SENSE_CODE(0x1000, "Id CRC or ECC error") -SENSE_CODE(0x1001, "Logical block guard check failed") -SENSE_CODE(0x1002, "Logical block application tag check failed") -SENSE_CODE(0x1003, "Logical block reference tag check failed") -SENSE_CODE(0x1004, "Logical block protection error on recover buffered data") -SENSE_CODE(0x1005, "Logical block protection method error") - -SENSE_CODE(0x1100, "Unrecovered read error") -SENSE_CODE(0x1101, "Read retries exhausted") -SENSE_CODE(0x1102, "Error too long to correct") -SENSE_CODE(0x1103, "Multiple read errors") -SENSE_CODE(0x1104, "Unrecovered read error - auto reallocate failed") -SENSE_CODE(0x1105, "L-EC uncorrectable error") -SENSE_CODE(0x1106, "CIRC unrecovered error") -SENSE_CODE(0x1107, "Data re-synchronization error") -SENSE_CODE(0x1108, "Incomplete block read") -SENSE_CODE(0x1109, "No gap found") -SENSE_CODE(0x110A, "Miscorrected error") -SENSE_CODE(0x110B, "Unrecovered read error - recommend reassignment") -SENSE_CODE(0x110C, "Unrecovered read error - recommend rewrite the data") -SENSE_CODE(0x110D, "De-compression CRC error") -SENSE_CODE(0x110E, "Cannot decompress using declared algorithm") -SENSE_CODE(0x110F, "Error reading UPC/EAN number") -SENSE_CODE(0x1110, "Error reading ISRC number") -SENSE_CODE(0x1111, "Read error - loss of streaming") -SENSE_CODE(0x1112, "Auxiliary memory read error") -SENSE_CODE(0x1113, "Read error - failed retransmission request") -SENSE_CODE(0x1114, "Read error - lba marked bad by application client") -SENSE_CODE(0x1115, "Write after sanitize required") - -SENSE_CODE(0x1200, "Address mark not found for id field") - -SENSE_CODE(0x1300, "Address mark not found for data field") - -SENSE_CODE(0x1400, "Recorded entity not found") -SENSE_CODE(0x1401, "Record not found") -SENSE_CODE(0x1402, "Filemark or setmark not found") -SENSE_CODE(0x1403, "End-of-data not found") -SENSE_CODE(0x1404, "Block sequence error") -SENSE_CODE(0x1405, "Record not found - recommend reassignment") -SENSE_CODE(0x1406, "Record not found - data auto-reallocated") -SENSE_CODE(0x1407, "Locate operation failure") - -SENSE_CODE(0x1500, "Random positioning error") -SENSE_CODE(0x1501, "Mechanical positioning error") -SENSE_CODE(0x1502, "Positioning error detected by read of medium") - -SENSE_CODE(0x1600, "Data synchronization mark error") -SENSE_CODE(0x1601, "Data sync error - data rewritten") -SENSE_CODE(0x1602, "Data sync error - recommend rewrite") -SENSE_CODE(0x1603, "Data sync error - data auto-reallocated") -SENSE_CODE(0x1604, "Data sync error - recommend reassignment") - -SENSE_CODE(0x1700, "Recovered data with no error correction applied") -SENSE_CODE(0x1701, "Recovered data with retries") -SENSE_CODE(0x1702, "Recovered data with positive head offset") -SENSE_CODE(0x1703, "Recovered data with negative head offset") -SENSE_CODE(0x1704, "Recovered data with retries and/or circ applied") -SENSE_CODE(0x1705, "Recovered data using previous sector id") -SENSE_CODE(0x1706, "Recovered data without ECC - data auto-reallocated") -SENSE_CODE(0x1707, "Recovered data without ECC - recommend reassignment") -SENSE_CODE(0x1708, "Recovered data without ECC - recommend rewrite") -SENSE_CODE(0x1709, "Recovered data without ECC - data rewritten") - -SENSE_CODE(0x1800, "Recovered data with error correction applied") -SENSE_CODE(0x1801, "Recovered data with error corr. & retries applied") -SENSE_CODE(0x1802, "Recovered data - data auto-reallocated") -SENSE_CODE(0x1803, "Recovered data with CIRC") -SENSE_CODE(0x1804, "Recovered data with L-EC") -SENSE_CODE(0x1805, "Recovered data - recommend reassignment") -SENSE_CODE(0x1806, "Recovered data - recommend rewrite") -SENSE_CODE(0x1807, "Recovered data with ECC - data rewritten") -SENSE_CODE(0x1808, "Recovered data with linking") - -SENSE_CODE(0x1900, "Defect list error") -SENSE_CODE(0x1901, "Defect list not available") -SENSE_CODE(0x1902, "Defect list error in primary list") -SENSE_CODE(0x1903, "Defect list error in grown list") - -SENSE_CODE(0x1A00, "Parameter list length error") - -SENSE_CODE(0x1B00, "Synchronous data transfer error") - -SENSE_CODE(0x1C00, "Defect list not found") -SENSE_CODE(0x1C01, "Primary defect list not found") -SENSE_CODE(0x1C02, "Grown defect list not found") - -SENSE_CODE(0x1D00, "Miscompare during verify operation") -SENSE_CODE(0x1D01, "Miscompare verify of unmapped LBA") - -SENSE_CODE(0x1E00, "Recovered id with ECC correction") - -SENSE_CODE(0x1F00, "Partial defect list transfer") - -SENSE_CODE(0x2000, "Invalid command operation code") -SENSE_CODE(0x2001, "Access denied - initiator pending-enrolled") -SENSE_CODE(0x2002, "Access denied - no access rights") -SENSE_CODE(0x2003, "Access denied - invalid mgmt id key") -SENSE_CODE(0x2004, "Illegal command while in write capable state") -SENSE_CODE(0x2005, "Obsolete") -SENSE_CODE(0x2006, "Illegal command while in explicit address mode") -SENSE_CODE(0x2007, "Illegal command while in implicit address mode") -SENSE_CODE(0x2008, "Access denied - enrollment conflict") -SENSE_CODE(0x2009, "Access denied - invalid LU identifier") -SENSE_CODE(0x200A, "Access denied - invalid proxy token") -SENSE_CODE(0x200B, "Access denied - ACL LUN conflict") -SENSE_CODE(0x200C, "Illegal command when not in append-only mode") -SENSE_CODE(0x200D, "Not an administrative logical unit") -SENSE_CODE(0x200E, "Not a subsidiary logical unit") -SENSE_CODE(0x200F, "Not a conglomerate logical unit") - -SENSE_CODE(0x2100, "Logical block address out of range") -SENSE_CODE(0x2101, "Invalid element address") -SENSE_CODE(0x2102, "Invalid address for write") -SENSE_CODE(0x2103, "Invalid write crossing layer jump") -SENSE_CODE(0x2104, "Unaligned write command") -SENSE_CODE(0x2105, "Write boundary violation") -SENSE_CODE(0x2106, "Attempt to read invalid data") -SENSE_CODE(0x2107, "Read boundary violation") -SENSE_CODE(0x2108, "Misaligned write command") -SENSE_CODE(0x2109, "Attempt to access gap zone") - -SENSE_CODE(0x2200, "Illegal function (use 20 00, 24 00, or 26 00)") - -SENSE_CODE(0x2300, "Invalid token operation, cause not reportable") -SENSE_CODE(0x2301, "Invalid token operation, unsupported token type") -SENSE_CODE(0x2302, "Invalid token operation, remote token usage not supported") -SENSE_CODE(0x2303, "Invalid token operation, remote rod token creation not supported") -SENSE_CODE(0x2304, "Invalid token operation, token unknown") -SENSE_CODE(0x2305, "Invalid token operation, token corrupt") -SENSE_CODE(0x2306, "Invalid token operation, token revoked") -SENSE_CODE(0x2307, "Invalid token operation, token expired") -SENSE_CODE(0x2308, "Invalid token operation, token cancelled") -SENSE_CODE(0x2309, "Invalid token operation, token deleted") -SENSE_CODE(0x230A, "Invalid token operation, invalid token length") - -SENSE_CODE(0x2400, "Invalid field in cdb") -SENSE_CODE(0x2401, "CDB decryption error") -SENSE_CODE(0x2402, "Obsolete") -SENSE_CODE(0x2403, "Obsolete") -SENSE_CODE(0x2404, "Security audit value frozen") -SENSE_CODE(0x2405, "Security working key frozen") -SENSE_CODE(0x2406, "Nonce not unique") -SENSE_CODE(0x2407, "Nonce timestamp out of range") -SENSE_CODE(0x2408, "Invalid XCDB") -SENSE_CODE(0x2409, "Invalid fast format") - -SENSE_CODE(0x2500, "Logical unit not supported") - -SENSE_CODE(0x2600, "Invalid field in parameter list") -SENSE_CODE(0x2601, "Parameter not supported") -SENSE_CODE(0x2602, "Parameter value invalid") -SENSE_CODE(0x2603, "Threshold parameters not supported") -SENSE_CODE(0x2604, "Invalid release of persistent reservation") -SENSE_CODE(0x2605, "Data decryption error") -SENSE_CODE(0x2606, "Too many target descriptors") -SENSE_CODE(0x2607, "Unsupported target descriptor type code") -SENSE_CODE(0x2608, "Too many segment descriptors") -SENSE_CODE(0x2609, "Unsupported segment descriptor type code") -SENSE_CODE(0x260A, "Unexpected inexact segment") -SENSE_CODE(0x260B, "Inline data length exceeded") -SENSE_CODE(0x260C, "Invalid operation for copy source or destination") -SENSE_CODE(0x260D, "Copy segment granularity violation") -SENSE_CODE(0x260E, "Invalid parameter while port is enabled") -SENSE_CODE(0x260F, "Invalid data-out buffer integrity check value") -SENSE_CODE(0x2610, "Data decryption key fail limit reached") -SENSE_CODE(0x2611, "Incomplete key-associated data set") -SENSE_CODE(0x2612, "Vendor specific key reference not found") -SENSE_CODE(0x2613, "Application tag mode page is invalid") -SENSE_CODE(0x2614, "Tape stream mirroring prevented") -SENSE_CODE(0x2615, "Copy source or copy destination not authorized") -SENSE_CODE(0x2616, "Fast copy not possible") - -SENSE_CODE(0x2700, "Write protected") -SENSE_CODE(0x2701, "Hardware write protected") -SENSE_CODE(0x2702, "Logical unit software write protected") -SENSE_CODE(0x2703, "Associated write protect") -SENSE_CODE(0x2704, "Persistent write protect") -SENSE_CODE(0x2705, "Permanent write protect") -SENSE_CODE(0x2706, "Conditional write protect") -SENSE_CODE(0x2707, "Space allocation failed write protect") -SENSE_CODE(0x2708, "Zone is read only") - -SENSE_CODE(0x2800, "Not ready to ready change, medium may have changed") -SENSE_CODE(0x2801, "Import or export element accessed") -SENSE_CODE(0x2802, "Format-layer may have changed") -SENSE_CODE(0x2803, "Import/export element accessed, medium changed") - -SENSE_CODE(0x2900, "Power on, reset, or bus device reset occurred") -SENSE_CODE(0x2901, "Power on occurred") -SENSE_CODE(0x2902, "Scsi bus reset occurred") -SENSE_CODE(0x2903, "Bus device reset function occurred") -SENSE_CODE(0x2904, "Device internal reset") -SENSE_CODE(0x2905, "Transceiver mode changed to single-ended") -SENSE_CODE(0x2906, "Transceiver mode changed to lvd") -SENSE_CODE(0x2907, "I_T nexus loss occurred") - -SENSE_CODE(0x2A00, "Parameters changed") -SENSE_CODE(0x2A01, "Mode parameters changed") -SENSE_CODE(0x2A02, "Log parameters changed") -SENSE_CODE(0x2A03, "Reservations preempted") -SENSE_CODE(0x2A04, "Reservations released") -SENSE_CODE(0x2A05, "Registrations preempted") -SENSE_CODE(0x2A06, "Asymmetric access state changed") -SENSE_CODE(0x2A07, "Implicit asymmetric access state transition failed") -SENSE_CODE(0x2A08, "Priority changed") -SENSE_CODE(0x2A09, "Capacity data has changed") -SENSE_CODE(0x2A0A, "Error history I_T nexus cleared") -SENSE_CODE(0x2A0B, "Error history snapshot released") -SENSE_CODE(0x2A0C, "Error recovery attributes have changed") -SENSE_CODE(0x2A0D, "Data encryption capabilities changed") -SENSE_CODE(0x2A10, "Timestamp changed") -SENSE_CODE(0x2A11, "Data encryption parameters changed by another i_t nexus") -SENSE_CODE(0x2A12, "Data encryption parameters changed by vendor specific event") -SENSE_CODE(0x2A13, "Data encryption key instance counter has changed") -SENSE_CODE(0x2A14, "SA creation capabilities data has changed") -SENSE_CODE(0x2A15, "Medium removal prevention preempted") -SENSE_CODE(0x2A16, "Zone reset write pointer recommended") - -SENSE_CODE(0x2B00, "Copy cannot execute since host cannot disconnect") - -SENSE_CODE(0x2C00, "Command sequence error") -SENSE_CODE(0x2C01, "Too many windows specified") -SENSE_CODE(0x2C02, "Invalid combination of windows specified") -SENSE_CODE(0x2C03, "Current program area is not empty") -SENSE_CODE(0x2C04, "Current program area is empty") -SENSE_CODE(0x2C05, "Illegal power condition request") -SENSE_CODE(0x2C06, "Persistent prevent conflict") -SENSE_CODE(0x2C07, "Previous busy status") -SENSE_CODE(0x2C08, "Previous task set full status") -SENSE_CODE(0x2C09, "Previous reservation conflict status") -SENSE_CODE(0x2C0A, "Partition or collection contains user objects") -SENSE_CODE(0x2C0B, "Not reserved") -SENSE_CODE(0x2C0C, "Orwrite generation does not match") -SENSE_CODE(0x2C0D, "Reset write pointer not allowed") -SENSE_CODE(0x2C0E, "Zone is offline") -SENSE_CODE(0x2C0F, "Stream not open") -SENSE_CODE(0x2C10, "Unwritten data in zone") -SENSE_CODE(0x2C11, "Descriptor format sense data required") -SENSE_CODE(0x2C12, "Zone is inactive") -SENSE_CODE(0x2C13, "Well known logical unit access required") - -SENSE_CODE(0x2D00, "Overwrite error on update in place") - -SENSE_CODE(0x2E00, "Insufficient time for operation") -SENSE_CODE(0x2E01, "Command timeout before processing") -SENSE_CODE(0x2E02, "Command timeout during processing") -SENSE_CODE(0x2E03, "Command timeout during processing due to error recovery") - -SENSE_CODE(0x2F00, "Commands cleared by another initiator") -SENSE_CODE(0x2F01, "Commands cleared by power loss notification") -SENSE_CODE(0x2F02, "Commands cleared by device server") -SENSE_CODE(0x2F03, "Some commands cleared by queuing layer event") - -SENSE_CODE(0x3000, "Incompatible medium installed") -SENSE_CODE(0x3001, "Cannot read medium - unknown format") -SENSE_CODE(0x3002, "Cannot read medium - incompatible format") -SENSE_CODE(0x3003, "Cleaning cartridge installed") -SENSE_CODE(0x3004, "Cannot write medium - unknown format") -SENSE_CODE(0x3005, "Cannot write medium - incompatible format") -SENSE_CODE(0x3006, "Cannot format medium - incompatible medium") -SENSE_CODE(0x3007, "Cleaning failure") -SENSE_CODE(0x3008, "Cannot write - application code mismatch") -SENSE_CODE(0x3009, "Current session not fixated for append") -SENSE_CODE(0x300A, "Cleaning request rejected") -SENSE_CODE(0x300C, "WORM medium - overwrite attempted") -SENSE_CODE(0x300D, "WORM medium - integrity check") -SENSE_CODE(0x3010, "Medium not formatted") -SENSE_CODE(0x3011, "Incompatible volume type") -SENSE_CODE(0x3012, "Incompatible volume qualifier") -SENSE_CODE(0x3013, "Cleaning volume expired") - -SENSE_CODE(0x3100, "Medium format corrupted") -SENSE_CODE(0x3101, "Format command failed") -SENSE_CODE(0x3102, "Zoned formatting failed due to spare linking") -SENSE_CODE(0x3103, "Sanitize command failed") -SENSE_CODE(0x3104, "Depopulation failed") -SENSE_CODE(0x3105, "Depopulation restoration failed") - -SENSE_CODE(0x3200, "No defect spare location available") -SENSE_CODE(0x3201, "Defect list update failure") - -SENSE_CODE(0x3300, "Tape length error") - -SENSE_CODE(0x3400, "Enclosure failure") - -SENSE_CODE(0x3500, "Enclosure services failure") -SENSE_CODE(0x3501, "Unsupported enclosure function") -SENSE_CODE(0x3502, "Enclosure services unavailable") -SENSE_CODE(0x3503, "Enclosure services transfer failure") -SENSE_CODE(0x3504, "Enclosure services transfer refused") -SENSE_CODE(0x3505, "Enclosure services checksum error") - -SENSE_CODE(0x3600, "Ribbon, ink, or toner failure") - -SENSE_CODE(0x3700, "Rounded parameter") - -SENSE_CODE(0x3800, "Event status notification") -SENSE_CODE(0x3802, "Esn - power management class event") -SENSE_CODE(0x3804, "Esn - media class event") -SENSE_CODE(0x3806, "Esn - device busy class event") -SENSE_CODE(0x3807, "Thin Provisioning soft threshold reached") -SENSE_CODE(0x3808, "Depopulation interrupted") - -SENSE_CODE(0x3900, "Saving parameters not supported") - -SENSE_CODE(0x3A00, "Medium not present") -SENSE_CODE(0x3A01, "Medium not present - tray closed") -SENSE_CODE(0x3A02, "Medium not present - tray open") -SENSE_CODE(0x3A03, "Medium not present - loadable") -SENSE_CODE(0x3A04, "Medium not present - medium auxiliary memory accessible") - -SENSE_CODE(0x3B00, "Sequential positioning error") -SENSE_CODE(0x3B01, "Tape position error at beginning-of-medium") -SENSE_CODE(0x3B02, "Tape position error at end-of-medium") -SENSE_CODE(0x3B03, "Tape or electronic vertical forms unit not ready") -SENSE_CODE(0x3B04, "Slew failure") -SENSE_CODE(0x3B05, "Paper jam") -SENSE_CODE(0x3B06, "Failed to sense top-of-form") -SENSE_CODE(0x3B07, "Failed to sense bottom-of-form") -SENSE_CODE(0x3B08, "Reposition error") -SENSE_CODE(0x3B09, "Read past end of medium") -SENSE_CODE(0x3B0A, "Read past beginning of medium") -SENSE_CODE(0x3B0B, "Position past end of medium") -SENSE_CODE(0x3B0C, "Position past beginning of medium") -SENSE_CODE(0x3B0D, "Medium destination element full") -SENSE_CODE(0x3B0E, "Medium source element empty") -SENSE_CODE(0x3B0F, "End of medium reached") -SENSE_CODE(0x3B11, "Medium magazine not accessible") -SENSE_CODE(0x3B12, "Medium magazine removed") -SENSE_CODE(0x3B13, "Medium magazine inserted") -SENSE_CODE(0x3B14, "Medium magazine locked") -SENSE_CODE(0x3B15, "Medium magazine unlocked") -SENSE_CODE(0x3B16, "Mechanical positioning or changer error") -SENSE_CODE(0x3B17, "Read past end of user object") -SENSE_CODE(0x3B18, "Element disabled") -SENSE_CODE(0x3B19, "Element enabled") -SENSE_CODE(0x3B1A, "Data transfer device removed") -SENSE_CODE(0x3B1B, "Data transfer device inserted") -SENSE_CODE(0x3B1C, "Too many logical objects on partition to support operation") -SENSE_CODE(0x3B20, "Element static information changed") - -SENSE_CODE(0x3D00, "Invalid bits in identify message") - -SENSE_CODE(0x3E00, "Logical unit has not self-configured yet") -SENSE_CODE(0x3E01, "Logical unit failure") -SENSE_CODE(0x3E02, "Timeout on logical unit") -SENSE_CODE(0x3E03, "Logical unit failed self-test") -SENSE_CODE(0x3E04, "Logical unit unable to update self-test log") - -SENSE_CODE(0x3F00, "Target operating conditions have changed") -SENSE_CODE(0x3F01, "Microcode has been changed") -SENSE_CODE(0x3F02, "Changed operating definition") -SENSE_CODE(0x3F03, "Inquiry data has changed") -SENSE_CODE(0x3F04, "Component device attached") -SENSE_CODE(0x3F05, "Device identifier changed") -SENSE_CODE(0x3F06, "Redundancy group created or modified") -SENSE_CODE(0x3F07, "Redundancy group deleted") -SENSE_CODE(0x3F08, "Spare created or modified") -SENSE_CODE(0x3F09, "Spare deleted") -SENSE_CODE(0x3F0A, "Volume set created or modified") -SENSE_CODE(0x3F0B, "Volume set deleted") -SENSE_CODE(0x3F0C, "Volume set deassigned") -SENSE_CODE(0x3F0D, "Volume set reassigned") -SENSE_CODE(0x3F0E, "Reported luns data has changed") -SENSE_CODE(0x3F0F, "Echo buffer overwritten") -SENSE_CODE(0x3F10, "Medium loadable") -SENSE_CODE(0x3F11, "Medium auxiliary memory accessible") -SENSE_CODE(0x3F12, "iSCSI IP address added") -SENSE_CODE(0x3F13, "iSCSI IP address removed") -SENSE_CODE(0x3F14, "iSCSI IP address changed") -SENSE_CODE(0x3F15, "Inspect referrals sense descriptors") -SENSE_CODE(0x3F16, "Microcode has been changed without reset") -SENSE_CODE(0x3F17, "Zone transition to full") -SENSE_CODE(0x3F18, "Bind completed") -SENSE_CODE(0x3F19, "Bind redirected") -SENSE_CODE (0x3F1A ,"Subsidiary binding changed" ) +SENSE_CODE (NO_ADDITIONAL_SENSE_INFORMATION , + "No additional sense information") +SENSE_CODE (FILEMARK_DETECTED , + "Filemark detected") +SENSE_CODE (END_OF_PARTITION_MEDIUM_DETECTED , + "End-of-partition/medium detected") +SENSE_CODE (SETMARK_DETECTED , + "Setmark detected") +SENSE_CODE (BEGINNING_OF_PARTITION_MEDIUM_DETECTED , + "Beginning-of-partition/medium detected") +SENSE_CODE (END_OF_DATA_DETECTED , + "End-of-data detected") +SENSE_CODE (IO_PROCESS_TERMINATED , + "I/O process terminated") +SENSE_CODE (PROGRAMMABLE_EARLY_WARNING_DETECTED , + "Programmable early warning detected") +SENSE_CODE (AUDIO_PLAY_OP_IN_PROGRESS , + "Audio play operation in progress") +SENSE_CODE (AUDIO_PLAY_OP_PAUSED , + "Audio play operation paused") +SENSE_CODE (AUDIO_PLAY_OP_SUCCESSFULLY_COMPLETED , + "Audio play operation successfully completed") +SENSE_CODE (AUDIO_PLAY_OP_STOPPED_DUE_TO_ERROR , + "Audio play operation stopped due to error") +SENSE_CODE (NO_CURRENT_AUDIO_STATUS_TO_RETURN , + "No current audio status to return") +SENSE_CODE (OP_IN_PROGRESS , + "Operation in progress") +SENSE_CODE (CLEANING_REQUESTED , + "Cleaning requested") +SENSE_CODE (ERASE_OP_IN_PROGRESS , + "Erase operation in progress") +SENSE_CODE (LOCATE_OP_IN_PROGRESS , + "Locate operation in progress") +SENSE_CODE (REWIND_OP_IN_PROGRESS , + "Rewind operation in progress") +SENSE_CODE (SET_CAPACITY_OP_IN_PROGRESS , + "Set capacity operation in progress") +SENSE_CODE (VERIFY_OP_IN_PROGRESS , + "Verify operation in progress") +SENSE_CODE (ATA_PASS_THROUGH_INFORMATION_AVAILABLE , + "ATA pass through information available") +SENSE_CODE (CONFLICTING_SA_CREATION_REQUEST , + "Conflicting SA creation request") +SENSE_CODE (LU_TRANSITIONING_TO_ANOTHER_POWER_CONDITION , + "Logical unit transitioning to another power condition") +SENSE_CODE (EXTENDED_COPY_INFORMATION_AVAILABLE , + "Extended copy information available") +SENSE_CODE (ATOMIC_COMMAND_ABORTED_DUE_TO_ACA , + "Atomic command aborted due to ACA") +SENSE_CODE (DEFERRED_MICROCODE_IS_PENDING , + "Deferred microcode is pending") +SENSE_CODE (OVERLAPPING_ATOMIC_COMMAND_IN_PROGRESS , + "Overlapping atomic command in progress") + +SENSE_CODE (NO_INDEX_SECTOR_SIGNAL , + "No index/sector signal") + +SENSE_CODE (NO_SEEK_COMPLETE , + "No seek complete") + +SENSE_CODE (PERIPHERAL_DEVICE_WRITE_FAULT , + "Peripheral device write fault") +SENSE_CODE (NO_WRITE_CURRENT , + "No write current") +SENSE_CODE (EXCESSIVE_WRITE_ERRORS , + "Excessive write errors") + +SENSE_CODE (LU_NOT_READY , + "Logical unit not ready, cause not reportable") +SENSE_CODE (LU_IS_IN_PROCESS_OF_BECOMING_READY , + "Logical unit is in process of becoming ready") +SENSE_CODE (LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED , + "Logical unit not ready, initializing command required") +SENSE_CODE (LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED , + "Logical unit not ready, manual intervention required") +SENSE_CODE (LU_NOT_READY_FORMAT_IN_PROGRESS , + "Logical unit not ready, format in progress") +SENSE_CODE (LU_NOT_READY_REBUILD_IN_PROGRESS , + "Logical unit not ready, rebuild in progress") +SENSE_CODE (LU_NOT_READY_RECALCULATION_IN_PROGRESS , + "Logical unit not ready, recalculation in progress") +SENSE_CODE (LU_NOT_READY_OP_IN_PROGRESS , + "Logical unit not ready, operation in progress") +SENSE_CODE (LU_NOT_READY_LONG_WRITE_IN_PROGRESS , + "Logical unit not ready, long write in progress") +SENSE_CODE (LU_NOT_READY_SELFTEST_IN_PROGRESS , + "Logical unit not ready, self-test in progress") +SENSE_CODE (LU_NOT_ACCESSIBLE_ASYMMETRIC_ACCESS_STATE_TRANSITION , + "Logical unit not accessible, asymmetric access state transition") +SENSE_CODE (LU_NOT_ACCESSIBLE_TARGET_PORT_IN_STANDBY_STATE , + "Logical unit not accessible, target port in standby state") +SENSE_CODE (LU_NOT_ACCESSIBLE_TARGET_PORT_IN_UNAVAILABLE_STATE , + "Logical unit not accessible, target port in unavailable state") +SENSE_CODE (LU_NOT_READY_STRUCTURE_CHECK_REQUIRED , + "Logical unit not ready, structure check required") +SENSE_CODE (LU_NOT_READY_SECURITY_SESSION_IN_PROGRESS , + "Logical unit not ready, security session in progress") +SENSE_CODE (LU_NOT_READY_AUXILIARY_MEMORY_NOT_ACCESSIBLE , + "Logical unit not ready, auxiliary memory not accessible") +SENSE_CODE (LU_NOT_READY_NOTIFY_REQUIRED , + "Logical unit not ready, notify (enable spinup) required") +SENSE_CODE (LU_NOT_READY_OFFLINE , + "Logical unit not ready, offline") +SENSE_CODE (LU_NOT_READY_SA_CREATION_IN_PROGRESS , + "Logical unit not ready, SA creation in progress") +SENSE_CODE (LU_NOT_READY_SPACE_ALLOCATION_IN_PROGRESS , + "Logical unit not ready, space allocation in progress") +SENSE_CODE (LU_NOT_READY_ROBOTICS_DISABLED , + "Logical unit not ready, robotics disabled") +SENSE_CODE (LU_NOT_READY_CONFIG_REQUIRED , + "Logical unit not ready, configuration required") +SENSE_CODE (LU_NOT_READY_CALIBRATION_REQUIRED , + "Logical unit not ready, calibration required") +SENSE_CODE (LU_NOT_READY_A_DOOR_IS_OPEN , + "Logical unit not ready, a door is open") +SENSE_CODE (LU_NOT_READY_OPERATING_IN_SEQUENTIAL_MODE , + "Logical unit not ready, operating in sequential mode") +SENSE_CODE (LU_NOT_READY_START_STOP_UNIT_COMMAND_IN_PROGRESS , + "Logical unit not ready, start stop unit command in progress") +SENSE_CODE (LU_NOT_READY_SANITIZE_IN_PROGRESS , + "Logical unit not ready, sanitize in progress") +SENSE_CODE (LU_NOT_READY_ADDITIONAL_POWER_USE_NOT_YET_GRANTED , + "Logical unit not ready, additional power use not yet granted") +SENSE_CODE (LU_NOT_READY_CONFIG_IN_PROGRESS , + "Logical unit not ready, configuration in progress") +SENSE_CODE (LU_NOT_READY_MICROCODE_ACTIVATION_REQUIRED , + "Logical unit not ready, microcode activation required") +SENSE_CODE (LU_NOT_READY_MICROCODE_DOWNLOAD_REQUIRED , + "Logical unit not ready, microcode download required") +SENSE_CODE (LU_NOT_READY_LU_RESET_REQUIRED , + "Logical unit not ready, logical unit reset required") +SENSE_CODE (LU_NOT_READY_HARD_RESET_REQUIRED , + "Logical unit not ready, hard reset required") +SENSE_CODE (LU_NOT_READY_POWER_CYCLE_REQUIRED , + "Logical unit not ready, power cycle required") +SENSE_CODE (LU_NOT_READY_AFFILIATION_REQUIRED , + "Logical unit not ready, affiliation required") +SENSE_CODE (DEPOPULATION_IN_PROGRESS , + "Depopulation in progress") +SENSE_CODE (DEPOPULATION_RESTORATION_IN_PROGRESS , + "Depopulation restoration in progress") + +SENSE_CODE (LU_DOES_NOT_RESPOND_TO_SELECTION , + "Logical unit does not respond to selection") + +SENSE_CODE (NO_REFERENCE_POSITION_FOUND , + "No reference position found") + +SENSE_CODE (MULTIPLE_PERIPHERAL_DEVICES_SELECTED , + "Multiple peripheral devices selected") + +SENSE_CODE (LU_COMMUNICATION_FAILURE , + "Logical unit communication failure") +SENSE_CODE (LU_COMMUNICATION_TIMEOUT , + "Logical unit communication time-out") +SENSE_CODE (LU_COMMUNICATION_PARITY_ERROR , + "Logical unit communication parity error") +SENSE_CODE (LU_COMMUNICATION_CRC_ERROR , + "Logical unit communication CRC error (Ultra-DMA/32)") +SENSE_CODE (UNREACHABLE_COPY_TARGET , + "Unreachable copy target") + +SENSE_CODE (TRACK_FOLLOWING_ERROR , + "Track following error") +SENSE_CODE (TRACKING_SERVO_FAILURE , + "Tracking servo failure") +SENSE_CODE (FOCUS_SERVO_FAILURE , + "Focus servo failure") +SENSE_CODE (SPINDLE_SERVO_FAILURE , + "Spindle servo failure") +SENSE_CODE (HEAD_SELECT_FAULT , + "Head select fault") +SENSE_CODE (VIBRATION_INDUCED_TRACKING_ERROR , + "Vibration induced tracking error") + +SENSE_CODE (ERROR_LOG_OVERFLOW , + "Error log overflow") + +SENSE_CODE (WARNING , + "Warning") +SENSE_CODE (WARNING_SPECIFIED_TEMPERATURE_EXCEEDED , + "Warning - specified temperature exceeded") +SENSE_CODE (WARNING_ENCLOSURE_DEGRADED , + "Warning - enclosure degraded") +SENSE_CODE (WARNING_BACKGROUND_SELFTEST_FAILED , + "Warning - background self-test failed") +SENSE_CODE (WARNING_BACKGROUND_PRESCAN_DETECTED_MEDIUM_ERROR , + "Warning - background pre-scan detected medium error") +SENSE_CODE (WARNING_BACKGROUND_MEDIUM_SCAN_DETECTED_MEDIUM_ERROR , + "Warning - background medium scan detected medium error") +SENSE_CODE (WARNING_NONVOLATILE_CACHE_NOW_VOLATILE , + "Warning - non-volatile cache now volatile") +SENSE_CODE (WARNING_DEGRADED_POWER_TO_NONVOLATILE_CACHE , + "Warning - degraded power to non-volatile cache") +SENSE_CODE (WARNING_POWER_LOSS_EXPECTED , + "Warning - power loss expected") +SENSE_CODE (WARNING_DEVICE_STATISTICS_NOTIFICATION_ACTIVE , + "Warning - device statistics notification active") +SENSE_CODE (WARNING_HIGH_CRITICAL_TEMPERATURE_LIMIT_EXCEEDED , + "Warning - high critical temperature limit exceeded") +SENSE_CODE (WARNING_LOW_CRITICAL_TEMPERATURE_LIMIT_EXCEEDED , + "Warning - low critical temperature limit exceeded") +SENSE_CODE (WARNING_HIGH_OPERATING_TEMPERATURE_LIMIT_EXCEEDED , + "Warning - high operating temperature limit exceeded") +SENSE_CODE (WARNING_LOW_OPERATING_TEMPERATURE_LIMIT_EXCEEDED , + "Warning - low operating temperature limit exceeded") +SENSE_CODE (WARNING_HIGH_CRITICAL_HUMIDITY_LIMIT_EXCEEDED , + "Warning - high critical humidity limit exceeded") +SENSE_CODE (WARNING_LOW_CRITICAL_HUMIDITY_LIMIT_EXCEEDED , + "Warning - low critical humidity limit exceeded") +SENSE_CODE (WARNING_HIGH_OPERATING_HUMIDITY_LIMIT_EXCEEDED , + "Warning - high operating humidity limit exceeded") +SENSE_CODE (WARNING_LOW_OPERATING_HUMIDITY_LIMIT_EXCEEDED , + "Warning - low operating humidity limit exceeded") +SENSE_CODE (WARNING_MICROCODE_SECURITY_AT_RISK , + "Warning - microcode security at risk") +SENSE_CODE (WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE , + "Warning - microcode digital signature validation failure") +SENSE_CODE (WARNING_PHYSICAL_ELEMENT_STATUS_CHANGE , + "Warning - physical element status change") + +SENSE_CODE (WRITE_ERROR , + "Write error") +SENSE_CODE (WRITE_ERROR_RECOVERED_WITH_AUTO_REALLOCATION , + "Write error - recovered with auto reallocation") +SENSE_CODE (WRITE_ERROR_AUTO_REALLOCATION_FAILED , + "Write error - auto reallocation failed") +SENSE_CODE (WRITE_ERROR_RECOMMEND_REASSIGNMENT , + "Write error - recommend reassignment") +SENSE_CODE (COMPRESSION_CHECK_MISCOMPARE_ERROR , + "Compression check miscompare error") +SENSE_CODE (DATA_EXPANSION_OCCURRED_DURING_COMPRESSION , + "Data expansion occurred during compression") +SENSE_CODE (BLOCK_NOT_COMPRESSIBLE , + "Block not compressible") +SENSE_CODE (WRITE_ERROR_RECOVERY_NEEDED , + "Write error - recovery needed") +SENSE_CODE (WRITE_ERROR_RECOVERY_FAILED , + "Write error - recovery failed") +SENSE_CODE (WRITE_ERROR_LOSS_OF_STREAMING , + "Write error - loss of streaming") +SENSE_CODE (WRITE_ERROR_PADDING_BLOCKS_ADDED , + "Write error - padding blocks added") +SENSE_CODE (AUXILIARY_MEMORY_WRITE_ERROR , + "Auxiliary memory write error") +SENSE_CODE (WRITE_ERROR_UNEXPECTED_UNSOLICITED_DATA , + "Write error - unexpected unsolicited data") +SENSE_CODE (WRITE_ERROR_NOT_ENOUGH_UNSOLICITED_DATA , + "Write error - not enough unsolicited data") +SENSE_CODE (MULTIPLE_WRITE_ERRORS , + "Multiple write errors") +SENSE_CODE (DEFECTS_IN_ERROR_WINDOW , + "Defects in error window") +SENSE_CODE (INCOMPLETE_MULTIPLE_ATOMIC_WRITE_OPERATIONS , + "Incomplete multiple atomic write operations") +SENSE_CODE (WRITE_ERROR_RECOVERY_SCAN_NEEDED , + "Write error - recovery scan needed") +SENSE_CODE (WRITE_ERROR_INSUFFICIENT_ZONE_RESOURCES , + "Write error - insufficient zone resources") + +SENSE_CODE (ERROR_DETECTED_BY_THIRD_PARTY_TEMPORARY_INITIATOR , + "Error detected by third party temporary initiator") +SENSE_CODE (THIRD_PARTY_DEVICE_FAILURE , + "Third party device failure") +SENSE_CODE (COPY_TARGET_DEVICE_NOT_REACHABLE , + "Copy target device not reachable") +SENSE_CODE (INCORRECT_COPY_TARGET_DEVICE_TYPE , + "Incorrect copy target device type") +SENSE_CODE (COPY_TARGET_DEVICE_DATA_UNDERRUN , + "Copy target device data underrun") +SENSE_CODE (COPY_TARGET_DEVICE_DATA_OVERRUN , + "Copy target device data overrun") + +SENSE_CODE (INVALID_INFORMATION_UNIT , + "Invalid information unit") +SENSE_CODE (INFORMATION_UNIT_TOO_SHORT , + "Information unit too short") +SENSE_CODE (INFORMATION_UNIT_TOO_LONG , + "Information unit too long") +SENSE_CODE (INVALID_FIELD_IN_COMMAND_INFORMATION_UNIT , + "Invalid field in command information unit") + +SENSE_CODE (ID_CRC_OR_ECC_ERROR , + "Id CRC or ECC error") +SENSE_CODE (LOGICAL_BLOCK_GUARD_CHECK_FAILED , + "Logical block guard check failed") +SENSE_CODE (LOGICAL_BLOCK_APPLICATION_TAG_CHECK_FAILED , + "Logical block application tag check failed") +SENSE_CODE (LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED , + "Logical block reference tag check failed") +SENSE_CODE (LOGICAL_BLOCK_PROTECTION_ERROR_ON_RECOVER_BUFFERED_DATA , + "Logical block protection error on recover buffered data") +SENSE_CODE (LOGICAL_BLOCK_PROTECTION_METHOD_ERROR , + "Logical block protection method error") + +SENSE_CODE (UNRECOVERED_READ_ERROR , + "Unrecovered read error") +SENSE_CODE (READ_RETRIES_EXHAUSTED , + "Read retries exhausted") +SENSE_CODE (ERROR_TOO_LONG_TO_CORRECT , + "Error too long to correct") +SENSE_CODE (MULTIPLE_READ_ERRORS , + "Multiple read errors") +SENSE_CODE (UNRECOVERED_READ_ERROR_AUTO_REALLOCATE_FAILED , + "Unrecovered read error - auto reallocate failed") +SENSE_CODE (LEC_UNCORRECTABLE_ERROR , + "L-EC uncorrectable error") +SENSE_CODE (CIRC_UNRECOVERED_ERROR , + "CIRC unrecovered error") +SENSE_CODE (DATA_RESYNCHRONIZATION_ERROR , + "Data re-synchronization error") +SENSE_CODE (INCOMPLETE_BLOCK_READ , + "Incomplete block read") +SENSE_CODE (NO_GAP_FOUND , + "No gap found") +SENSE_CODE (MISCORRECTED_ERROR , + "Miscorrected error") +SENSE_CODE (UNRECOVERED_READ_ERROR_RECOMMEND_REASSIGNMENT , + "Unrecovered read error - recommend reassignment") +SENSE_CODE (UNRECOVERED_READ_ERROR_RECOMMEND_REWRITE_THE_DATA , + "Unrecovered read error - recommend rewrite the data") +SENSE_CODE (DECOMPRESSION_CRC_ERROR , + "De-compression CRC error") +SENSE_CODE (CANNOT_DECOMPRESS_USING_DECLARED_ALGORITHM , + "Cannot decompress using declared algorithm") +SENSE_CODE (ERROR_READING_UPC_EAN_NUMBER , + "Error reading UPC/EAN number") +SENSE_CODE (ERROR_READING_ISRC_NUMBER , + "Error reading ISRC number") +SENSE_CODE (READ_ERROR_LOSS_OF_STREAMING , + "Read error - loss of streaming") +SENSE_CODE (AUXILIARY_MEMORY_READ_ERROR , + "Auxiliary memory read error") +SENSE_CODE (READ_ERROR_FAILED_RETRANSMISSION_REQUEST , + "Read error - failed retransmission request") +SENSE_CODE (READ_ERROR_LBA_MARKED_BAD_BY_APPLICATION_CLIENT , + "Read error - lba marked bad by application client") +SENSE_CODE (WRITE_AFTER_SANITIZE_REQUIRED , + "Write after sanitize required") + +SENSE_CODE (ADDRESS_MARK_NOT_FOUND_FOR_ID_FIELD , + "Address mark not found for id field") + +SENSE_CODE (ADDRESS_MARK_NOT_FOUND_FOR_DATA_FIELD , + "Address mark not found for data field") + +SENSE_CODE (RECORDED_ENTITY_NOT_FOUND , + "Recorded entity not found") +SENSE_CODE (RECORD_NOT_FOUND , + "Record not found") +SENSE_CODE (FILEMARK_OR_SETMARK_NOT_FOUND , + "Filemark or setmark not found") +SENSE_CODE (END_OF_DATA_NOT_FOUND , + "End-of-data not found") +SENSE_CODE (BLOCK_SEQUENCE_ERROR , + "Block sequence error") +SENSE_CODE (RECORD_NOT_FOUND_RECOMMEND_REASSIGNMENT , + "Record not found - recommend reassignment") +SENSE_CODE (RECORD_NOT_FOUND_DATA_AUTO_REALLOCATED , + "Record not found - data auto-reallocated") +SENSE_CODE (LOCATE_OPERATION_FAILURE , + "Locate operation failure") + +SENSE_CODE (RANDOM_POSITIONING_ERROR , + "Random positioning error") +SENSE_CODE (MECHANICAL_POSITIONING_ERROR , + "Mechanical positioning error") +SENSE_CODE (POSITIONING_ERROR_DETECTED_BY_READ_OF_MEDIUM , + "Positioning error detected by read of medium") + +SENSE_CODE (DATA_SYNCHRONIZATION_MARK_ERROR , + "Data synchronization mark error") +SENSE_CODE (DATA_SYNC_ERROR_DATA_REWRITTEN , + "Data sync error - data rewritten") +SENSE_CODE (DATA_SYNC_ERROR_RECOMMEND_REWRITE , + "Data sync error - recommend rewrite") +SENSE_CODE (DATA_SYNC_ERROR_DATA_AUTO_REALLOCATED , + "Data sync error - data auto-reallocated") +SENSE_CODE (DATA_SYNC_ERROR_RECOMMEND_REASSIGNMENT , + "Data sync error - recommend reassignment") + +SENSE_CODE (RECOVERED_DATA_WITH_NO_ERROR_CORRECTION_APPLIED , + "Recovered data with no error correction applied") +SENSE_CODE (RECOVERED_DATA_WITH_RETRIES , + "Recovered data with retries") +SENSE_CODE (RECOVERED_DATA_WITH_POSITIVE_HEAD_OFFSET , + "Recovered data with positive head offset") +SENSE_CODE (RECOVERED_DATA_WITH_NEGATIVE_HEAD_OFFSET , + "Recovered data with negative head offset") +SENSE_CODE (RECOVERED_DATA_WITH_RETRIES_AND_OR_CIRC_APPLIED , + "Recovered data with retries and/or circ applied") +SENSE_CODE (RECOVERED_DATA_USING_PREVIOUS_SECTOR_ID , + "Recovered data using previous sector id") +SENSE_CODE (RECOVERED_DATA_WITHOUT_ECC_DATA_AUTO_REALLOCATED , + "Recovered data without ECC - data auto-reallocated") +SENSE_CODE (RECOVERED_DATA_WITHOUT_ECC_RECOMMEND_REASSIGNMENT , + "Recovered data without ECC - recommend reassignment") +SENSE_CODE (RECOVERED_DATA_WITHOUT_ECC_RECOMMEND_REWRITE , + "Recovered data without ECC - recommend rewrite") +SENSE_CODE (RECOVERED_DATA_WITHOUT_ECC_DATA_REWRITTEN , + "Recovered data without ECC - data rewritten") + +SENSE_CODE (RECOVERED_DATA_WITH_ERROR_CORRECTION_APPLIED , + "Recovered data with error correction applied") +SENSE_CODE (RECOVERED_DATA_WITH_ERROR_CORRECTION_RETRIES_APPLIED , + "Recovered data with error corr. & retries applied") +SENSE_CODE (RECOVERED_DATA_DATA_AUTO_REALLOCATED , + "Recovered data - data auto-reallocated") +SENSE_CODE (RECOVERED_DATA_WITH_CIRC , + "Recovered data with CIRC") +SENSE_CODE (RECOVERED_DATA_WITH_LEC , + "Recovered data with L-EC") +SENSE_CODE (RECOVERED_DATA_RECOMMEND_REASSIGNMENT , + "Recovered data - recommend reassignment") +SENSE_CODE (RECOVERED_DATA_RECOMMEND_REWRITE , + "Recovered data - recommend rewrite") +SENSE_CODE (RECOVERED_DATA_WITH_ECC_DATA_REWRITTEN , + "Recovered data with ECC - data rewritten") +SENSE_CODE (RECOVERED_DATA_WITH_LINKING , + "Recovered data with linking") + +SENSE_CODE (DEFECT_LIST_ERROR , + "Defect list error") +SENSE_CODE (DEFECT_LIST_NOT_AVAILABLE , + "Defect list not available") +SENSE_CODE (DEFECT_LIST_ERROR_IN_PRIMARY_LIST , + "Defect list error in primary list") +SENSE_CODE (DEFECT_LIST_ERROR_IN_GROWN_LIST , + "Defect list error in grown list") + +SENSE_CODE (PARAMETER_LIST_LENGTH_ERROR , + "Parameter list length error") + +SENSE_CODE (SYNCHRONOUS_DATA_TRANSFER_ERROR , + "Synchronous data transfer error") + +SENSE_CODE (DEFECT_LIST_NOT_FOUND , + "Defect list not found") +SENSE_CODE (PRIMARY_DEFECT_LIST_NOT_FOUND , + "Primary defect list not found") +SENSE_CODE (GROWN_DEFECT_LIST_NOT_FOUND , + "Grown defect list not found") + +SENSE_CODE (MISCOMPARE_DURING_VERIFY_OPERATION , + "Miscompare during verify operation") +SENSE_CODE (MISCOMPARE_VERIFY_OF_UNMAPPED_LBA , + "Miscompare verify of unmapped LBA") + +SENSE_CODE (RECOVERED_ID_WITH_ECC_CORRECTION , + "Recovered id with ECC correction") + +SENSE_CODE (PARTIAL_DEFECT_LIST_TRANSFER , + "Partial defect list transfer") + +SENSE_CODE (INVALID_COMMAND_OP_CODE , + "Invalid command operation code") +SENSE_CODE (ACCESS_DENIED_INITIATOR_PENDING_ENROLLED , + "Access denied - initiator pending-enrolled") +SENSE_CODE (ACCESS_DENIED_NO_ACCESS_RIGHTS , + "Access denied - no access rights") +SENSE_CODE (ACCESS_DENIED_INVALID_MGMT_ID_KEY , + "Access denied - invalid mgmt id key") +SENSE_CODE (ILLEGAL_COMMAND_WHILE_IN_WRITE_CAPABLE_STATE , + "Illegal command while in write capable state") +SENSE_CODE (0x2005 , + "Obsolete") +SENSE_CODE (ILLEGAL_COMMAND_WHILE_IN_EXPLICIT_ADDRESS_MODE , + "Illegal command while in explicit address mode") +SENSE_CODE (ILLEGAL_COMMAND_WHILE_IN_IMPLICIT_ADDRESS_MODE , + "Illegal command while in implicit address mode") +SENSE_CODE (ACCESS_DENIED_ENROLLMENT_CONFLICT , + "Access denied - enrollment conflict") +SENSE_CODE (ACCESS_DENIED_INVALID_LU_IDENTIFIER , + "Access denied - invalid LU identifier") +SENSE_CODE (ACCESS_DENIED_INVALID_PROXY_TOKEN , + "Access denied - invalid proxy token") +SENSE_CODE (ACCESS_DENIED_ACL_LUN_CONFLICT , + "Access denied - ACL LUN conflict") +SENSE_CODE (ILLEGAL_COMMAND_WHEN_NOT_IN_APPEND_ONLY_MODE , + "Illegal command when not in append-only mode") +SENSE_CODE (NOT_AN_ADMINISTRATIVE_LOGICAL_UNIT , + "Not an administrative logical unit") +SENSE_CODE (NOT_A_SUBSIDIARY_LOGICAL_UNIT , + "Not a subsidiary logical unit") +SENSE_CODE (NOT_A_CONGLOMERATE_LOGICAL_UNIT , + "Not a conglomerate logical unit") + +SENSE_CODE (LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE , + "Logical block address out of range") +SENSE_CODE (INVALID_ELEMENT_ADDRESS , + "Invalid element address") +SENSE_CODE (INVALID_ADDRESS_FOR_WRITE , + "Invalid address for write") +SENSE_CODE (INVALID_WRITE_CROSSING_LAYER_JUMP , + "Invalid write crossing layer jump") +SENSE_CODE (UNALIGNED_WRITE_COMMAND , + "Unaligned write command") +SENSE_CODE (WRITE_BOUNDARY_VIOLATION , + "Write boundary violation") +SENSE_CODE (ATTEMPT_TO_READ_INVALID_DATA , + "Attempt to read invalid data") +SENSE_CODE (READ_BOUNDARY_VIOLATION , + "Read boundary violation") +SENSE_CODE (MISALIGNED_WRITE_COMMAND , + "Misaligned write command") +SENSE_CODE (ATTEMPT_TO_ACCESS_GAP_ZONE , + "Attempt to access gap zone") + +SENSE_CODE (ILLEGAL_FUNCTION , + "Illegal function (use 20 00, 24 00, or 26 00)") + +SENSE_CODE (INVALID_TOKEN_OP , + "Invalid token operation, cause not reportable") +SENSE_CODE (INVALID_TOKEN_OP_UNSUPPORTED_TOKEN_TYPE , + "Invalid token operation, unsupported token type") +SENSE_CODE (INVALID_TOKEN_OP_REMOTE_TOKEN_USAGE_NOT_SUPPORTED , + "Invalid token operation, remote token usage not supported") +SENSE_CODE (INVALID_TOKEN_OP_REMOTE_ROD_TOKEN_CREATION_NOT_SUPPORTED , + "Invalid token operation, remote rod token creation not supported") +SENSE_CODE (INVALID_TOKEN_OP_TOKEN_UNKNOWN , + "Invalid token operation, token unknown") +SENSE_CODE (INVALID_TOKEN_OP_TOKEN_CORRUPT , + "Invalid token operation, token corrupt") +SENSE_CODE (INVALID_TOKEN_OP_TOKEN_REVOKED , + "Invalid token operation, token revoked") +SENSE_CODE (INVALID_TOKEN_OP_TOKEN_EXPIRED , + "Invalid token operation, token expired") +SENSE_CODE (INVALID_TOKEN_OP_TOKEN_CANCELLED , + "Invalid token operation, token cancelled") +SENSE_CODE (INVALID_TOKEN_OP_TOKEN_DELETED , + "Invalid token operation, token deleted") +SENSE_CODE (INVALID_TOKEN_OP_INVALID_TOKEN_LENGTH , + "Invalid token operation, invalid token length") + +SENSE_CODE (INVALID_FIELD_IN_CDB , + "Invalid field in cdb") +SENSE_CODE (CDB_DECRYPTION_ERROR , + "CDB decryption error") +SENSE_CODE (0x2402 , + "Obsolete") +SENSE_CODE (0x2403 , + "Obsolete") +SENSE_CODE (SECURITY_AUDIT_VALUE_FROZEN , + "Security audit value frozen") +SENSE_CODE (SECURITY_WORKING_KEY_FROZEN , + "Security working key frozen") +SENSE_CODE (NONCE_NOT_UNIQUE , + "Nonce not unique") +SENSE_CODE (NONCE_TIMESTAMP_OUT_OF_RANGE , + "Nonce timestamp out of range") +SENSE_CODE (INVALID_XCDB , + "Invalid XCDB") +SENSE_CODE (INVALID_FAST_FORMAT , + "Invalid fast format") + +SENSE_CODE (LU_NOT_SUPPORTED , + "Logical unit not supported") + +SENSE_CODE (INVALID_FIELD_IN_PARAMETER_LIST , + "Invalid field in parameter list") +SENSE_CODE (PARAMETER_NOT_SUPPORTED , + "Parameter not supported") +SENSE_CODE (PARAMETER_VALUE_INVALID , + "Parameter value invalid") +SENSE_CODE (THRESHOLD_PARAMETERS_NOT_SUPPORTED , + "Threshold parameters not supported") +SENSE_CODE (INVALID_RELEASE_OF_PERSISTENT_RESERVATION , + "Invalid release of persistent reservation") +SENSE_CODE (DATA_DECRYPTION_ERROR , + "Data decryption error") +SENSE_CODE (TOO_MANY_TARGET_DESCRIPTORS , + "Too many target descriptors") +SENSE_CODE (UNSUPPORTED_TARGET_DESCRIPTOR_TYPE_CODE , + "Unsupported target descriptor type code") +SENSE_CODE (TOO_MANY_SEGMENT_DESCRIPTORS , + "Too many segment descriptors") +SENSE_CODE (UNSUPPORTED_SEGMENT_DESCRIPTOR_TYPE_CODE , + "Unsupported segment descriptor type code") +SENSE_CODE (UNEXPECTED_INEXACT_SEGMENT , + "Unexpected inexact segment") +SENSE_CODE (INLINE_DATA_LENGTH_EXCEEDED , + "Inline data length exceeded") +SENSE_CODE (INVALID_OP_FOR_COPY_SOURCE_OR_DESTINATION , + "Invalid operation for copy source or destination") +SENSE_CODE (COPY_SEGMENT_GRANULARITY_VIOLATION , + "Copy segment granularity violation") +SENSE_CODE (INVALID_PARAMETER_WHILE_PORT_IS_ENABLED , + "Invalid parameter while port is enabled") +SENSE_CODE (INVALID_DATA_OUT_BUFFER_INTEGRITY_CHECK_VALUE , + "Invalid data-out buffer integrity check value") +SENSE_CODE (DATA_DECRYPTION_KEY_FAIL_LIMIT_REACHED , + "Data decryption key fail limit reached") +SENSE_CODE (INCOMPLETE_KEY_ASSOCIATED_DATA_SET , + "Incomplete key-associated data set") +SENSE_CODE (VENDOR_SPECIFIC_KEY_REFERENCE_NOT_FOUND , + "Vendor specific key reference not found") +SENSE_CODE (APPLICATION_TAG_MODE_PAGE_IS_INVALID , + "Application tag mode page is invalid") +SENSE_CODE (TAPE_STREAM_MIRRORING_PREVENTED , + "Tape stream mirroring prevented") +SENSE_CODE (COPY_SOURCE_OR_COPY_DESTINATION_NOT_AUTHORIZED , + "Copy source or copy destination not authorized") +SENSE_CODE (FAST_COPY_NOT_POSSIBLE , + "Fast copy not possible") + +SENSE_CODE (WRITE_PROTECTED , + "Write protected") +SENSE_CODE (HW_WRITE_PROTECTED , + "Hardware write protected") +SENSE_CODE (LU_SOFTWARE_WRITE_PROTECTED , + "Logical unit software write protected") +SENSE_CODE (ASSOCIATED_WRITE_PROTECT , + "Associated write protect") +SENSE_CODE (PERSISTENT_WRITE_PROTECT , + "Persistent write protect") +SENSE_CODE (PERMANENT_WRITE_PROTECT , + "Permanent write protect") +SENSE_CODE (CONDITIONAL_WRITE_PROTECT , + "Conditional write protect") +SENSE_CODE (SPACE_ALLOCATION_FAILED_WRITE_PROTECT , + "Space allocation failed write protect") +SENSE_CODE (ZONE_IS_READ_ONLY , + "Zone is read only") + +SENSE_CODE (NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED , + "Not ready to ready change, medium may have changed") +SENSE_CODE (IMPORT_OR_EXPORT_ELEMENT_ACCESSED , + "Import or export element accessed") +SENSE_CODE (FORMAT_LAYER_MAY_HAVE_CHANGED , + "Format-layer may have changed") +SENSE_CODE (IMPORT_EXPORT_ELEMENT_ACCESSED_MEDIUM_CHANGED , + "Import/export element accessed, medium changed") + +SENSE_CODE (POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED , + "Power on, reset, or bus device reset occurred") +SENSE_CODE (POWER_ON_OCCURRED , + "Power on occurred") +SENSE_CODE (SCSI_BUS_RESET_OCCURRED , + "Scsi bus reset occurred") +SENSE_CODE (BUS_DEVICE_RESET_FUNCTION_OCCURRED , + "Bus device reset function occurred") +SENSE_CODE (DEVICE_INTERNAL_RESET , + "Device internal reset") +SENSE_CODE (TRANSCEIVER_MODE_CHANGED_TO_SINGLE_ENDED , + "Transceiver mode changed to single-ended") +SENSE_CODE (TRANSCEIVER_MODE_CHANGED_TO_LVD , + "Transceiver mode changed to lvd") +SENSE_CODE (I_T_NEXUS_LOSS_OCCURRED , + "I_T nexus loss occurred") + +SENSE_CODE (PARAMETERS_CHANGED , + "Parameters changed") +SENSE_CODE (MODE_PARAMETERS_CHANGED , + "Mode parameters changed") +SENSE_CODE (LOG_PARAMETERS_CHANGED , + "Log parameters changed") +SENSE_CODE (RESERVATIONS_PREEMPTED , + "Reservations preempted") +SENSE_CODE (RESERVATIONS_RELEASED , + "Reservations released") +SENSE_CODE (REGISTRATIONS_PREEMPTED , + "Registrations preempted") +SENSE_CODE (ASYMMETRIC_ACCESS_STATE_CHANGED , + "Asymmetric access state changed") +SENSE_CODE (IMPLICIT_ASYMMETRIC_ACCESS_STATE_TRANSITION_FAILED , + "Implicit asymmetric access state transition failed") +SENSE_CODE (PRIORITY_CHANGED , + "Priority changed") +SENSE_CODE (CAPACITY_DATA_HAS_CHANGED , + "Capacity data has changed") +SENSE_CODE (ERROR_HISTORY_I_T_NEXUS_CLEARED , + "Error history I_T nexus cleared") +SENSE_CODE (ERROR_HISTORY_SNAPSHOT_RELEASED , + "Error history snapshot released") +SENSE_CODE (ERROR_RECOVERY_ATTRIBUTES_HAVE_CHANGED , + "Error recovery attributes have changed") +SENSE_CODE (DATA_ENCRYPTION_CAPABILITIES_CHANGED , + "Data encryption capabilities changed") +SENSE_CODE (TIMESTAMP_CHANGED , + "Timestamp changed") +SENSE_CODE (DATA_ENCRYPTION_PARAMS_CHANGED_BY_ANOTHER_I_T_NEXUS , + "Data encryption parameters changed by another i_t nexus") +SENSE_CODE (DATA_ENCRYPTION_PARAMS_CHANGED_BY_VENDOR_SPECIFIC_EVENT , + "Data encryption parameters changed by vendor specific event") +SENSE_CODE (DATA_ENCRYPTION_KEY_INSTANCE_COUNTER_HAS_CHANGED , + "Data encryption key instance counter has changed") +SENSE_CODE (SA_CREATION_CAPABILITIES_DATA_HAS_CHANGED , + "SA creation capabilities data has changed") +SENSE_CODE (MEDIUM_REMOVAL_PREVENTION_PREEMPTED , + "Medium removal prevention preempted") +SENSE_CODE (ZONE_RESET_WRITE_POINTER_RECOMMENDED , + "Zone reset write pointer recommended") + +SENSE_CODE (COPY_CANNOT_EXECUTE_SINCE_HOST_CANNOT_DISCONNECT , + "Copy cannot execute since host cannot disconnect") + +SENSE_CODE (COMMAND_SEQUENCE_ERROR , + "Command sequence error") +SENSE_CODE (TOO_MANY_WINDOWS_SPECIFIED , + "Too many windows specified") +SENSE_CODE (INVALID_COMBINATION_OF_WINDOWS_SPECIFIED , + "Invalid combination of windows specified") +SENSE_CODE (CURRENT_PROGRAM_AREA_IS_NOT_EMPTY , + "Current program area is not empty") +SENSE_CODE (CURRENT_PROGRAM_AREA_IS_EMPTY , + "Current program area is empty") +SENSE_CODE (ILLEGAL_POWER_CONDITION_REQUEST , + "Illegal power condition request") +SENSE_CODE (PERSISTENT_PREVENT_CONFLICT , + "Persistent prevent conflict") +SENSE_CODE (PREVIOUS_BUSY_STATUS , + "Previous busy status") +SENSE_CODE (PREVIOUS_TASK_SET_FULL_STATUS , + "Previous task set full status") +SENSE_CODE (PREVIOUS_RESERVATION_CONFLICT_STATUS , + "Previous reservation conflict status") +SENSE_CODE (PARTITION_OR_COLLECTION_CONTAINS_USER_OBJECTS , + "Partition or collection contains user objects") +SENSE_CODE (NOT_RESERVED , + "Not reserved") +SENSE_CODE (ORWRITE_GENERATION_DOES_NOT_MATCH , + "Orwrite generation does not match") +SENSE_CODE (RESET_WRITE_POINTER_NOT_ALLOWED , + "Reset write pointer not allowed") +SENSE_CODE (ZONE_IS_OFFLINE , + "Zone is offline") +SENSE_CODE (STREAM_NOT_OPEN , + "Stream not open") +SENSE_CODE (UNWRITTEN_DATA_IN_ZONE , + "Unwritten data in zone") +SENSE_CODE (DESCRIPTOR_FORMAT_SENSE_DATA_REQUIRED , + "Descriptor format sense data required") +SENSE_CODE (ZONE_IS_INACTIVE , + "Zone is inactive") +SENSE_CODE (WELL_KNOWN_LU_ACCESS_REQUIRED , + "Well known logical unit access required") + +SENSE_CODE (OVERWRITE_ERROR_ON_UPDATE_IN_PLACE , + "Overwrite error on update in place") + +SENSE_CODE (INSUFFICIENT_TIME_FOR_OPERATION , + "Insufficient time for operation") +SENSE_CODE (COMMAND_TIMEOUT_BEFORE_PROCESSING , + "Command timeout before processing") +SENSE_CODE (COMMAND_TIMEOUT_DURING_PROCESSING , + "Command timeout during processing") +SENSE_CODE (COMMAND_TIMEOUT_DURING_PROCESSING_DUE_TO_ERROR_RECOVERY , + "Command timeout during processing due to error recovery") + +SENSE_CODE (COMMANDS_CLEARED_BY_ANOTHER_INITIATOR , + "Commands cleared by another initiator") +SENSE_CODE (COMMANDS_CLEARED_BY_POWER_LOSS_NOTIFICATION , + "Commands cleared by power loss notification") +SENSE_CODE (COMMANDS_CLEARED_BY_DEVICE_SERVER , + "Commands cleared by device server") +SENSE_CODE (SOME_COMMANDS_CLEARED_BY_QUEUING_LAYER_EVENT , + "Some commands cleared by queuing layer event") + +SENSE_CODE (INCOMPATIBLE_MEDIUM_INSTALLED , + "Incompatible medium installed") +SENSE_CODE (CANNOT_READ_MEDIUM_UNKNOWN_FORMAT , + "Cannot read medium - unknown format") +SENSE_CODE (CANNOT_READ_MEDIUM_INCOMPATIBLE_FORMAT , + "Cannot read medium - incompatible format") +SENSE_CODE (CLEANING_CARTRIDGE_INSTALLED , + "Cleaning cartridge installed") +SENSE_CODE (CANNOT_WRITE_MEDIUM_UNKNOWN_FORMAT , + "Cannot write medium - unknown format") +SENSE_CODE (CANNOT_WRITE_MEDIUM_INCOMPATIBLE_FORMAT , + "Cannot write medium - incompatible format") +SENSE_CODE (CANNOT_FORMAT_MEDIUM_INCOMPATIBLE_MEDIUM , + "Cannot format medium - incompatible medium") +SENSE_CODE (CLEANING_FAILURE , + "Cleaning failure") +SENSE_CODE (CANNOT_WRITE_APPLICATION_CODE_MISMATCH , + "Cannot write - application code mismatch") +SENSE_CODE (CURRENT_SESSION_NOT_FIXATED_FOR_APPEND , + "Current session not fixated for append") +SENSE_CODE (CLEANING_REQUEST_REJECTED , + "Cleaning request rejected") +SENSE_CODE (WORM_MEDIUM_OVERWRITE_ATTEMPTED , + "WORM medium - overwrite attempted") +SENSE_CODE (WORM_MEDIUM_INTEGRITY_CHECK , + "WORM medium - integrity check") +SENSE_CODE (MEDIUM_NOT_FORMATTED , + "Medium not formatted") +SENSE_CODE (INCOMPATIBLE_VOLUME_TYPE , + "Incompatible volume type") +SENSE_CODE (INCOMPATIBLE_VOLUME_QUALIFIER , + "Incompatible volume qualifier") +SENSE_CODE (CLEANING_VOLUME_EXPIRED , + "Cleaning volume expired") + +SENSE_CODE (MEDIUM_FORMAT_CORRUPTED , + "Medium format corrupted") +SENSE_CODE (FORMAT_COMMAND_FAILED , + "Format command failed") +SENSE_CODE (ZONED_FORMATTING_FAILED_DUE_TO_SPARE_LINKING , + "Zoned formatting failed due to spare linking") +SENSE_CODE (SANITIZE_COMMAND_FAILED , + "Sanitize command failed") +SENSE_CODE (DEPOPULATION_FAILED , + "Depopulation failed") +SENSE_CODE (DEPOPULATION_RESTORATION_FAILED , + "Depopulation restoration failed") + +SENSE_CODE (NO_DEFECT_SPARE_LOCATION_AVAILABLE , + "No defect spare location available") +SENSE_CODE (DEFECT_LIST_UPDATE_FAILURE , + "Defect list update failure") + +SENSE_CODE (TAPE_LENGTH_ERROR , + "Tape length error") + +SENSE_CODE (ENCLOSURE_FAILURE , + "Enclosure failure") + +SENSE_CODE (ENCLOSURE_SERVICES_FAILURE , + "Enclosure services failure") +SENSE_CODE (UNSUPPORTED_ENCLOSURE_FUNCTION , + "Unsupported enclosure function") +SENSE_CODE (ENCLOSURE_SERVICES_UNAVAILABLE , + "Enclosure services unavailable") +SENSE_CODE (ENCLOSURE_SERVICES_TRANSFER_FAILURE , + "Enclosure services transfer failure") +SENSE_CODE (ENCLOSURE_SERVICES_TRANSFER_REFUSED , + "Enclosure services transfer refused") +SENSE_CODE (ENCLOSURE_SERVICES_CHECKSUM_ERROR , + "Enclosure services checksum error") + +SENSE_CODE (RIBBON_INK_OR_TONER_FAILURE , + "Ribbon, ink, or toner failure") + +SENSE_CODE (ROUNDED_PARAMETER , + "Rounded parameter") + +SENSE_CODE (EVENT_STATUS_NOTIFICATION , + "Event status notification") +SENSE_CODE (ESN_POWER_MANAGEMENT_CLASS_EVENT , + "Esn - power management class event") +SENSE_CODE (ESN_MEDIA_CLASS_EVENT , + "Esn - media class event") +SENSE_CODE (ESN_DEVICE_BUSY_CLASS_EVENT , + "Esn - device busy class event") +SENSE_CODE (THIN_PROVISIONING_SOFT_THRESHOLD_REACHED , + "Thin Provisioning soft threshold reached") +SENSE_CODE (DEPOPULATION_INTERRUPTED , + "Depopulation interrupted") +SENSE_CODE (DEPOPULATION_RESTORATION_INTERRUPTED , + "Depopulation restoration interrupted") + +SENSE_CODE (SAVING_PARAMETERS_NOT_SUPPORTED , + "Saving parameters not supported") + +SENSE_CODE (MEDIUM_NOT_PRESENT , + "Medium not present") +SENSE_CODE (MEDIUM_NOT_PRESENT_TRAY_CLOSED , + "Medium not present - tray closed") +SENSE_CODE (MEDIUM_NOT_PRESENT_TRAY_OPEN , + "Medium not present - tray open") +SENSE_CODE (MEDIUM_NOT_PRESENT_LOADABLE , + "Medium not present - loadable") +SENSE_CODE (MEDIUM_NOT_PRESENT_MEDIUM_AUXILIARY_MEMORY_ACCESSIBLE , + "Medium not present - medium auxiliary memory accessible") + +SENSE_CODE (SEQUENTIAL_POSITIONING_ERROR , + "Sequential positioning error") +SENSE_CODE (TAPE_POSITION_ERROR_AT_BEGINNING_OF_MEDIUM , + "Tape position error at beginning-of-medium") +SENSE_CODE (TAPE_POSITION_ERROR_AT_END_OF_MEDIUM , + "Tape position error at end-of-medium") +SENSE_CODE (TAPE_OR_ELECTRONIC_VERTICAL_FORMS_UNIT_NOT_READY , + "Tape or electronic vertical forms unit not ready") +SENSE_CODE (SLEW_FAILURE , + "Slew failure") +SENSE_CODE (PAPER_JAM , + "Paper jam") +SENSE_CODE (FAILED_TO_SENSE_TOP_OF_FORM , + "Failed to sense top-of-form") +SENSE_CODE (FAILED_TO_SENSE_BOTTOM_OF_FORM , + "Failed to sense bottom-of-form") +SENSE_CODE (REPOSITION_ERROR , + "Reposition error") +SENSE_CODE (READ_PAST_END_OF_MEDIUM , + "Read past end of medium") +SENSE_CODE (READ_PAST_BEGINNING_OF_MEDIUM , + "Read past beginning of medium") +SENSE_CODE (POSITION_PAST_END_OF_MEDIUM , + "Position past end of medium") +SENSE_CODE (POSITION_PAST_BEGINNING_OF_MEDIUM , + "Position past beginning of medium") +SENSE_CODE (MEDIUM_DESTINATION_ELEMENT_FULL , + "Medium destination element full") +SENSE_CODE (MEDIUM_SOURCE_ELEMENT_EMPTY , + "Medium source element empty") +SENSE_CODE (END_OF_MEDIUM_REACHED , + "End of medium reached") +SENSE_CODE (MEDIUM_MAGAZINE_NOT_ACCESSIBLE , + "Medium magazine not accessible") +SENSE_CODE (MEDIUM_MAGAZINE_REMOVED , + "Medium magazine removed") +SENSE_CODE (MEDIUM_MAGAZINE_INSERTED , + "Medium magazine inserted") +SENSE_CODE (MEDIUM_MAGAZINE_LOCKED , + "Medium magazine locked") +SENSE_CODE (MEDIUM_MAGAZINE_UNLOCKED , + "Medium magazine unlocked") +SENSE_CODE (MECHANICAL_POSITIONING_OR_CHANGER_ERROR , + "Mechanical positioning or changer error") +SENSE_CODE (READ_PAST_END_OF_USER_OBJECT , + "Read past end of user object") +SENSE_CODE (ELEMENT_DISABLED , + "Element disabled") +SENSE_CODE (ELEMENT_ENABLED , + "Element enabled") +SENSE_CODE (DATA_TRANSFER_DEVICE_REMOVED , + "Data transfer device removed") +SENSE_CODE (DATA_TRANSFER_DEVICE_INSERTED , + "Data transfer device inserted") +SENSE_CODE (TOO_MANY_LOGICAL_OBJECTS_ON_PARTITION_TO_SUPPORT_OP , + "Too many logical objects on partition to support operation") +SENSE_CODE (ELEMENT_STATIC_INFORMATION_CHANGED , + "Element static information changed") + +SENSE_CODE (INVALID_BITS_IN_IDENTIFY_MESSAGE , + "Invalid bits in identify message") + +SENSE_CODE (LU_HAS_NOT_SELF_CONFIGURED_YET , + "Logical unit has not self-configured yet") +SENSE_CODE (LU_FAILURE , + "Logical unit failure") +SENSE_CODE (TIMEOUT_ON_LOGICAL_UNIT , + "Timeout on logical unit") +SENSE_CODE (LU_FAILED_SELF_TEST , + "Logical unit failed self-test") +SENSE_CODE (LU_UNABLE_TO_UPDATE_SELFTEST_LOG , + "Logical unit unable to update self-test log") + +SENSE_CODE (TARGET_OPERATING_CONDITIONS_HAVE_CHANGED , + "Target operating conditions have changed") +SENSE_CODE (MICROCODE_HAS_BEEN_CHANGED , + "Microcode has been changed") +SENSE_CODE (CHANGED_OPERATING_DEFINITION , + "Changed operating definition") +SENSE_CODE (INQUIRY_DATA_HAS_CHANGED , + "Inquiry data has changed") +SENSE_CODE (COMPONENT_DEVICE_ATTACHED , + "Component device attached") +SENSE_CODE (DEVICE_IDENTIFIER_CHANGED , + "Device identifier changed") +SENSE_CODE (REDUNDANCY_GROUP_CREATED_OR_MODIFIED , + "Redundancy group created or modified") +SENSE_CODE (REDUNDANCY_GROUP_DELETED , + "Redundancy group deleted") +SENSE_CODE (SPARE_CREATED_OR_MODIFIED , + "Spare created or modified") +SENSE_CODE (SPARE_DELETED , + "Spare deleted") +SENSE_CODE (VOLUME_SET_CREATED_OR_MODIFIED , + "Volume set created or modified") +SENSE_CODE (VOLUME_SET_DELETED , + "Volume set deleted") +SENSE_CODE (VOLUME_SET_DEASSIGNED , + "Volume set deassigned") +SENSE_CODE (VOLUME_SET_REASSIGNED , + "Volume set reassigned") +SENSE_CODE (REPORTED_LUNS_DATA_HAS_CHANGED , + "Reported luns data has changed") +SENSE_CODE (ECHO_BUFFER_OVERWRITTEN , + "Echo buffer overwritten") +SENSE_CODE (MEDIUM_LOADABLE , + "Medium loadable") +SENSE_CODE (MEDIUM_AUXILIARY_MEMORY_ACCESSIBLE , + "Medium auxiliary memory accessible") +SENSE_CODE (iSCSI_IP_ADDRESS_ADDED, + "iSCSI IP address added") +SENSE_CODE (iSCSI_IP_ADDRESS_REMOVED, + "iSCSI IP address removed") +SENSE_CODE (iSCSI_IP_ADDRESS_CHANGED, + "iSCSI IP address changed") +SENSE_CODE (INSPECT_REFERRALS_SENSE_DESCRIPTORS , + "Inspect referrals sense descriptors") +SENSE_CODE (MICROCODE_HAS_BEEN_CHANGED_WITHOUT_RESET , + "Microcode has been changed without reset") +SENSE_CODE (ZONE_TRANSITION_TO_FULL , + "Zone transition to full") +SENSE_CODE (BIND_COMPLETED , + "Bind completed") +SENSE_CODE (BIND_REDIRECTED , + "Bind redirected") +SENSE_CODE (SUBSIDIARY_BINDING_CHANGED , +"Subsidiary binding changed" )/* -* SENSE_CODE(0x40NN, "Ram failure") -* SENSE_CODE(0x40NN, "Diagnostic failure on component nn") -* SENSE_CODE(0x41NN, "Data path failure") -* SENSE_CODE(0x42NN, "Power-on or self-test failure") +* SENSE_CODE(0x40NN, "Ram failure") +* SENSE_CODE(0x40NN, "Diagnostic failure on component nn") +* +* SENSE_CODE(0x41NN, "Data path failure") +* +* SENSE_CODE(0x42NN, "Power-on or self-test failure") */ -SENSE_CODE(0x4300, "Message error") - -SENSE_CODE(0x4400, "Internal target failure") -SENSE_CODE(0x4401, "Persistent reservation information lost") -SENSE_CODE(0x4471, "ATA device failed set features") - -SENSE_CODE(0x4500, "Select or reselect failure") - -SENSE_CODE(0x4600, "Unsuccessful soft reset") - -SENSE_CODE(0x4700, "Scsi parity error") -SENSE_CODE(0x4701, "Data phase CRC error detected") -SENSE_CODE(0x4702, "Scsi parity error detected during st data phase") -SENSE_CODE(0x4703, "Information unit iuCRC error detected") -SENSE_CODE(0x4704, "Asynchronous information protection error detected") -SENSE_CODE(0x4705, "Protocol service CRC error") -SENSE_CODE(0x4706, "Phy test function in progress") -SENSE_CODE(0x477f, "Some commands cleared by iSCSI Protocol event") - -SENSE_CODE(0x4800, "Initiator detected error message received") - -SENSE_CODE(0x4900, "Invalid message error") - -SENSE_CODE(0x4A00, "Command phase error") - -SENSE_CODE(0x4B00, "Data phase error") -SENSE_CODE(0x4B01, "Invalid target port transfer tag received") -SENSE_CODE(0x4B02, "Too much write data") -SENSE_CODE(0x4B03, "Ack/nak timeout") -SENSE_CODE(0x4B04, "Nak received") -SENSE_CODE(0x4B05, "Data offset error") -SENSE_CODE(0x4B06, "Initiator response timeout") -SENSE_CODE(0x4B07, "Connection lost") -SENSE_CODE(0x4B08, "Data-in buffer overflow - data buffer size") -SENSE_CODE(0x4B09, "Data-in buffer overflow - data buffer descriptor area") -SENSE_CODE(0x4B0A, "Data-in buffer error") -SENSE_CODE(0x4B0B, "Data-out buffer overflow - data buffer size") -SENSE_CODE(0x4B0C, "Data-out buffer overflow - data buffer descriptor area") -SENSE_CODE(0x4B0D, "Data-out buffer error") -SENSE_CODE(0x4B0E, "PCIe fabric error") -SENSE_CODE(0x4B0F, "PCIe completion timeout") -SENSE_CODE(0x4B10, "PCIe completer abort") -SENSE_CODE(0x4B11, "PCIe poisoned tlp received") -SENSE_CODE(0x4B12, "PCIe eCRC check failed") -SENSE_CODE(0x4B13, "PCIe unsupported request") -SENSE_CODE(0x4B14, "PCIe acs violation") -SENSE_CODE(0x4B15, "PCIe tlp prefix blocked") - -SENSE_CODE (0x4C00 ,"Logical unit failed self-configuration" ) + +SENSE_CODE (MESSAGE_ERROR , + "Message error") + +SENSE_CODE (INTERNAL_TARGET_FAILURE , + "Internal target failure") +SENSE_CODE (PERSISTENT_RESERVATION_INFORMATION_LOST , + "Persistent reservation information lost") +SENSE_CODE (ATA_DEVICE_FAILED_SET_FEATURES , + "ATA device failed set features") + +SENSE_CODE (SELECT_OR_RESELECT_FAILURE , + "Select or reselect failure") + +SENSE_CODE (UNSUCCESSFUL_SOFT_RESET , + "Unsuccessful soft reset") + +SENSE_CODE (SCSI_PARITY_ERROR , + "Scsi parity error") +SENSE_CODE (DATA_PHASE_CRC_ERROR_DETECTED , + "Data phase CRC error detected") +SENSE_CODE (SCSI_PARITY_ERROR_DETECTED_DURING_ST_DATA_PHASE , + "Scsi parity error detected during st data phase") +SENSE_CODE (INFORMATION_UNIT_iuCRC_ERROR_DETECTED, + "Information unit iuCRC error detected") +SENSE_CODE (ASYNCHRONOUS_INFORMATION_PROTECTION_ERROR_DETECTED , + "Asynchronous information protection error detected") +SENSE_CODE (PROTOCOL_SERVICE_CRC_ERROR , + "Protocol service CRC error") +SENSE_CODE (PHY_TEST_FUNCTION_IN_PROGRESS , + "Phy test function in progress") +SENSE_CODE (SOME_COMMANDS_CLEARED_BY_ISCSI_PROTOCOL_EVENT , + "Some commands cleared by iSCSI Protocol event") + +SENSE_CODE (INITIATOR_DETECTED_ERROR_MESSAGE_RECEIVED , + "Initiator detected error message received") + +SENSE_CODE (INVALID_MESSAGE_ERROR , + "Invalid message error") + +SENSE_CODE (COMMAND_PHASE_ERROR , + "Command phase error") + +SENSE_CODE (DATA_PHASE_ERROR , + "Data phase error") +SENSE_CODE (INVALID_TARGET_PORT_TRANSFER_TAG_RECEIVED , + "Invalid target port transfer tag received") +SENSE_CODE (TOO_MUCH_WRITE_DATA , + "Too much write data") +SENSE_CODE (ACK_NAK_TIMEOUT , + "Ack/nak timeout") +SENSE_CODE (NAK_RECEIVED , + "Nak received") +SENSE_CODE (DATA_OFFSET_ERROR , + "Data offset error") +SENSE_CODE (INITIATOR_RESPONSE_TIMEOUT , + "Initiator response timeout") +SENSE_CODE (CONNECTION_LOST , + "Connection lost") +SENSE_CODE (DATA_IN_BUFFER_OVERFLOW_BUFFER_SIZE , + "Data-in buffer overflow - data buffer size") +SENSE_CODE (DATA_IN_BUFFER_OVERFLOW_BUFFER_DESCRIPTOR_AREA , + "Data-in buffer overflow - data buffer descriptor area") +SENSE_CODE (DATA_IN_BUFFER_ERROR , + "Data-in buffer error") +SENSE_CODE (DATA_OUT_BUFFER_OVERFLOW_BUFFER_SIZE , + "Data-out buffer overflow - data buffer size") +SENSE_CODE (DATA_OUT_BUFFER_OVERFLOW_BUFFER_DESCRIPTOR_AREA , + "Data-out buffer overflow - data buffer descriptor area") +SENSE_CODE (DATA_OUT_BUFFER_ERROR , + "Data-out buffer error") +SENSE_CODE (PCIE_FABRIC_ERROR , + "PCIe fabric error") +SENSE_CODE (PCIE_COMPLETION_TIMEOUT , + "PCIe completion timeout") +SENSE_CODE (PCIE_COMPLETER_ABORT , + "PCIe completer abort") +SENSE_CODE (PCIE_POISONED_TLP_RECEIVED , + "PCIe poisoned tlp received") +SENSE_CODE (PCIE_ECRC_CHECK_FAILED , + "PCIe eCRC check failed") +SENSE_CODE (PCIE_UNSUPPORTED_REQUEST , + "PCIe unsupported request") +SENSE_CODE (PCIE_ACS_VIOLATION , + "PCIe acs violation") +SENSE_CODE (PCIE_TLP_PREFIX_BLOCKED , + "PCIe tlp prefix blocked") + +SENSE_CODE (LU_FAILED_SELF_CONFIGURATION , +"Logical unit failed self-configuration" ) +/* -* SENSE_CODE(0x4DNN, "Tagged overlapped commands (nn = queue tag)") +* SENSE_CODE(0x4DNN, "Tagged overlapped commands (nn = queue tag)") */ -SENSE_CODE(0x4E00, "Overlapped commands attempted") - -SENSE_CODE(0x5000, "Write append error") -SENSE_CODE(0x5001, "Write append position error") -SENSE_CODE(0x5002, "Position error related to timing") - -SENSE_CODE(0x5100, "Erase failure") -SENSE_CODE(0x5101, "Erase failure - incomplete erase operation detected") - -SENSE_CODE(0x5200, "Cartridge fault") - -SENSE_CODE(0x5300, "Media load or eject failed") -SENSE_CODE(0x5301, "Unload tape failure") -SENSE_CODE(0x5302, "Medium removal prevented") -SENSE_CODE(0x5303, "Medium removal prevented by data transfer element") -SENSE_CODE(0x5304, "Medium thread or unthread failure") -SENSE_CODE(0x5305, "Volume identifier invalid") -SENSE_CODE(0x5306, "Volume identifier missing") -SENSE_CODE(0x5307, "Duplicate volume identifier") -SENSE_CODE(0x5308, "Element status unknown") -SENSE_CODE(0x5309, "Data transfer device error - load failed") -SENSE_CODE(0x530a, "Data transfer device error - unload failed") -SENSE_CODE(0x530b, "Data transfer device error - unload missing") -SENSE_CODE(0x530c, "Data transfer device error - eject failed") -SENSE_CODE(0x530d, "Data transfer device error - library communication failed") - -SENSE_CODE(0x5400, "Scsi to host system interface failure") - -SENSE_CODE(0x5500, "System resource failure") -SENSE_CODE(0x5501, "System buffer full") -SENSE_CODE(0x5502, "Insufficient reservation resources") -SENSE_CODE(0x5503, "Insufficient resources") -SENSE_CODE(0x5504, "Insufficient registration resources") -SENSE_CODE(0x5505, "Insufficient access control resources") -SENSE_CODE(0x5506, "Auxiliary memory out of space") -SENSE_CODE(0x5507, "Quota error") -SENSE_CODE(0x5508, "Maximum number of supplemental decryption keys exceeded") -SENSE_CODE(0x5509, "Medium auxiliary memory not accessible") -SENSE_CODE(0x550A, "Data currently unavailable") -SENSE_CODE(0x550B, "Insufficient power for operation") -SENSE_CODE(0x550C, "Insufficient resources to create rod") -SENSE_CODE(0x550D, "Insufficient resources to create rod token") -SENSE_CODE(0x550E, "Insufficient zone resources") -SENSE_CODE(0x550F, "Insufficient zone resources to complete write") -SENSE_CODE(0x5510, "Maximum number of streams open") -SENSE_CODE(0x5511, "Insufficient resources to bind") - -SENSE_CODE(0x5700, "Unable to recover table-of-contents") - -SENSE_CODE(0x5800, "Generation does not exist") - -SENSE_CODE(0x5900, "Updated block read") - -SENSE_CODE(0x5A00, "Operator request or state change input") -SENSE_CODE(0x5A01, "Operator medium removal request") -SENSE_CODE(0x5A02, "Operator selected write protect") -SENSE_CODE(0x5A03, "Operator selected write permit") - -SENSE_CODE(0x5B00, "Log exception") -SENSE_CODE(0x5B01, "Threshold condition met") -SENSE_CODE(0x5B02, "Log counter at maximum") -SENSE_CODE(0x5B03, "Log list codes exhausted") - -SENSE_CODE(0x5C00, "Rpl status change") -SENSE_CODE(0x5C01, "Spindles synchronized") -SENSE_CODE(0x5C02, "Spindles not synchronized") - -SENSE_CODE(0x5D00, "Failure prediction threshold exceeded") -SENSE_CODE(0x5D01, "Media failure prediction threshold exceeded") -SENSE_CODE(0x5D02, "Logical unit failure prediction threshold exceeded") -SENSE_CODE(0x5D03, "Spare area exhaustion prediction threshold exceeded") -SENSE_CODE(0x5D10, "Hardware impending failure general hard drive failure") -SENSE_CODE(0x5D11, "Hardware impending failure drive error rate too high") -SENSE_CODE(0x5D12, "Hardware impending failure data error rate too high") -SENSE_CODE(0x5D13, "Hardware impending failure seek error rate too high") -SENSE_CODE(0x5D14, "Hardware impending failure too many block reassigns") -SENSE_CODE(0x5D15, "Hardware impending failure access times too high") -SENSE_CODE(0x5D16, "Hardware impending failure start unit times too high") -SENSE_CODE(0x5D17, "Hardware impending failure channel parametrics") -SENSE_CODE(0x5D18, "Hardware impending failure controller detected") -SENSE_CODE(0x5D19, "Hardware impending failure throughput performance") -SENSE_CODE(0x5D1A, "Hardware impending failure seek time performance") -SENSE_CODE(0x5D1B, "Hardware impending failure spin-up retry count") -SENSE_CODE(0x5D1C, "Hardware impending failure drive calibration retry count") -SENSE_CODE(0x5D20, "Controller impending failure general hard drive failure") -SENSE_CODE(0x5D21, "Controller impending failure drive error rate too high") -SENSE_CODE(0x5D22, "Controller impending failure data error rate too high") -SENSE_CODE(0x5D23, "Controller impending failure seek error rate too high") -SENSE_CODE(0x5D24, "Controller impending failure too many block reassigns") -SENSE_CODE(0x5D25, "Controller impending failure access times too high") -SENSE_CODE(0x5D26, "Controller impending failure start unit times too high") -SENSE_CODE(0x5D27, "Controller impending failure channel parametrics") -SENSE_CODE(0x5D28, "Controller impending failure controller detected") -SENSE_CODE(0x5D29, "Controller impending failure throughput performance") -SENSE_CODE(0x5D2A, "Controller impending failure seek time performance") -SENSE_CODE(0x5D2B, "Controller impending failure spin-up retry count") -SENSE_CODE(0x5D2C, "Controller impending failure drive calibration retry count") -SENSE_CODE(0x5D30, "Data channel impending failure general hard drive failure") -SENSE_CODE(0x5D31, "Data channel impending failure drive error rate too high") -SENSE_CODE(0x5D32, "Data channel impending failure data error rate too high") -SENSE_CODE(0x5D33, "Data channel impending failure seek error rate too high") -SENSE_CODE(0x5D34, "Data channel impending failure too many block reassigns") -SENSE_CODE(0x5D35, "Data channel impending failure access times too high") -SENSE_CODE(0x5D36, "Data channel impending failure start unit times too high") -SENSE_CODE(0x5D37, "Data channel impending failure channel parametrics") -SENSE_CODE(0x5D38, "Data channel impending failure controller detected") -SENSE_CODE(0x5D39, "Data channel impending failure throughput performance") -SENSE_CODE(0x5D3A, "Data channel impending failure seek time performance") -SENSE_CODE(0x5D3B, "Data channel impending failure spin-up retry count") -SENSE_CODE(0x5D3C, "Data channel impending failure drive calibration retry count") -SENSE_CODE(0x5D40, "Servo impending failure general hard drive failure") -SENSE_CODE(0x5D41, "Servo impending failure drive error rate too high") -SENSE_CODE(0x5D42, "Servo impending failure data error rate too high") -SENSE_CODE(0x5D43, "Servo impending failure seek error rate too high") -SENSE_CODE(0x5D44, "Servo impending failure too many block reassigns") -SENSE_CODE(0x5D45, "Servo impending failure access times too high") -SENSE_CODE(0x5D46, "Servo impending failure start unit times too high") -SENSE_CODE(0x5D47, "Servo impending failure channel parametrics") -SENSE_CODE(0x5D48, "Servo impending failure controller detected") -SENSE_CODE(0x5D49, "Servo impending failure throughput performance") -SENSE_CODE(0x5D4A, "Servo impending failure seek time performance") -SENSE_CODE(0x5D4B, "Servo impending failure spin-up retry count") -SENSE_CODE(0x5D4C, "Servo impending failure drive calibration retry count") -SENSE_CODE(0x5D50, "Spindle impending failure general hard drive failure") -SENSE_CODE(0x5D51, "Spindle impending failure drive error rate too high") -SENSE_CODE(0x5D52, "Spindle impending failure data error rate too high") -SENSE_CODE(0x5D53, "Spindle impending failure seek error rate too high") -SENSE_CODE(0x5D54, "Spindle impending failure too many block reassigns") -SENSE_CODE(0x5D55, "Spindle impending failure access times too high") -SENSE_CODE(0x5D56, "Spindle impending failure start unit times too high") -SENSE_CODE(0x5D57, "Spindle impending failure channel parametrics") -SENSE_CODE(0x5D58, "Spindle impending failure controller detected") -SENSE_CODE(0x5D59, "Spindle impending failure throughput performance") -SENSE_CODE(0x5D5A, "Spindle impending failure seek time performance") -SENSE_CODE(0x5D5B, "Spindle impending failure spin-up retry count") -SENSE_CODE(0x5D5C, "Spindle impending failure drive calibration retry count") -SENSE_CODE(0x5D60, "Firmware impending failure general hard drive failure") -SENSE_CODE(0x5D61, "Firmware impending failure drive error rate too high") -SENSE_CODE(0x5D62, "Firmware impending failure data error rate too high") -SENSE_CODE(0x5D63, "Firmware impending failure seek error rate too high") -SENSE_CODE(0x5D64, "Firmware impending failure too many block reassigns") -SENSE_CODE(0x5D65, "Firmware impending failure access times too high") -SENSE_CODE(0x5D66, "Firmware impending failure start unit times too high") -SENSE_CODE(0x5D67, "Firmware impending failure channel parametrics") -SENSE_CODE(0x5D68, "Firmware impending failure controller detected") -SENSE_CODE(0x5D69, "Firmware impending failure throughput performance") -SENSE_CODE(0x5D6A, "Firmware impending failure seek time performance") -SENSE_CODE(0x5D6B, "Firmware impending failure spin-up retry count") -SENSE_CODE(0x5D6C, "Firmware impending failure drive calibration retry count") -SENSE_CODE(0x5D73, "Media impending failure endurance limit met") -SENSE_CODE(0x5DFF, "Failure prediction threshold exceeded (false)") - -SENSE_CODE(0x5E00, "Low power condition on") -SENSE_CODE(0x5E01, "Idle condition activated by timer") -SENSE_CODE(0x5E02, "Standby condition activated by timer") -SENSE_CODE(0x5E03, "Idle condition activated by command") -SENSE_CODE(0x5E04, "Standby condition activated by command") -SENSE_CODE(0x5E05, "Idle_b condition activated by timer") -SENSE_CODE(0x5E06, "Idle_b condition activated by command") -SENSE_CODE(0x5E07, "Idle_c condition activated by timer") -SENSE_CODE(0x5E08, "Idle_c condition activated by command") -SENSE_CODE(0x5E09, "Standby_y condition activated by timer") -SENSE_CODE(0x5E0A, "Standby_y condition activated by command") -SENSE_CODE(0x5E41, "Power state change to active") -SENSE_CODE(0x5E42, "Power state change to idle") -SENSE_CODE(0x5E43, "Power state change to standby") -SENSE_CODE(0x5E45, "Power state change to sleep") -SENSE_CODE(0x5E47, "Power state change to device control") - -SENSE_CODE(0x6000, "Lamp failure") - -SENSE_CODE(0x6100, "Video acquisition error") -SENSE_CODE(0x6101, "Unable to acquire video") -SENSE_CODE(0x6102, "Out of focus") - -SENSE_CODE(0x6200, "Scan head positioning error") - -SENSE_CODE(0x6300, "End of user area encountered on this track") -SENSE_CODE(0x6301, "Packet does not fit in available space") - -SENSE_CODE(0x6400, "Illegal mode for this track") -SENSE_CODE(0x6401, "Invalid packet size") - -SENSE_CODE(0x6500, "Voltage fault") - -SENSE_CODE(0x6600, "Automatic document feeder cover up") -SENSE_CODE(0x6601, "Automatic document feeder lift up") -SENSE_CODE(0x6602, "Document jam in automatic document feeder") -SENSE_CODE(0x6603, "Document miss feed automatic in document feeder") - -SENSE_CODE(0x6700, "Configuration failure") -SENSE_CODE(0x6701, "Configuration of incapable logical units failed") -SENSE_CODE(0x6702, "Add logical unit failed") -SENSE_CODE(0x6703, "Modification of logical unit failed") -SENSE_CODE(0x6704, "Exchange of logical unit failed") -SENSE_CODE(0x6705, "Remove of logical unit failed") -SENSE_CODE(0x6706, "Attachment of logical unit failed") -SENSE_CODE(0x6707, "Creation of logical unit failed") -SENSE_CODE(0x6708, "Assign failure occurred") -SENSE_CODE(0x6709, "Multiply assigned logical unit") -SENSE_CODE(0x670A, "Set target port groups command failed") -SENSE_CODE(0x670B, "ATA device feature not enabled") -SENSE_CODE(0x670C, "Command rejected") -SENSE_CODE(0x670D, "Explicit bind not allowed") - -SENSE_CODE(0x6800, "Logical unit not configured") -SENSE_CODE(0x6801, "Subsidiary logical unit not configured") - -SENSE_CODE(0x6900, "Data loss on logical unit") -SENSE_CODE(0x6901, "Multiple logical unit failures") -SENSE_CODE(0x6902, "Parity/data mismatch") - -SENSE_CODE(0x6A00, "Informational, refer to log") - -SENSE_CODE(0x6B00, "State change has occurred") -SENSE_CODE(0x6B01, "Redundancy level got better") -SENSE_CODE(0x6B02, "Redundancy level got worse") - -SENSE_CODE(0x6C00, "Rebuild failure occurred") - -SENSE_CODE(0x6D00, "Recalculate failure occurred") - -SENSE_CODE(0x6E00, "Command to logical unit failed") - -SENSE_CODE(0x6F00, "Copy protection key exchange failure - authentication failure") -SENSE_CODE(0x6F01, "Copy protection key exchange failure - key not present") -SENSE_CODE(0x6F02, "Copy protection key exchange failure - key not established") -SENSE_CODE(0x6F03, "Read of scrambled sector without authentication") -SENSE_CODE(0x6F04, "Media region code is mismatched to logical unit region") -SENSE_CODE(0x6F05, "Drive region must be permanent/region reset count error") -SENSE_CODE(0x6F06, "Insufficient block count for binding nonce recording") -SENSE_CODE(0x6F07, "Conflict in binding nonce recording") -SENSE_CODE(0x6F08, "Insufficient permission") -SENSE_CODE(0x6F09, "Invalid drive-host pairing server") -SENSE_CODE (0x6F0A ,"Drive-host pairing suspended" ) + +SENSE_CODE (OVERLAPPED_COMMANDS_ATTEMPTED , + "Overlapped commands attempted") + +SENSE_CODE (WRITE_APPEND_ERROR , + "Write append error") +SENSE_CODE (WRITE_APPEND_POSITION_ERROR , + "Write append position error") +SENSE_CODE (POSITION_ERROR_RELATED_TO_TIMING , + "Position error related to timing") + +SENSE_CODE (ERASE_FAILURE , + "Erase failure") +SENSE_CODE (ERASE_FAILURE_INCOMPLETE_ERASE_OP_DETECTED , + "Erase failure - incomplete erase operation detected") + +SENSE_CODE (CARTRIDGE_FAULT , + "Cartridge fault") + +SENSE_CODE (MEDIA_LOAD_OR_EJECT_FAILED , + "Media load or eject failed") +SENSE_CODE (UNLOAD_TAPE_FAILURE , + "Unload tape failure") +SENSE_CODE (MEDIUM_REMOVAL_PREVENTED , + "Medium removal prevented") +SENSE_CODE (MEDIUM_REMOVAL_PREVENTED_BY_DATA_TRANSFER_ELEMENT , + "Medium removal prevented by data transfer element") +SENSE_CODE (MEDIUM_THREAD_OR_UNTHREAD_FAILURE , + "Medium thread or unthread failure") +SENSE_CODE (VOLUME_IDENTIFIER_INVALID , + "Volume identifier invalid") +SENSE_CODE (VOLUME_IDENTIFIER_MISSING , + "Volume identifier missing") +SENSE_CODE (DUPLICATE_VOLUME_IDENTIFIER , + "Duplicate volume identifier") +SENSE_CODE (ELEMENT_STATUS_UNKNOWN , + "Element status unknown") +SENSE_CODE (DATA_TRANSFER_DEVICE_ERR_LOAD_FAILED , + "Data transfer device error - load failed") +SENSE_CODE (DATA_TRANSFER_DEVICE_ERR_UNLOAD_FAILED , + "Data transfer device error - unload failed") +SENSE_CODE (DATA_TRANSFER_DEVICE_ERR_UNLOAD_MISSING , + "Data transfer device error - unload missing") +SENSE_CODE (DATA_TRANSFER_DEVICE_ERR_EJECT_FAILED , + "Data transfer device error - eject failed") +SENSE_CODE (DATA_TRANSFER_DEVICE_ERR_LIBRARY_COMMUNICATION_FAILED , + "Data transfer device error - library communication failed") + +SENSE_CODE (SCSI_TO_HOST_SYSTEM_INTERFACE_FAILURE , + "Scsi to host system interface failure") + +SENSE_CODE (SYSTEM_RESOURCE_FAILURE , + "System resource failure") +SENSE_CODE (SYSTEM_BUFFER_FULL , + "System buffer full") +SENSE_CODE (INSUFFICIENT_RESERVATION_RESOURCES , + "Insufficient reservation resources") +SENSE_CODE (INSUFFICIENT_RESOURCES , + "Insufficient resources") +SENSE_CODE (INSUFFICIENT_REGISTRATION_RESOURCES , + "Insufficient registration resources") +SENSE_CODE (INSUFFICIENT_ACCESS_CONTROL_RESOURCES , + "Insufficient access control resources") +SENSE_CODE (AUXILIARY_MEMORY_OUT_OF_SPACE , + "Auxiliary memory out of space") +SENSE_CODE (QUOTA_ERROR , + "Quota error") +SENSE_CODE (MAXIMUM_NUMBER_OF_SUPPLEMENTAL_DECRYPTION_KEYS_EXCEEDED , + "Maximum number of supplemental decryption keys exceeded") +SENSE_CODE (MEDIUM_AUXILIARY_MEMORY_NOT_ACCESSIBLE , + "Medium auxiliary memory not accessible") +SENSE_CODE (DATA_CURRENTLY_UNAVAILABLE , + "Data currently unavailable") +SENSE_CODE (INSUFFICIENT_POWER_FOR_OPERATION , + "Insufficient power for operation") +SENSE_CODE (INSUFFICIENT_RESOURCES_TO_CREATE_ROD , + "Insufficient resources to create rod") +SENSE_CODE (INSUFFICIENT_RESOURCES_TO_CREATE_ROD_TOKEN , + "Insufficient resources to create rod token") +SENSE_CODE (INSUFFICIENT_ZONE_RESOURCES , + "Insufficient zone resources") +SENSE_CODE (INSUFFICIENT_ZONE_RESOURCES_TO_COMPLETE_WRITE , + "Insufficient zone resources to complete write") +SENSE_CODE (MAXIMUM_NUMBER_OF_STREAMS_OPEN , + "Maximum number of streams open") +SENSE_CODE (INSUFFICIENT_RESOURCES_TO_BIND , + "Insufficient resources to bind") + +SENSE_CODE (UNABLE_TO_RECOVER_TABLE_OF_CONTENTS , + "Unable to recover table-of-contents") + +SENSE_CODE (GENERATION_DOES_NOT_EXIST , + "Generation does not exist") + +SENSE_CODE (UPDATED_BLOCK_READ , + "Updated block read") + +SENSE_CODE (OPERATOR_REQUEST_OR_STATE_CHANGE_INPUT , + "Operator request or state change input") +SENSE_CODE (OPERATOR_MEDIUM_REMOVAL_REQUEST , + "Operator medium removal request") +SENSE_CODE (OPERATOR_SELECTED_WRITE_PROTECT , + "Operator selected write protect") +SENSE_CODE (OPERATOR_SELECTED_WRITE_PERMIT , + "Operator selected write permit") + +SENSE_CODE (LOG_EXCEPTION , + "Log exception") +SENSE_CODE (THRESHOLD_CONDITION_MET , + "Threshold condition met") +SENSE_CODE (LOG_COUNTER_AT_MAXIMUM , + "Log counter at maximum") +SENSE_CODE (LOG_LIST_CODES_EXHAUSTED , + "Log list codes exhausted") + +SENSE_CODE (RPL_STATUS_CHANGE , + "Rpl status change") +SENSE_CODE (SPINDLES_SYNCHRONIZED , + "Spindles synchronized") +SENSE_CODE (SPINDLES_NOT_SYNCHRONIZED , + "Spindles not synchronized") + +SENSE_CODE (FAILURE_PREDICTION_THRESHOLD_EXCEEDED , + "Failure prediction threshold exceeded") +SENSE_CODE (MEDIA_FAILURE_PREDICTION_THRESHOLD_EXCEEDED , + "Media failure prediction threshold exceeded") +SENSE_CODE (LU_FAILURE_PREDICTION_THRESHOLD_EXCEEDED , + "Logical unit failure prediction threshold exceeded") +SENSE_CODE (SPARE_AREA_EXHAUSTION_PREDICTION_THRESHOLD_EXCEEDED , + "Spare area exhaustion prediction threshold exceeded") +SENSE_CODE (HW_IMPENDING_FAILURE_GENERAL_HARD_DRIVE_FAILURE , + "Hardware impending failure general hard drive failure") +SENSE_CODE (HW_IMPENDING_FAILURE_DRIVE_ERROR_RATE_TOO_HIGH , + "Hardware impending failure drive error rate too high") +SENSE_CODE (HW_IMPENDING_FAILURE_DATA_ERROR_RATE_TOO_HIGH , + "Hardware impending failure data error rate too high") +SENSE_CODE (HW_IMPENDING_FAILURE_SEEK_ERROR_RATE_TOO_HIGH , + "Hardware impending failure seek error rate too high") +SENSE_CODE (HW_IMPENDING_FAILURE_TOO_MANY_BLOCK_REASSIGNS , + "Hardware impending failure too many block reassigns") +SENSE_CODE (HW_IMPENDING_FAILURE_ACCESS_TIMES_TOO_HIGH , + "Hardware impending failure access times too high") +SENSE_CODE (HW_IMPENDING_FAILURE_START_UNIT_TIMES_TOO_HIGH , + "Hardware impending failure start unit times too high") +SENSE_CODE (HW_IMPENDING_FAILURE_CHANNEL_PARAMETRICS , + "Hardware impending failure channel parametrics") +SENSE_CODE (HW_IMPENDING_FAILURE_CONTROLLER_DETECTED , + "Hardware impending failure controller detected") +SENSE_CODE (HW_IMPENDING_FAILURE_THROUGHPUT_PERFORMANCE , + "Hardware impending failure throughput performance") +SENSE_CODE (HW_IMPENDING_FAILURE_SEEK_TIME_PERFORMANCE , + "Hardware impending failure seek time performance") +SENSE_CODE (HW_IMPENDING_FAILURE_SPINUP_RETRY_COUNT , + "Hardware impending failure spin-up retry count") +SENSE_CODE (HW_IMPENDING_FAILURE_DRIVE_CALIBRATION_RETRY_COUNT , + "Hardware impending failure drive calibration retry count") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_GENERAL_HARD_DRIVE_FAILURE , + "Controller impending failure general hard drive failure") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_DRIVE_ERROR_RATE_TOO_HIGH , + "Controller impending failure drive error rate too high") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_DATA_ERROR_RATE_TOO_HIGH , + "Controller impending failure data error rate too high") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_SEEK_ERROR_RATE_TOO_HIGH , + "Controller impending failure seek error rate too high") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_TOO_MANY_BLOCK_REASSIGNS , + "Controller impending failure too many block reassigns") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_ACCESS_TIMES_TOO_HIGH , + "Controller impending failure access times too high") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_START_UNIT_TIMES_TOO_HIGH , + "Controller impending failure start unit times too high") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_CHANNEL_PARAMETRICS , + "Controller impending failure channel parametrics") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_CONTROLLER_DETECTED , + "Controller impending failure controller detected") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_THROUGHPUT_PERFORMANCE , + "Controller impending failure throughput performance") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_SEEK_TIME_PERFORMANCE , + "Controller impending failure seek time performance") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_SPINUP_RETRY_COUNT , + "Controller impending failure spin-up retry count") +SENSE_CODE (CONTROLLER_IMPENDING_FAILURE_DRIVE_CALIBRATION_RETRY_COUNT , + "Controller impending failure drive calibration retry count") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_GENERAL_HARD_DRIVE_FAILURE , + "Data channel impending failure general hard drive failure") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_DRIVE_ERROR_RATE_TOO_HIGH , + "Data channel impending failure drive error rate too high") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_DATA_ERROR_RATE_TOO_HIGH , + "Data channel impending failure data error rate too high") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_SEEK_ERROR_RATE_TOO_HIGH , + "Data channel impending failure seek error rate too high") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_TOO_MANY_BLOCK_REASSIGNS , + "Data channel impending failure too many block reassigns") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_ACCESS_TIMES_TOO_HIGH , + "Data channel impending failure access times too high") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_START_UNIT_TIMES_TOO_HIGH , + "Data channel impending failure start unit times too high") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_CHANNEL_PARAMETRICS , + "Data channel impending failure channel parametrics") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_CONTROLLER_DETECTED , + "Data channel impending failure controller detected") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_THROUGHPUT_PERFORMANCE , + "Data channel impending failure throughput performance") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_SEEK_TIME_PERFORMANCE , + "Data channel impending failure seek time performance") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_SPINUP_RETRY_COUNT , + "Data channel impending failure spin-up retry count") +SENSE_CODE (DATA_CHANNEL_IMPENDING_FAILURE_DRIVE_CALIBRATION_RETRY_COUNT , + "Data channel impending failure drive calibration retry count") +SENSE_CODE (SERVO_IMPENDING_FAILURE_GENERAL_HARD_DRIVE_FAILURE , + "Servo impending failure general hard drive failure") +SENSE_CODE (SERVO_IMPENDING_FAILURE_DRIVE_ERROR_RATE_TOO_HIGH , + "Servo impending failure drive error rate too high") +SENSE_CODE (SERVO_IMPENDING_FAILURE_DATA_ERROR_RATE_TOO_HIGH , + "Servo impending failure data error rate too high") +SENSE_CODE (SERVO_IMPENDING_FAILURE_SEEK_ERROR_RATE_TOO_HIGH , + "Servo impending failure seek error rate too high") +SENSE_CODE (SERVO_IMPENDING_FAILURE_TOO_MANY_BLOCK_REASSIGNS , + "Servo impending failure too many block reassigns") +SENSE_CODE (SERVO_IMPENDING_FAILURE_ACCESS_TIMES_TOO_HIGH , + "Servo impending failure access times too high") +SENSE_CODE (SERVO_IMPENDING_FAILURE_START_UNIT_TIMES_TOO_HIGH , + "Servo impending failure start unit times too high") +SENSE_CODE (SERVO_IMPENDING_FAILURE_CHANNEL_PARAMETRICS , + "Servo impending failure channel parametrics") +SENSE_CODE (SERVO_IMPENDING_FAILURE_CONTROLLER_DETECTED , + "Servo impending failure controller detected") +SENSE_CODE (SERVO_IMPENDING_FAILURE_THROUGHPUT_PERFORMANCE , + "Servo impending failure throughput performance") +SENSE_CODE (SERVO_IMPENDING_FAILURE_SEEK_TIME_PERFORMANCE , + "Servo impending failure seek time performance") +SENSE_CODE (SERVO_IMPENDING_FAILURE_SPINUP_RETRY_COUNT , + "Servo impending failure spin-up retry count") +SENSE_CODE (SERVO_IMPENDING_FAILURE_DRIVE_CALIBRATION_RETRY_COUNT , + "Servo impending failure drive calibration retry count") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_GENERAL_HARD_DRIVE_FAILURE , + "Spindle impending failure general hard drive failure") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_DRIVE_ERROR_RATE_TOO_HIGH , + "Spindle impending failure drive error rate too high") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_DATA_ERROR_RATE_TOO_HIGH , + "Spindle impending failure data error rate too high") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_SEEK_ERROR_RATE_TOO_HIGH , + "Spindle impending failure seek error rate too high") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_TOO_MANY_BLOCK_REASSIGNS , + "Spindle impending failure too many block reassigns") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_ACCESS_TIMES_TOO_HIGH , + "Spindle impending failure access times too high") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_START_UNIT_TIMES_TOO_HIGH , + "Spindle impending failure start unit times too high") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_CHANNEL_PARAMETRICS , + "Spindle impending failure channel parametrics") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_CONTROLLER_DETECTED , + "Spindle impending failure controller detected") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_THROUGHPUT_PERFORMANCE , + "Spindle impending failure throughput performance") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_SEEK_TIME_PERFORMANCE , + "Spindle impending failure seek time performance") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_SPINUP_RETRY_COUNT , + "Spindle impending failure spin-up retry count") +SENSE_CODE (SPINDLE_IMPENDING_FAILURE_DRIVE_CALIBRATION_RETRY_COUNT , + "Spindle impending failure drive calibration retry count") +SENSE_CODE (FW_IMPENDING_FAILURE_GENERAL_HARD_DRIVE_FAILURE , + "Firmware impending failure general hard drive failure") +SENSE_CODE (FW_IMPENDING_FAILURE_DRIVE_ERROR_RATE_TOO_HIGH , + "Firmware impending failure drive error rate too high") +SENSE_CODE (FW_IMPENDING_FAILURE_DATA_ERROR_RATE_TOO_HIGH , + "Firmware impending failure data error rate too high") +SENSE_CODE (FW_IMPENDING_FAILURE_SEEK_ERROR_RATE_TOO_HIGH , + "Firmware impending failure seek error rate too high") +SENSE_CODE (FW_IMPENDING_FAILURE_TOO_MANY_BLOCK_REASSIGNS , + "Firmware impending failure too many block reassigns") +SENSE_CODE (FW_IMPENDING_FAILURE_ACCESS_TIMES_TOO_HIGH , + "Firmware impending failure access times too high") +SENSE_CODE (FW_IMPENDING_FAILURE_START_UNIT_TIMES_TOO_HIGH , + "Firmware impending failure start unit times too high") +SENSE_CODE (FW_IMPENDING_FAILURE_CHANNEL_PARAMETRICS , + "Firmware impending failure channel parametrics") +SENSE_CODE (FW_IMPENDING_FAILURE_CONTROLLER_DETECTED , + "Firmware impending failure controller detected") +SENSE_CODE (FW_IMPENDING_FAILURE_THROUGHPUT_PERFORMANCE , + "Firmware impending failure throughput performance") +SENSE_CODE (FW_IMPENDING_FAILURE_SEEK_TIME_PERFORMANCE , + "Firmware impending failure seek time performance") +SENSE_CODE (FW_IMPENDING_FAILURE_SPINUP_RETRY_COUNT , + "Firmware impending failure spin-up retry count") +SENSE_CODE (FW_IMPENDING_FAILURE_DRIVE_CALIBRATION_RETRY_COUNT , + "Firmware impending failure drive calibration retry count") +SENSE_CODE (MEDIA_IMPENDING_FAILURE_ENDURANCE_LIMIT_MET , + "Media impending failure endurance limit met") +SENSE_CODE (FAILURE_PREDICTION_THRESHOLD_EXCEEDED_FALSE , + "Failure prediction threshold exceeded (false)") + +SENSE_CODE (LOW_POWER_CONDITION_ON , + "Low power condition on") +SENSE_CODE (IDLE_CONDITION_ACTIVATED_BY_TIMER , + "Idle condition activated by timer") +SENSE_CODE (STANDBY_CONDITION_ACTIVATED_BY_TIMER , + "Standby condition activated by timer") +SENSE_CODE (IDLE_CONDITION_ACTIVATED_BY_COMMAND , + "Idle condition activated by command") +SENSE_CODE (STANDBY_CONDITION_ACTIVATED_BY_COMMAND , + "Standby condition activated by command") +SENSE_CODE (IDLE_B_CONDITION_ACTIVATED_BY_TIMER , + "Idle_b condition activated by timer") +SENSE_CODE (IDLE_B_CONDITION_ACTIVATED_BY_COMMAND , + "Idle_b condition activated by command") +SENSE_CODE (IDLE_C_CONDITION_ACTIVATED_BY_TIMER , + "Idle_c condition activated by timer") +SENSE_CODE (IDLE_C_CONDITION_ACTIVATED_BY_COMMAND , + "Idle_c condition activated by command") +SENSE_CODE (STANDBY_Y_CONDITION_ACTIVATED_BY_TIMER , + "Standby_y condition activated by timer") +SENSE_CODE (STANDBY_Y_CONDITION_ACTIVATED_BY_COMMAND , + "Standby_y condition activated by command") +SENSE_CODE (POWER_STATE_CHANGE_TO_ACTIVE , + "Power state change to active") +SENSE_CODE (POWER_STATE_CHANGE_TO_IDLE , + "Power state change to idle") +SENSE_CODE (POWER_STATE_CHANGE_TO_STANDBY , + "Power state change to standby") +SENSE_CODE (POWER_STATE_CHANGE_TO_SLEEP , + "Power state change to sleep") +SENSE_CODE (POWER_STATE_CHANGE_TO_DEVICE_CONTROL , + "Power state change to device control") + +SENSE_CODE (LAMP_FAILURE , + "Lamp failure") + +SENSE_CODE (VIDEO_ACQUISITION_ERROR , + "Video acquisition error") +SENSE_CODE (UNABLE_TO_ACQUIRE_VIDEO , + "Unable to acquire video") +SENSE_CODE (OUT_OF_FOCUS , + "Out of focus") + +SENSE_CODE (SCAN_HEAD_POSITIONING_ERROR , + "Scan head positioning error") + +SENSE_CODE (END_OF_USER_AREA_ENCOUNTERED_ON_THIS_TRACK , + "End of user area encountered on this track") +SENSE_CODE (PACKET_DOES_NOT_FIT_IN_AVAILABLE_SPACE , + "Packet does not fit in available space") + +SENSE_CODE (ILLEGAL_MODE_FOR_THIS_TRACK , + "Illegal mode for this track") +SENSE_CODE (INVALID_PACKET_SIZE , + "Invalid packet size") + +SENSE_CODE (VOLTAGE_FAULT , + "Voltage fault") + +SENSE_CODE (AUTOMATIC_DOCUMENT_FEEDER_COVER_UP , + "Automatic document feeder cover up") +SENSE_CODE (AUTOMATIC_DOCUMENT_FEEDER_LIFT_UP , + "Automatic document feeder lift up") +SENSE_CODE (DOCUMENT_JAM_IN_AUTOMATIC_DOCUMENT_FEEDER , + "Document jam in automatic document feeder") +SENSE_CODE (DOCUMENT_MISS_FEED_AUTOMATIC_IN_DOCUMENT_FEEDER , + "Document miss feed automatic in document feeder") + +SENSE_CODE (CONFIG_FAILURE , + "Configuration failure") +SENSE_CODE (CONFIG_OF_INCAPABLE_LOGICAL_UNITS_FAILED , + "Configuration of incapable logical units failed") +SENSE_CODE (ADD_LU_FAILED , + "Add logical unit failed") +SENSE_CODE (MODIFICATION_OF_LU_FAILED , + "Modification of logical unit failed") +SENSE_CODE (EXCHANGE_OF_LU_FAILED , + "Exchange of logical unit failed") +SENSE_CODE (REMOVE_OF_LU_FAILED , + "Remove of logical unit failed") +SENSE_CODE (ATTACHMENT_OF_LU_FAILED , + "Attachment of logical unit failed") +SENSE_CODE (CREATION_OF_LU_FAILED , + "Creation of logical unit failed") +SENSE_CODE (ASSIGN_FAILURE_OCCURRED , + "Assign failure occurred") +SENSE_CODE (MULTIPLY_ASSIGNED_LOGICAL_UNIT , + "Multiply assigned logical unit") +SENSE_CODE (SET_TARGET_PORT_GROUPS_COMMAND_FAILED , + "Set target port groups command failed") +SENSE_CODE (ATA_DEVICE_FEATURE_NOT_ENABLED , + "ATA device feature not enabled") +SENSE_CODE (COMMAND_REJECTED , + "Command rejected") +SENSE_CODE (EXPLICIT_BIND_NOT_ALLOWED , + "Explicit bind not allowed") + +SENSE_CODE (LU_NOT_CONFIGURED , + "Logical unit not configured") +SENSE_CODE (SUBSIDIARY_LU_NOT_CONFIGURED , + "Subsidiary logical unit not configured") + +SENSE_CODE (DATA_LOSS_ON_LOGICAL_UNIT , + "Data loss on logical unit") +SENSE_CODE (MULTIPLE_LU_FAILURES , + "Multiple logical unit failures") +SENSE_CODE (PARITY_DATA_MISMATCH , + "Parity/data mismatch") + +SENSE_CODE (INFORMATIONAL_REFER_TO_LOG , + "Informational, refer to log") + +SENSE_CODE (STATE_CHANGE_HAS_OCCURRED , + "State change has occurred") +SENSE_CODE (REDUNDANCY_LEVEL_GOT_BETTER , + "Redundancy level got better") +SENSE_CODE (REDUNDANCY_LEVEL_GOT_WORSE , + "Redundancy level got worse") + +SENSE_CODE (REBUILD_FAILURE_OCCURRED , + "Rebuild failure occurred") + +SENSE_CODE (RECALCULATE_FAILURE_OCCURRED , + "Recalculate failure occurred") + +SENSE_CODE (COMMAND_TO_LU_FAILED , + "Command to logical unit failed") + +SENSE_CODE (COPY_PROTECTION_KEY_EXCHANGE_FAILURE_AUTHENTICATION_FAILURE , + "Copy protection key exchange failure - authentication failure") +SENSE_CODE (COPY_PROTECTION_KEY_EXCHANGE_FAILURE_KEY_NOT_PRESENT , + "Copy protection key exchange failure - key not present") +SENSE_CODE (COPY_PROTECTION_KEY_EXCHANGE_FAILURE_KEY_NOT_ESTABLISHED , + "Copy protection key exchange failure - key not established") +SENSE_CODE (READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION , + "Read of scrambled sector without authentication") +SENSE_CODE (MEDIA_REGION_CODE_IS_MISMATCHED_TO_LU_REGION , + "Media region code is mismatched to logical unit region") +SENSE_CODE (DRIVE_REGION_MUST_BE_PERMANENT_REGION_RESET_COUNT_ERROR , + "Drive region must be permanent/region reset count error") +SENSE_CODE (INSUFFICIENT_BLOCK_COUNT_FOR_BINDING_NONCE_RECORDING , + "Insufficient block count for binding nonce recording") +SENSE_CODE (CONFLICT_IN_BINDING_NONCE_RECORDING , + "Conflict in binding nonce recording") +SENSE_CODE (INSUFFICIENT_PERMISSION , + "Insufficient permission") +SENSE_CODE (INVALID_DRIVE_HOST_PAIRING_SERVER , + "Invalid drive-host pairing server") +SENSE_CODE (DRIVE_HOST_PAIRING_SUSPENDED , +"Drive-host pairing suspended" )/* -* SENSE_CODE(0x70NN, "Decompression exception short algorithm id of nn") +* SENSE_CODE(0x70NN, "Decompression exception short algorithm id of nn") */ -SENSE_CODE(0x7100, "Decompression exception long algorithm id") - -SENSE_CODE(0x7200, "Session fixation error") -SENSE_CODE(0x7201, "Session fixation error writing lead-in") -SENSE_CODE(0x7202, "Session fixation error writing lead-out") -SENSE_CODE(0x7203, "Session fixation error - incomplete track in session") -SENSE_CODE(0x7204, "Empty or partially written reserved track") -SENSE_CODE(0x7205, "No more track reservations allowed") -SENSE_CODE(0x7206, "RMZ extension is not allowed") -SENSE_CODE(0x7207, "No more test zone extensions are allowed") - -SENSE_CODE(0x7300, "Cd control error") -SENSE_CODE(0x7301, "Power calibration area almost full") -SENSE_CODE(0x7302, "Power calibration area is full") -SENSE_CODE(0x7303, "Power calibration area error") -SENSE_CODE(0x7304, "Program memory area update failure") -SENSE_CODE(0x7305, "Program memory area is full") -SENSE_CODE(0x7306, "RMA/PMA is almost full") -SENSE_CODE(0x7310, "Current power calibration area almost full") -SENSE_CODE(0x7311, "Current power calibration area is full") -SENSE_CODE(0x7317, "RDZ is full") - -SENSE_CODE(0x7400, "Security error") -SENSE_CODE(0x7401, "Unable to decrypt data") -SENSE_CODE(0x7402, "Unencrypted data encountered while decrypting") -SENSE_CODE(0x7403, "Incorrect data encryption key") -SENSE_CODE(0x7404, "Cryptographic integrity validation failed") -SENSE_CODE(0x7405, "Error decrypting data") -SENSE_CODE(0x7406, "Unknown signature verification key") -SENSE_CODE(0x7407, "Encryption parameters not useable") -SENSE_CODE(0x7408, "Digital signature validation failure") -SENSE_CODE(0x7409, "Encryption mode mismatch on read") -SENSE_CODE(0x740A, "Encrypted block not raw read enabled") -SENSE_CODE(0x740B, "Incorrect Encryption parameters") -SENSE_CODE(0x740C, "Unable to decrypt parameter list") -SENSE_CODE(0x740D, "Encryption algorithm disabled") -SENSE_CODE(0x7410, "SA creation parameter value invalid") -SENSE_CODE(0x7411, "SA creation parameter value rejected") -SENSE_CODE(0x7412, "Invalid SA usage") -SENSE_CODE(0x7421, "Data Encryption configuration prevented") -SENSE_CODE(0x7430, "SA creation parameter not supported") -SENSE_CODE(0x7440, "Authentication failed") -SENSE_CODE(0x7461, "External data encryption key manager access error") -SENSE_CODE(0x7462, "External data encryption key manager error") -SENSE_CODE(0x7463, "External data encryption key not found") -SENSE_CODE(0x7464, "External data encryption request not authorized") -SENSE_CODE(0x746E, "External data encryption control timeout") -SENSE_CODE(0x746F, "External data encryption control error") -SENSE_CODE(0x7471, "Logical unit access not authorized") -SENSE_CODE (0x7479 ,"Security conflict in translated device" ) + +SENSE_CODE (DECOMPRESSION_EXCEPTION_LONG_ALGORITHM_ID , + "Decompression exception long algorithm id") + +SENSE_CODE (SESSION_FIXATION_ERROR , + "Session fixation error") +SENSE_CODE (SESSION_FIXATION_ERROR_WRITING_LEAD_IN , + "Session fixation error writing lead-in") +SENSE_CODE (SESSION_FIXATION_ERROR_WRITING_LEAD_OUT , + "Session fixation error writing lead-out") +SENSE_CODE (SESSION_FIXATION_ERROR_INCOMPLETE_TRACK_IN_SESSION , + "Session fixation error - incomplete track in session") +SENSE_CODE (EMPTY_OR_PARTIALLY_WRITTEN_RESERVED_TRACK , + "Empty or partially written reserved track") +SENSE_CODE (NO_MORE_TRACK_RESERVATIONS_ALLOWED , + "No more track reservations allowed") +SENSE_CODE (RMZ_EXTENSION_IS_NOT_ALLOWED , + "RMZ extension is not allowed") +SENSE_CODE (NO_MORE_TEST_ZONE_EXTENSIONS_ARE_ALLOWED , + "No more test zone extensions are allowed") + +SENSE_CODE (CD_CONTROL_ERROR , + "Cd control error") +SENSE_CODE (POWER_CALIBRATION_AREA_ALMOST_FULL , + "Power calibration area almost full") +SENSE_CODE (POWER_CALIBRATION_AREA_IS_FULL , + "Power calibration area is full") +SENSE_CODE (POWER_CALIBRATION_AREA_ERROR , + "Power calibration area error") +SENSE_CODE (PROGRAM_MEMORY_AREA_UPDATE_FAILURE , + "Program memory area update failure") +SENSE_CODE (PROGRAM_MEMORY_AREA_IS_FULL , + "Program memory area is full") +SENSE_CODE (RMA_PMA_IS_ALMOST_FULL , + "RMA/PMA is almost full") +SENSE_CODE (CURRENT_POWER_CALIBRATION_AREA_ALMOST_FULL , + "Current power calibration area almost full") +SENSE_CODE (CURRENT_POWER_CALIBRATION_AREA_IS_FULL , + "Current power calibration area is full") +SENSE_CODE (RDZ_IS_FULL , + "RDZ is full") + +SENSE_CODE (SECURITY_ERROR , + "Security error") +SENSE_CODE (UNABLE_TO_DECRYPT_DATA , + "Unable to decrypt data") +SENSE_CODE (UNENCRYPTED_DATA_ENCOUNTERED_WHILE_DECRYPTING , + "Unencrypted data encountered while decrypting") +SENSE_CODE (INCORRECT_DATA_ENCRYPTION_KEY , + "Incorrect data encryption key") +SENSE_CODE (CRYPTOGRAPHIC_INTEGRITY_VALIDATION_FAILED , + "Cryptographic integrity validation failed") +SENSE_CODE (ERROR_DECRYPTING_DATA , + "Error decrypting data") +SENSE_CODE (UNKNOWN_SIGNATURE_VERIFICATION_KEY , + "Unknown signature verification key") +SENSE_CODE (ENCRYPTION_PARAMS_NOT_USEABLE , + "Encryption parameters not useable") +SENSE_CODE (DIGITAL_SIGNATURE_VALIDATION_FAILURE , + "Digital signature validation failure") +SENSE_CODE (ENCRYPTION_MODE_MISMATCH_ON_READ , + "Encryption mode mismatch on read") +SENSE_CODE (ENCRYPTED_BLOCK_NOT_RAW_READ_ENABLED , + "Encrypted block not raw read enabled") +SENSE_CODE (INCORRECT_ENCRYPTION_PARAMS , + "Incorrect Encryption parameters") +SENSE_CODE (UNABLE_TO_DECRYPT_PARAMETER_LIST , + "Unable to decrypt parameter list") +SENSE_CODE (ENCRYPTION_ALGORITHM_DISABLED , + "Encryption algorithm disabled") +SENSE_CODE (SA_CREATION_PARAMETER_VALUE_INVALID , + "SA creation parameter value invalid") +SENSE_CODE (SA_CREATION_PARAMETER_VALUE_REJECTED , + "SA creation parameter value rejected") +SENSE_CODE (INVALID_SA_USAGE , + "Invalid SA usage") +SENSE_CODE (DATA_ENCRYPTION_CONFIG_PREVENTED , + "Data Encryption configuration prevented") +SENSE_CODE (SA_CREATION_PARAMETER_NOT_SUPPORTED , + "SA creation parameter not supported") +SENSE_CODE (AUTHENTICATION_FAILED , + "Authentication failed") +SENSE_CODE (EXTERNAL_DATA_ENCRYPTION_KEY_MANAGER_ACCESS_ERROR , + "External data encryption key manager access error") +SENSE_CODE (EXTERNAL_DATA_ENCRYPTION_KEY_MANAGER_ERROR , + "External data encryption key manager error") +SENSE_CODE (EXTERNAL_DATA_ENCRYPTION_KEY_NOT_FOUND , + "External data encryption key not found") +SENSE_CODE (EXTERNAL_DATA_ENCRYPTION_REQUEST_NOT_AUTHORIZED , + "External data encryption request not authorized") +SENSE_CODE (EXTERNAL_DATA_ENCRYPTION_CONTROL_TIMEOUT , + "External data encryption control timeout") +SENSE_CODE (EXTERNAL_DATA_ENCRYPTION_CONTROL_ERROR , + "External data encryption control error") +SENSE_CODE (LU_ACCESS_NOT_AUTHORIZED , + "Logical unit access not authorized") +SENSE_CODE (SECURITY_CONFLICT_IN_TRANSLATED_DEVICE , +"Security conflict in translated device" )
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 02/40] scsi: constants: use defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
The
SENSE_CODE()macro is used for defining the array of structerror_infowhich associates a string description to an additional sense code and its combinations with additional sense code qualifiers. These are however hardcoded values.
Quoted 7 lines
Now that all 16-bits sense codes are defined as macros in
include/scsi/scsi_sense.h, modifysense_codes.hto use the defined sense code macros. While doing this, 2 missing entries are added for the codesOVERLAPPING_ATOMIC_COMMAND_IN_PROGRESSandDEPOPULATION_RESTORATION_INTERRUPTED.Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v2 02/40] scsi: constants: use defined sense codes
In reply to Damien Le MoalLooks good,
Re: [PATCH v2 02/40] scsi: constants: use defined sense codes
In reply to Damien Le MoalQuoted 11 lines · Damien Le Moal
The
SENSE_CODE()macro is used for defining the array of structerror_infowhich associates a string description to an additional sense code and its combinations with additional sense code qualifiers. These are however hardcoded values.Now that all 16-bits sense codes are defined as macros in
include/scsi/scsi_sense.h, modifysense_codes.hto use the defined sense code macros. While doing this, 2 missing entries are added for the codesOVERLAPPING_ATOMIC_COMMAND_IN_PROGRESSandDEPOPULATION_RESTORATION_INTERRUPTED.
Quoted 5 lines
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/sense_codes.h | 2496 +++++++++++++++++++++++------------- 1 file changed, 1631 insertions(+), 865 deletions(-)
Would be nice if we could auto-generate that...
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 3/40 scsi: constants: rename internal struct field names
In reply to Damien Le MoalTo make the code more clear, rename the code12 field of struct error_info to the more natural name "code" and the fields code1, code2_min and code2_max of struct error_info2 to the more explicit asc, ascq_min and ascq_max.
No functional change intended.
--- drivers/scsi/constants.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/scsi/constants.c +12 -10
@@ -292,7 +292,7 @@ bool scsi_opcode_sa_name(int opcode, int service_action, }struct error_info { -unsigned short code12;/* 0x0302 looks better than 0x03,0x02 */ +unsigned short code;/* 0x0302 looks better than 0x03,0x02 */ unsigned short size; };
@@ -318,9 +318,11 @@ static const char *additional_text = ;struct error_info2 { -unsigned char code1, code2_min, code2_max; -const char * str; -const char * fmt; +u8 asc; +u8 ascq_min; +u8 ascq_max; +const char *str; +const char *fmt; }; static const struct error_info2 additional2[] =
@@ -377,20 +379,20 @@ EXPORT_SYMBOL(scsi_sense_key_string);const char *scsi_extd_sense_format (unsigned char asc,unsigned char ascq,const char **fmt) { -int i; -unsigned short code = ((asc <<8 ) | ascq); +u16 code =scsi_sense_code (asc, ascq);unsigned offset =0 ; +int i; *fmt =NULL ;for (i =0 ; i <ARRAY_SIZE (additional); i++) { -if (additional[i].code12 == code) +if (additional[i].code == code)return additional_text + offset; offset += additional[i].size; }for (i =0 ; additional2[i].fmt; i++) { -if (additional2[i].code1 == asc && - ascq >= additional2[i].code2_min && - ascq <= additional2[i].code2_max) { +if (additional2[i].asc == asc && + ascq >= additional2[i].ascq_min && + ascq <= additional2[i].ascq_max) { *fmt = additional2[i].fmt;return additional2[i].str; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 03/40] scsi: constants: rename internal struct field names
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
To make the code more clear, rename the code12 field of struct
error_infoto the more natural name "code" and the fields code1,code2_minandcode2_maxof structerror_info2to the more explicit asc,ascq_minandascq_max.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v2 03/40] scsi: constants: rename internal struct field names
In reply to Damien Le MoalLooks good,
Re: [PATCH v2 03/40] scsi: constants: rename internal struct field names
In reply to Damien Le MoalQuoted 5 lines · Damien Le Moal
To make the code more clear, rename the code12 field of struct
error_infoto the more natural name "code" and the fields code1,code2_minandcode2_maxof structerror_info2to the more explicit asc,ascq_minandascq_max.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/constants.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 4/40 scsi: rename sense field of struct scsi_failure
In reply to Damien Le MoalRename the sense field of struct scsi_failure to sense_key. This makes it clear that this field stores the sense key, and also unifies this structure field names with the names used in struct scsi_sense_hdr.
To be consistent with this change, the macro SCMD_FAILURE_SENSE_ANY is renamed SCMD_FAILURE_SENSE_KEY_ANY.
Of note is that the definition of the array any_sense_failure_defs in scsi_lib_test_any_sense() is modified to change the initialization of the result field to use SCMD_FAILURE_RESULT_ANY and add the .sense_key field initialization to SCMD_FAILURE_SENSE_KEY_ANY to match the test target case.
--- drivers/scsi/ch.c | 2 +- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 ++-- drivers/scsi/device_handler/scsi_dh_rdac.c | 10 ++++----- drivers/scsi/scsi_lib.c | 6 ++--- drivers/scsi/scsi_lib_test.c | 25 +++++++++++---------- drivers/scsi/scsi_scan.c | 8 +++---- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 20 ++++++++--------- drivers/scsi/ses.c | 8 +++---- include/scsi/scsi_device.h | 12 +++++----- 10 files changed, 49 insertions(+), 48 deletions(-)
drivers/scsi/ch.c +1 -1
@@ -191,7 +191,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =3 ,
drivers/scsi/device_handler/scsi_dh_hp_sw.c +2 -2
@@ -84,7 +84,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCMD_FAILURE_NO_LIMIT ,
@@ -138,7 +138,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)* * Switch-over in progress, retry. */ - .sense = NOT_READY, + .sense_key = NOT_READY, .asc = 0x04, .ascq = 0x03, .allowed = HP_SW_RETRIES,
drivers/scsi/device_handler/scsi_dh_rdac.c +5 -5
@@ -514,33 +514,33 @@ static void send_mode_select(struct work_struct *work)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =NO_SENSE , + .sense_key =NO_SENSE , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* LUN Not Ready and is in the Process of Becoming Ready */ { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x04 , .ascq =0x01 , .result =SAM_STAT_CHECK_CONDITION , },/* Command Lock contention */ { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCMD_FAILURE_NO_LIMIT ,
drivers/scsi/scsi_lib.c +3 -3
@@ -243,13 +243,13 @@ static int scsi_check_passthrough(struct scsi_cmnd *scmd,continue ;if (status_byte (failure->result) !=SAM_STAT_CHECK_CONDITION || - failure->sense ==SCMD_FAILURE_SENSE_ANY ) + failure->sense_key ==SCMD_FAILURE_SENSE_KEY_ANY ) goto maybe_retry;if (!scsi_command_normalize_sense (scmd, &sshdr))return 0 ; -if (failure->sense != sshdr.sense_key) +if (failure->sense_key != sshdr.sense_key)continue ;if (failure->asc ==SCMD_FAILURE_ASC_ANY )
@@ -2372,7 +2372,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,struct scsi_sense_hdr my_sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed = retries,
drivers/scsi/scsi_lib_test.c +13 -12
@@ -17,40 +17,40 @@ static void scsi_lib_test_multiple_sense(struct kunit *test) {struct scsi_failure multiple_sense_failure_defs[] = { { - .sense =DATA_PROTECT , + .sense_key =DATA_PROTECT , .asc =0x1 , .ascq =0x1 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x11 , .ascq =0x0 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x11 , .ascq =0x22 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ABORTED_COMMAND , + .sense_key =ABORTED_COMMAND , .asc =0x11 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =HARDWARE_ERROR , + .sense_key =HARDWARE_ERROR , .asc =SCMD_FAILURE_ASC_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =ILLEGAL_REQUEST , + .sense_key =ILLEGAL_REQUEST , .asc =0x91 , .ascq =0x36 , .allowed =SCSI_LIB_TEST_MAX_ALLOWED ,
@@ -116,8 +116,9 @@ static void scsi_lib_test_any_sense(struct kunit *test) {struct scsi_failure any_sense_failure_defs[] = { { - .result =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , + .result =SCMD_FAILURE_RESULT_ANY , }, {} };
@@ -129,7 +130,7 @@ static void scsi_lib_test_any_sense(struct kunit *test) .sense_buffer = sense, }; -/* Match using SCMD_FAILURE_SENSE_ANY */ +/* Match using SCMD_FAILURE_SENSE_KEY_ANY */ failures.failure_definitions = any_sense_failure_defs;scsi_build_sense (&sc,0 ,MEDIUM_ERROR ,0x11 ,0x22 );KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));
@@ -215,14 +216,14 @@ static void scsi_lib_test_total_allowed(struct kunit *test) {struct scsi_failure total_allowed_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
@@ -259,12 +260,12 @@ static void scsi_lib_test_mixed_total(struct kunit *test) {struct scsi_failure mixed_total_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x28 , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .result =SAM_STAT_CHECK_CONDITION , },
drivers/scsi/scsi_scan.c +4 -4
@@ -658,12 +658,12 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,* so anyway. */ { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x28, .result = SAM_STAT_CHECK_CONDITION, }, { - .sense = UNIT_ATTENTION, + .sense_key = UNIT_ATTENTION, .asc = 0x29, .result = SAM_STAT_CHECK_CONDITION, },
@@ -1457,14 +1457,14 @@ static int scsi_report_lun_scan(struct Scsi_Host *shost,struct scsi_device *sdev;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ { - .sense =SCMD_FAILURE_SENSE_ANY , + .sense_key =SCMD_FAILURE_SENSE_KEY_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Retry any other errors not listed above */
drivers/scsi/scsi_transport_spi.c +1 -1
@@ -112,7 +112,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =DV_RETRIES ,
drivers/scsi/sd.c +10 -10
@@ -2033,7 +2033,7 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa,u8 cmd[10 ] = {PERSISTENT_RESERVE_IN , sa };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2145,7 +2145,7 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key,struct scsi_sense_hdr sshdr;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =5 ,
@@ -2494,13 +2494,13 @@ sd_spinup_disk(struct scsi_disk *sdkp)struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .ascq =SCMD_FAILURE_ASCQ_ANY , .result =SAM_STAT_CHECK_CONDITION ,
@@ -2817,18 +2817,18 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,struct scsi_failure failure_defs[] = {/* Do not retry Medium Not Present */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =0x3A , .result =SAM_STAT_CHECK_CONDITION , },/* Device reset might occur several times so retry a lot */ { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .allowed =READ_CAPACITY_RETRIES_ON_RESET , .result =SAM_STAT_CHECK_CONDITION ,
@@ -4159,21 +4159,21 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)struct scsi_failure failure_defs[] = { {/* Power on, reset, or bus device reset occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =0 , .result =SAM_STAT_CHECK_CONDITION , }, {/* Power on occurred */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =1 , .result =SAM_STAT_CHECK_CONDITION , }, {/* SCSI bus reset */ - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =2 , .result =SAM_STAT_CHECK_CONDITION ,
drivers/scsi/ses.c +4 -4
@@ -88,14 +88,14 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,unsigned char recv_page_code;struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
@@ -145,14 +145,14 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code, };struct scsi_failure failure_defs[] = { { - .sense =UNIT_ATTENTION , + .sense_key =UNIT_ATTENTION , .asc =0x29 , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { - .sense =NOT_READY , + .sense_key =NOT_READY , .asc =SCMD_FAILURE_ASC_ANY , .ascq =SCMD_FAILURE_ASCQ_ANY , .allowed =SES_RETRIES ,
include/scsi/scsi_device.h +6 -6
@@ -514,18 +514,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);*/ #define SCMD_FAILURE_STAT_ANY 0xff/* -* The following can be set to the scsi_failure sense, asc and ascq fields to -* match on any sense, ASC, or ASCQ value. +* The following can be set to the scsi_failure sense key, asc and ascq fields +* to match any sense key, ASC, and ASCQ value. */ -#define SCMD_FAILURE_SENSE_ANY 0xff -#define SCMD_FAILURE_ASC_ANY 0xff -#define SCMD_FAILURE_ASCQ_ANY 0xff +#define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_ASC_ANY 0xff +#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */ #define SCMD_FAILURE_NO_LIMIT -1struct scsi_failure {int result; -u8 sense; +u8 sense_key;u8 asc;u8 ascq;/*
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 04/40] scsi: rename sense field of struct scsi_failure
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
Rename the sense field of struct
scsi_failuretosense_key. This makes it clear that this field stores the sense key, and also unifies this structure field names with the names used in structscsi_sense_hdr.To be consistent with this change, the macro
SCMD_FAILURE_SENSE_ANYis renamedSCMD_FAILURE_SENSE_KEY_ANY.
Quoted 7 lines
Of note is that the definition of the array
any_sense_failure_defsinscsi_lib_test_any_sense()is modified to change the initialization of the result field to useSCMD_FAILURE_RESULT_ANYand add the .sense_key field initialization toSCMD_FAILURE_SENSE_KEY_ANYto match the test target case.Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v2 04/40] scsi: rename sense field of struct scsi_failure
In reply to Damien Le MoalQuoted 14 lines · Damien Le Moal
Rename the sense field of struct
scsi_failuretosense_key. This makes it clear that this field stores the sense key, and also unifies this structure field names with the names used in structscsi_sense_hdr.To be consistent with this change, the macro
SCMD_FAILURE_SENSE_ANYis renamedSCMD_FAILURE_SENSE_KEY_ANY.Of note is that the definition of the array
any_sense_failure_defsinscsi_lib_test_any_sense()is modified to change the initialization of the result field to useSCMD_FAILURE_RESULT_ANYand add the .sense_key field initialization toSCMD_FAILURE_SENSE_KEY_ANYto match the test target case.Signed-off-by Damien Le Moal <[email protected]>
Quoted 13 lines
--- drivers/scsi/ch.c | 2 +- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 4 ++-- drivers/scsi/device_handler/scsi_dh_rdac.c | 10 ++++----- drivers/scsi/scsi_lib.c | 6 ++--- drivers/scsi/scsi_lib_test.c | 25 +++++++++++---------- drivers/scsi/scsi_scan.c | 8 +++---- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 20 ++++++++--------- drivers/scsi/ses.c | 8 +++---- include/scsi/scsi_device.h | 12 +++++----- 10 files changed, 49 insertions(+), 48 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 5/40 scsi: prepare for using 16-bits defined sense codes
In reply to Damien Le MoalIn preparation for handling sense codes and their qualifiers as a single 16-bits sense code field, with the values defined as macros in include/scsi/scsi_sense.h, modify the definition of the structures scsi_failure and scsi_sense_hdr to introduce a 16-bits sense_code field as a union with the existing 8-bits asc and ascq fields.
This temporary modification allows accessing either the asc and ascq fields individually, or their combination as the 16-bits sense_code field.
The helper functions scsi_sense_asc(), scsi_sense_ascq() are defined to allow accessing the 8-bits ASC and ASCQ values from the sense_code filed of struct scsi_sense_hdr. The helper functions scsi_failure_asc() and scsi_failure_ascq() provide the same for the sense code field of struct scsi_failure.
The helper functions scsi_set_sense_buffer() and scsi_set_sense() are also added to wrap calls to scsi_build_sense_buffer() and scsi_build_sense() using a 16-bits sense code aregument instead of the 8-bits ASC and ASCQ arguments.
--- include/scsi/scsi_cmnd.h | 7 +++++++ include/scsi/scsi_common.h | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_device.h | 25 +++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-)
include/scsi/scsi_cmnd.h +7 -0
@@ -394,6 +394,13 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq); +static inline void scsi_set_sense (struct scsi_cmnd *scmd,int desc, +u8 key,u16 code) +{ +scsi_build_sense (scmd, desc, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +struct request *scsi_alloc_request (struct request_queue *q,blk_opf_t opf,blk_mq_req_flags_t flags);
include/scsi/scsi_common.h +29 -2
@@ -71,8 +71,18 @@ extern u64 scsilun_to_int(struct scsi_lun *);struct scsi_sense_hdr {/* See SPC-3 section 4.5 */ u8 response_code;/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };u8 byte4;u8 byte5;u8 byte6;
@@ -87,10 +97,27 @@ static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)return (sshdr->response_code &0x70 ) ==0x70 ; } +static inline u8 scsi_sense_asc (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_asc (sshdr->sense_code); +} + +static inline u8 scsi_sense_ascq (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_ascq (sshdr->sense_code); +} +extern bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr);extern void scsi_build_sense_buffer (int desc,u8 *buf,u8 key,u8 asc,u8 ascq); + +static inline void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code) +{ +scsi_build_sense_buffer (desc, buf, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +int scsi_set_sense_information (u8 *buf,int buf_len,u64 info);int scsi_set_sense_field_pointer (u8 *buf,int buf_len,u16 fp,u8 bp,bool cd); extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,
include/scsi/scsi_device.h +23 -2
@@ -518,6 +518,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);* to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff#define SCMD_FAILURE_ASC_ANY 0xff#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */
@@ -526,8 +527,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);struct scsi_failure {int result;u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };/* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.
@@ -537,6 +548,16 @@ struct scsi_failure {s8 retries; }; +static inline u8 scsi_failure_asc (const struct scsi_failure *failure) +{ +return scsi_sense_code_asc (failure->sense_code); +} + +static inline u8 scsi_failure_ascq (const struct scsi_failure *failure) +{ +return scsi_sense_code_ascq (failure->sense_code); +} +struct scsi_failures {/* * If a scsi_failure does not have a retry limit setup this limit will
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 05/40] scsi: prepare for using 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
In preparation for handling sense codes and their qualifiers as a single 16-bits sense code field, with the values defined as macros in
include/scsi/scsi_sense.h, modify the definition of the structuresscsi_failureandscsi_sense_hdrto introduce a 16-bitssense_codefield as a union with the existing 8-bits asc and ascq fields.This temporary modification allows accessing either the asc and ascq fields individually, or their combination as the 16-bits
sense_codefield.The helper functions
scsi_sense_asc(),scsi_sense_ascq()are defined to allow accessing the 8-bits ASC and ASCQ values from thesense_codefiled of structscsi_sense_hdr. The helper functionsscsi_failure_asc()andscsi_failure_ascq()provide the same for the sense code field of structscsi_failure.
Quoted 6 lines
The helper functions
scsi_set_sense_buffer()andscsi_set_sense()are also added to wrap calls toscsi_build_sense_buffer()andscsi_build_sense()using a 16-bits sense code aregument instead of the 8-bits ASC and ASCQ arguments.Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH v2 05/40] scsi: prepare for using 16-bits defined sense codes
In reply to Damien Le MoalLooks good,
Re: [PATCH v2 05/40] scsi: prepare for using 16-bits defined sense codes
In reply to Damien Le MoalQuoted 121 lines · Damien Le Moal
In preparation for handling sense codes and their qualifiers as a single 16-bits sense code field, with the values defined as macros in
include/scsi/scsi_sense.h, modify the definition of the structuresscsi_failureandscsi_sense_hdrto introduce a 16-bitssense_codefield as a union with the existing 8-bits asc and ascq fields.This temporary modification allows accessing either the asc and ascq fields individually, or their combination as the 16-bits
sense_codefield.The helper functions
scsi_sense_asc(),scsi_sense_ascq()are defined to allow accessing the 8-bits ASC and ASCQ values from thesense_codefiled of structscsi_sense_hdr. The helper functionsscsi_failure_asc()andscsi_failure_ascq()provide the same for the sense code field of structscsi_failure.The helper functions
scsi_set_sense_buffer()andscsi_set_sense()are also added to wrap calls toscsi_build_sense_buffer()andscsi_build_sense()using a 16-bits sense code aregument instead of the 8-bits ASC and ASCQ arguments.Signed-off-by Damien Le Moal <[email protected]>--- include/scsi/scsi_cmnd.h | 7 +++++++ include/scsi/scsi_common.h | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_device.h | 25 +++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 4 deletions(-)include/scsi/scsi_cmnd.h +7
-0@@ -394,6 +394,13 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq); +static inline void scsi_set_sense (struct scsi_cmnd *scmd,int desc, +u8 key,u16 code) +{ +scsi_build_sense (scmd, desc, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +struct request *scsi_alloc_request (struct request_queue *q,blk_opf_t opf,blk_mq_req_flags_t flags);include/scsi/scsi_common.h +29
-2@@ -71,8 +71,18 @@ extern u64 scsilun_to_int(struct scsi_lun *);struct scsi_sense_hdr {/* See SPC-3 section 4.5 */ u8 response_code;/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ u8 sense_key; -u8 asc; -u8 ascq; +union { +struct { +#if defined(__BIG_ENDIAN) +u8 asc; +u8 ascq; +#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };u8 byte4;u8 byte5;u8 byte6;@@ -87,10 +97,27 @@ static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)return (sshdr->response_code &0x70 ) ==0x70 ; } +static inline u8 scsi_sense_asc (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_asc (sshdr->sense_code); +} + +static inline u8 scsi_sense_ascq (const struct scsi_sense_hdr *sshdr) +{ +return scsi_sense_code_ascq (sshdr->sense_code); +} +extern bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr);extern void scsi_build_sense_buffer (int desc,u8 *buf,u8 key,u8 asc,u8 ascq); + +static inline void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code) +{ +scsi_build_sense_buffer (desc, buf, key,scsi_sense_code_asc (code), +scsi_sense_code_ascq (code)); +} +int scsi_set_sense_information (u8 *buf,int buf_len,u64 info);int scsi_set_sense_field_pointer (u8 *buf,int buf_len,u16 fp,u8 bp,bool cd); extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,include/scsi/scsi_device.h +6
-2@@ -518,6 +518,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);* to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff#define SCMD_FAILURE_ASC_ANY 0xff#define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */ @@ -526,8 +527,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len); struct scsi_failure { int result; u8 sense_key; -u8 asc; -u8 ascq; + union { + struct { +#if defined(__BIG_ENDIAN) + u8 asc; + u8 ascq;
include/scsi/scsi_device.h extern void scsi_sanitize_inquiry_string(unsigned char *s, int len); · line 544
Quoted 10 lines
include/scsi/scsi_device.h +7
-0+#elif defined(__LITTLE_ENDIAN) +u8 ascq; +u8 asc; +#endif + }; +u16 sense_code; + };/* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.
Why do we have two definitions for the sense code header? Can't we combine it with the definitions in scsi_common.h ?
Quoted 7 lines
include/scsi/scsi_device.h +3
-0@@ -537,6 +548,16 @@ struct scsi_failure {s8 retries; }; +static inline u8 scsi_failure_asc (const struct scsi_failure *failure) +{ +return scsi_sense_code_asc (failure->sense_code);
include/scsi/scsi_device.h struct scsi_failure { · line 563
Quoted 10 lines
include/scsi/scsi_device.h +7
-0+} + +static inline u8 scsi_failure_ascq (const struct scsi_failure *failure) +{ +return scsi_sense_code_ascq (failure->sense_code); +} +struct scsi_failures {/* * If a scsi_failure does not have a retry limit setup this limit will
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerRe: [PATCH v2 05/40] scsi: prepare for using 16-bits defined sense codes
Quoted 30 lines · Hannes Reinecke
Quoted 30 lines
include/scsi/scsi_device.h +1
-0@@ -518,6 +518,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char*s, int len); * to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff #define SCMD_FAILURE_ASC_ANY 0xff #define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */
include/scsi/scsi_device.h +10
-2@@ -526,8 +527,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len); struct scsi_failure { int result; u8 sense_key; - u8 asc; - u8 ascq; + union { + struct { +#if defined(__BIG_ENDIAN) + u8 asc; + u8 ascq; +#elif defined(__LITTLE_ENDIAN) + u8 ascq; + u8 asc; +#endif + };
Quoted 8 lines
Quoted 5 lines
include/scsi/scsi_device.h +2
-0+ u16 sense_code; + }; /** Number of times scsi_execute_cmd will retry the failure. It does * not count for the
total_allowed.Why do we have two definitions for the sense code header? Can't we combine it with the definitions in
scsi_common.h?
This is *not* the sense header. This is the struct used to filter errors for internal SCSI commands issued with scsi_execute_cmd(). And since that function is devlared in scsi_device.h, this struct declaration is here too.
Quoted 21 lines
Quoted 7 lines
include/scsi/scsi_device.h +2
-0@@ -537,6 +548,16 @@ struct scsi_failure { s8 retries; }; +static inline u8 scsi_failure_asc(const struct scsi_failure *failure) +{ + return scsi_sense_code_asc(failure->sense_code);include/scsi/scsi_device.h struct scsi_failure { · line 562
Quoted 10 lines
include/scsi/scsi_device.h +7
-0+} + +static inline u8 scsi_failure_ascq (const struct scsi_failure *failure) +{ + return scsi_sense_code_ascq(failure->sense_code); +} + struct scsi_failures { /** If a scsi_failure does not have a retry limit setup this limit will Cheers,
Hannes
Signature · 2 lines
Damien Le Moal Western Digital Research
Hannes Reinecke
Reviewed-byRe: [PATCH v2 05/40] scsi: prepare for using 16-bits defined sense codes
Quoted 40 lines · Damien Le Moal
Quoted 30 lines · Hannes Reinecke
Quoted 30 lines
include/scsi/scsi_device.h +1
-0@@ -518,6 +518,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char*s, int len); * to match any sense key, ASC, and ASCQ value. */ #define SCMD_FAILURE_SENSE_KEY_ANY 0xff +#define SCMD_FAILURE_SENSE_CODE_ANY 0xffff #define SCMD_FAILURE_ASC_ANY 0xff #define SCMD_FAILURE_ASCQ_ANY 0xff/* Always retry a matching failure. */
include/scsi/scsi_device.h +10
-2@@ -526,8 +527,18 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len); struct scsi_failure { int result; u8 sense_key; - u8 asc; - u8 ascq; + union { + struct { +#if defined(__BIG_ENDIAN) + u8 asc; + u8 ascq; +#elif defined(__LITTLE_ENDIAN) + u8 ascq; + u8 asc; +#endif + };Quoted 8 lines
Quoted 5 lines
include/scsi/scsi_device.h +2
-0+ u16 sense_code; + }; /** Number of times scsi_execute_cmd will retry the failure. It does * not count for the
total_allowed.Why do we have two definitions for the sense code header? Can't we combine it with the definitions in
scsi_common.h?
Quoted 4 lines
This is *not* the sense header. This is the struct used to filter errors for internal SCSI commands issued with
scsi_execute_cmd(). And since that function is devlared inscsi_device.h, this struct declaration is here too.
Oh, I know. I just thought we could combine them.
But if not that's fine, too.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 6/40 scsi: use struct scsi_sense_hdr to log sense keys and codes
In reply to Damien Le MoalInstead of passing the sense key, additional sense code and additional sense code qualifier as separate parameters, change the functions scsi_extd_sense_format(), scsi_format_extd_sense(), and usb_stor_show_sense() to take a pointer to a struct scsi_sense_hdr to access the sense key and sense code with a single argument.
No functional change intended.
--- drivers/scsi/constants.c | 11 +++++------ drivers/scsi/scsi_logging.c | 22 ++++++++++++---------- drivers/usb/storage/debug.c | 12 +++++------- drivers/usb/storage/debug.h | 4 ++-- drivers/usb/storage/transport.c | 2 +- include/scsi/scsi_dbg.h | 6 +++--- 6 files changed, 28 insertions(+), 29 deletions(-)
drivers/scsi/constants.c +5 -6
@@ -377,22 +377,21 @@ EXPORT_SYMBOL(scsi_sense_key_string);* This string may contain a "%x" and should be printed with ascq as arg. */ const char * -scsi_extd_sense_format (unsigned char asc,unsigned char ascq,const char **fmt) +scsi_extd_sense_format (const struct scsi_sense_hdr *sshdr,const char **fmt) { -u16 code =scsi_sense_code (asc, ascq);unsigned offset =0 ;int i; *fmt =NULL ;for (i =0 ; i <ARRAY_SIZE (additional); i++) { -if (additional[i].code == code) +if (additional[i].code == sshdr->sense_code)return additional_text + offset; offset += additional[i].size; }for (i =0 ; additional2[i].fmt; i++) { -if (additional2[i].asc == asc && - ascq >= additional2[i].ascq_min && - ascq <= additional2[i].ascq_max) { +if (additional2[i].asc ==scsi_sense_asc (sshdr) && +scsi_sense_ascq (sshdr) >= additional2[i].ascq_min && +scsi_sense_ascq (sshdr) <= additional2[i].ascq_max) { *fmt = additional2[i].fmt;return additional2[i].str; }
drivers/scsi/scsi_logging.c +12 -10
@@ -238,29 +238,32 @@ EXPORT_SYMBOL(scsi_print_command);static size_t scsi_format_extd_sense (char *buffer,size_t buf_len, -unsigned char asc,unsigned char ascq) +const struct scsi_sense_hdr *sshdr) {size_t off =0 ;const char *extd_sense_fmt =NULL ; -const char *extd_sense_str =scsi_extd_sense_format (asc, ascq, - &extd_sense_fmt); +const char *extd_sense_str = +scsi_extd_sense_format (sshdr, &extd_sense_fmt);if (extd_sense_str) { off =scnprintf (buffer, buf_len,"Add. Sense: %s" , extd_sense_str);if (extd_sense_fmt) off +=scnprintf (buffer + off, buf_len - off, -"(%s%x)" , extd_sense_fmt, ascq); +"(%s%x)" , extd_sense_fmt, +scsi_sense_ascq (sshdr)); }else { -if (asc >=0x80 ) +if (scsi_sense_asc (sshdr) >=0x80 ) off =scnprintf (buffer, buf_len,"<<vendor>>" ); off +=scnprintf (buffer + off, buf_len - off, -"ASC=0x%x " , asc); -if (ascq >=0x80 ) +"ASC=0x%x " , +scsi_sense_asc (sshdr)); +if (scsi_sense_ascq (sshdr) >=0x80 ) off +=scnprintf (buffer + off, buf_len - off,"<<vendor>>" ); off +=scnprintf (buffer + off, buf_len - off, -"ASCQ=0x%x " , ascq); +"ASCQ=0x%x " , +scsi_sense_ascq (sshdr)); }return off; }
@@ -333,8 +336,7 @@ scsi_log_print_sense_hdr(const struct scsi_device *sdev, const char *name,if (!logbuf)return ; off =sdev_format_header (logbuf, logbuf_len, name, tag); - off +=scsi_format_extd_sense (logbuf + off, logbuf_len - off, - sshdr->asc, sshdr->ascq); + off +=scsi_format_extd_sense (logbuf + off, logbuf_len - off, sshdr);dev_printk (KERN_INFO , &sdev->sdev_gendev,"%s" , logbuf);scsi_log_release_buffer (logbuf); }
drivers/usb/storage/debug.c +5 -7
@@ -140,15 +140,12 @@ void usb_stor_show_command(const struct us_data *us, struct scsi_cmnd *srb) (const unsigned char *)srb->cmnd); } -void usb_stor_show_sense (const struct us_data *us, -unsigned char key, -unsigned char asc, -unsigned char ascq) +void usb_stor_show_sense (const struct us_data *us,struct scsi_sense_hdr *sshdr) {const char *what, *keystr, *fmt; - keystr =scsi_sense_key_string (key); - what =scsi_extd_sense_format (asc, ascq, &fmt); + keystr =scsi_sense_key_string (sshdr->sense_key); + what =scsi_extd_sense_format (sshdr, &fmt);if (keystr ==NULL ) keystr ="(Unknown Key)" ;
@@ -156,7 +153,8 @@ void usb_stor_show_sense(const struct us_data *us, what ="(unknown ASC/ASCQ)" ;if (fmt) -usb_stor_dbg (us,"%s: %s (%s%x)\n" , keystr, what, fmt, ascq); +usb_stor_dbg (us,"%s: %s (%s%x)\n" , keystr, what, fmt, +scsi_sense_ascq (sshdr));else usb_stor_dbg (us,"%s: %s\n" , keystr, what); }
drivers/usb/storage/debug.h +2 -2
@@ -31,8 +31,8 @@#ifdef CONFIG_USB_STORAGE_DEBUG void usb_stor_show_command (const struct us_data *us,struct scsi_cmnd *srb); -void usb_stor_show_sense (const struct us_data *us,unsigned char key, -unsigned char asc,unsigned char ascq); +void usb_stor_show_sense (const struct us_data *us, +struct scsi_sense_hdr *sshdr); __printf(2, 3) void usb_stor_dbg(const struct us_data *us,const char *fmt, ...);
drivers/usb/storage/transport.c +1 -1
@@ -805,7 +805,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) sshdr.response_code, sshdr.sense_key, sshdr.asc, sshdr.ascq);#ifdef CONFIG_USB_STORAGE_DEBUG -usb_stor_show_sense (us, sshdr.sense_key, sshdr.asc, sshdr.ascq); +usb_stor_show_sense (us, &sshdr);#endif /* set the result so the higher layers expect this data */
include/scsi/scsi_dbg.h +3 -3
@@ -20,8 +20,8 @@ extern void scsi_print_result(struct scsi_cmnd *, const char *, int);#ifdef CONFIG_SCSI_CONSTANTS extern bool scsi_opcode_sa_name (int ,int ,const char **,const char **);extern const char *scsi_sense_key_string (unsigned char ); -extern const char *scsi_extd_sense_format (unsigned char ,unsigned char , -const char **); +extern const char *scsi_extd_sense_format (const struct scsi_sense_hdr *sshdr, +const char **fmt);extern const char *scsi_mlreturn_string (int );extern const char *scsi_hostbyte_string (int );#else
@@ -57,7 +57,7 @@ scsi_sense_key_string(unsigned char key) }static inline const char * -scsi_extd_sense_format (unsigned char asc,unsigned char ascq,const char **fmt) +scsi_extd_sense_format (const struct scsi_sense_hdr *sshdr,const char **fmt) { *fmt =NULL ;return NULL ;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 06/40] scsi: use struct scsi_sense_hdr to log sense keys and codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Instead of passing the sense key, additional sense code and additional sense code qualifier as separate parameters, change the functions
scsi_extd_sense_format(),scsi_format_extd_sense(), andusb_stor_show_sense()to take a pointer to a structscsi_sense_hdrto access the sense key and sense code with a single argument.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Re: [PATCH v2 06/40] scsi: use struct scsi_sense_hdr to log sense keys and codes
In reply to Damien Le MoalQuoted 9 lines · Damien Le Moal
Instead of passing the sense key, additional sense code and additional sense code qualifier as separate parameters, change the functions
scsi_extd_sense_format(),scsi_format_extd_sense(), andusb_stor_show_sense()to take a pointer to a structscsi_sense_hdrto access the sense key and sense code with a single argument.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Quoted 9 lines
--- drivers/scsi/constants.c | 11 +++++------ drivers/scsi/scsi_logging.c | 22 ++++++++++++---------- drivers/usb/storage/debug.c | 12 +++++------- drivers/usb/storage/debug.h | 4 ++-- drivers/usb/storage/transport.c | 2 +- include/scsi/scsi_dbg.h | 6 +++--- 6 files changed, 28 insertions(+), 29 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 7/40 scsi: core: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the SCSI core code to use the 16-bits sense_code field of struct scsi_sense_hdr and struct scsi_failure and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended, with the exception of a correction of the array any_sense_failure_defs in scsi_lib_test_any_sense() which erroenously sets result to SCMD_FAILURE_RESULT_ANY instead of SAM_STAT_CHECK_CONDITION and does not sets sense_key to SCMD_FAILURE_SENSE_KEY_ANY.
--- drivers/scsi/constants.c | 38 ++++++++-- drivers/scsi/scsi.c | 3 +- drivers/scsi/scsi_common.c | 12 ++-- drivers/scsi/scsi_error.c | 94 ++++++++++++++---------- drivers/scsi/scsi_ioctl.c | 3 +- drivers/scsi/scsi_lib.c | 116 ++++++++++++++++-------------- drivers/scsi/scsi_lib_test.c | 73 +++++++++++-------- drivers/scsi/scsi_scan.c | 14 ++-- drivers/scsi/scsi_transport_spi.c | 10 ++- include/trace/events/scsi.h | 4 +- 10 files changed, 219 insertions(+), 148 deletions(-)
drivers/scsi/constants.c +31 -7
@@ -327,13 +327,37 @@ struct error_info2 {static const struct error_info2 additional2[] = { - {0x40 ,0x00 ,0x7f ,"Ram failure" ,"" }, - {0x40 ,0x80 ,0xff ,"Diagnostic failure on component" ,"" }, - {0x41 ,0x00 ,0xff ,"Data path failure" ,"" }, - {0x42 ,0x00 ,0xff ,"Power-on or self-test failure" ,"" }, - {0x4D ,0x00 ,0xff ,"Tagged overlapped commands" ,"task tag " }, - {0x70 ,0x00 ,0xff ,"Decompression exception" ,"short algorithm id of " }, - {0 ,0 ,0 ,NULL ,NULL } + { +ASC_RAM_FAILURE , +0x00 ,0x7f , +"Ram failure" ,"" + }, + { +ASC_RAM_FAILURE , +0x80 ,0xff , +"Diagnostic failure on component" ,"" + }, + { +ASC_DATA_PATH_FAILURE , +0x00 ,0xff , +"Data path failure" ,"" + }, + { +ASC_POWER_ON_OR_SELFTEST_FAILURE , +0x00 ,0xff , +"Power-on or self-test failure" ,"" + }, + { +ASC_TAGGED_OVERLAPPED_COMMANDS , +0x00 ,0xff , +"Tagged overlapped commands" ,"task tag " + }, + { +ASC_DECOMPRESSION_EXCEPTION_SHORT_ALGORITHM_ID , +0x00 ,0xff , +"Decompression exception" ,"short algorithm id of " + }, + {0 ,0 ,0 ,NULL ,NULL } };/* description of the sense key values */
drivers/scsi/scsi.c +2 -1
@@ -606,7 +606,8 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,return result;if (result &&scsi_sense_valid (&sshdr) && sshdr.sense_key ==ILLEGAL_REQUEST && - (sshdr.asc ==0x20 || sshdr.asc ==0x24 ) && sshdr.ascq ==0x00 ) + (sshdr.sense_code ==INVALID_COMMAND_OP_CODE || + sshdr.sense_code ==INVALID_FIELD_IN_CDB ))return -EINVAL ;if ((buffer[1 ] &3 ) ==3 )/* Command supported */
drivers/scsi/scsi_common.c +8 -4
@@ -191,6 +191,8 @@ EXPORT_SYMBOL(int_to_scsilun);bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr) { +u8 asc =0 , ascq =0 ; +memset (sshdr,0 ,sizeof (struct scsi_sense_hdr ));if (!sense_buffer || !sb_len)
@@ -208,9 +210,9 @@ bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,if (sb_len >1 ) sshdr->sense_key = (sense_buffer[1 ] &0xf );if (sb_len >2 ) - sshdr->asc = sense_buffer[2 ]; + asc = sense_buffer[2 ];if (sb_len >3 ) - sshdr->ascq = sense_buffer[3 ]; + ascq = sense_buffer[3 ];if (sb_len >7 ) sshdr->additional_length = sense_buffer[7 ]; }else {
@@ -222,12 +224,14 @@ bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,if (sb_len >7 ) { sb_len =min (sb_len, sense_buffer[7 ] +8 );if (sb_len >12 ) - sshdr->asc = sense_buffer[12 ]; + asc = sense_buffer[12 ];if (sb_len >13 ) - sshdr->ascq = sense_buffer[13 ]; + ascq = sense_buffer[13 ]; } } + sshdr->sense_code =scsi_sense_code (asc, ascq); +return true; }EXPORT_SYMBOL (scsi_normalize_sense);
drivers/scsi/scsi_error.c +57 -37
214 lines not on this page · raw message
drivers/scsi/scsi_ioctl.c +2 -1
@@ -96,7 +96,8 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,"ioctl_internal_command: " "ILLEGAL REQUEST " "asc=0x%x ascq=0x%x\n" , - sshdr.asc, sshdr.ascq); +scsi_sense_asc (&sshdr), + scsi_sense_ascq(&sshdr));break ;case NOT_READY :/* This happens if there is no disc in drive */ if (sdev->removable)
drivers/scsi/scsi_lib.c +64 -52
182 lines not on this page · raw message
drivers/scsi/scsi_lib_test.c +43 -30
185 lines not on this page · raw message
drivers/scsi/scsi_scan.c +6 -8
@@ -652,19 +652,18 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,int pass, count, result, resid;struct scsi_failure failure_defs[] = {/* -* not-ready to ready transition [asc/ascq=0x28/0x0] or -* power-on, reset [asc/ascq=0x29/0x0], continue. INQUIRY -* should not yield UNIT_ATTENTION but many buggy devices do -* so anyway. +* not-ready to ready transition or power-on, reset, continue. +* INQUIRY should not yield UNIT_ATTENTION but many buggy +* devices do so anyway. */ { .sense_key =UNIT_ATTENTION , - .asc =0x28 , + .sense_code =NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =UNIT_ATTENTION , - .asc =0x29 , + .sense_code =POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED , .result =SAM_STAT_CHECK_CONDITION , }, {
@@ -1458,8 +1457,7 @@ static int scsi_report_lun_scan(struct Scsi_Host *shost,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */
drivers/scsi/scsi_transport_spi.c +4 -6
@@ -113,8 +113,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =DV_RETRIES , .result =SAM_STAT_CHECK_CONDITION , },
@@ -680,10 +679,9 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,if (result || !scsi_device_online (sdev)) {scsi_device_set_state (sdev,SDEV_QUIESCE ); -if (result >0 &&scsi_sense_valid (&sshdr) - && sshdr.sense_key ==ILLEGAL_REQUEST -/* INVALID FIELD IN CDB */ - && sshdr.asc ==0x24 && sshdr.ascq ==0x00 ) +if (result >0 &&scsi_sense_valid (&sshdr) && + sshdr.sense_key ==ILLEGAL_REQUEST && + sshdr.sense_code ==INVALID_FIELD_IN_CDB )/* This would mean that the drive lied * to us about supporting an echo * buffer (unfortunately some Western
include/trace/events/scsi.h +2 -2
@@ -303,8 +303,8 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,if (cmd->sense_buffer &&SCSI_SENSE_VALID (cmd) &&scsi_command_normalize_sense (cmd, &sshdr)) { __entry->sense_key = sshdr.sense_key; - __entry->asc = sshdr.asc; - __entry->ascq = sshdr.ascq; + __entry->asc =scsi_sense_asc (&sshdr); + __entry->ascq =scsi_sense_ascq (&sshdr); }else { __entry->sense_key =0 ; __entry->asc =0 ;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 07/40] scsi: core: use 16-bits defined sense codes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Duplicate KUNIT_EXPECT_EQ execution in scsi_lib_test_multiple_sense --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Duplicate KUNIT_EXPECT_EQ execution in scsi_lib_test_multiple_sense --
commit 7abd3d2760cfc6366060acbd670a7ba4cba45ea2
Author: Damien Le Moal <[email protected]>
scsi: core: use 16-bits defined sense codes
Refactor the SCSI core code to use the 16-bits sense_code field of struct scsi_sense_hdr and struct scsi_failure. This replaces hard-coded additional sense codes with enum values to improve code clarity and testing.
Quoted 3 lines
drivers/scsi/scsi_lib_test.c +0
-0
[ ... ]
Quoted 1 line
drivers/scsi/scsi_lib_test.c +0
-0@@ -72,32 +73,37 @@ static void scsi_lib_test_multiple_sense(struct kunit *test)
[ ... ]
drivers/scsi/scsi_lib_test.c static void scsi_lib_test_multiple_sense(struct kunit *test) · line 99
Quoted 6 lines
drivers/scsi/scsi_lib_test.c +3
-1/* Match using SCMD_FAILURE_ASC_ANY */ -scsi_build_sense (&sc,0 ,HARDWARE_ERROR ,0x11 ,0x22 ); +scsi_set_sense (&sc,0 ,HARDWARE_ERROR , +scsi_sense_code (ASC_UNRECOVERED_READ_ERROR ,0x22 )); +KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));
[Severity: Low]
Is this duplicated KUNIT_EXPECT_EQ call intentional?
Since scsi_check_passthrough() modifies internal state by incrementing the retry counter in the failures array, calling it twice for the exact same mock failure consumes two retries instead of one.
The test still passes because the retry limit isn't exceeded, but does this unintentionally mask future issues by using up the retry budget?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Re: [PATCH v2 07/40] scsi: core: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 825 lines · Damien Le Moal
Refactor the SCSI core code to use the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended, with the exception of a correction of the array
any_sense_failure_defsinscsi_lib_test_any_sense()which erroenously sets result toSCMD_FAILURE_RESULT_ANYinstead ofSAM_STAT_CHECK_CONDITIONand does not setssense_keytoSCMD_FAILURE_SENSE_KEY_ANY.Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/constants.c | 38 ++++++++-- drivers/scsi/scsi.c | 3 +- drivers/scsi/scsi_common.c | 12 ++-- drivers/scsi/scsi_error.c | 94 ++++++++++++++---------- drivers/scsi/scsi_ioctl.c | 3 +- drivers/scsi/scsi_lib.c | 116 ++++++++++++++++-------------- drivers/scsi/scsi_lib_test.c | 73 +++++++++++-------- drivers/scsi/scsi_scan.c | 14 ++-- drivers/scsi/scsi_transport_spi.c | 10 ++- include/trace/events/scsi.h | 4 +- 10 files changed, 219 insertions(+), 148 deletions(-)drivers/scsi/constants.c +31
-7@@ -327,13 +327,37 @@ struct error_info2 {static const struct error_info2 additional2[] = { - {0x40 ,0x00 ,0x7f ,"Ram failure" ,"" }, - {0x40 ,0x80 ,0xff ,"Diagnostic failure on component" ,"" }, - {0x41 ,0x00 ,0xff ,"Data path failure" ,"" }, - {0x42 ,0x00 ,0xff ,"Power-on or self-test failure" ,"" }, - {0x4D ,0x00 ,0xff ,"Tagged overlapped commands" ,"task tag " }, - {0x70 ,0x00 ,0xff ,"Decompression exception" ,"short algorithm id of " }, - {0 ,0 ,0 ,NULL ,NULL } + { +ASC_RAM_FAILURE , +0x00 ,0x7f , +"Ram failure" ,"" + }, + { +ASC_RAM_FAILURE , +0x80 ,0xff , +"Diagnostic failure on component" ,"" + }, + { +ASC_DATA_PATH_FAILURE , +0x00 ,0xff , +"Data path failure" ,"" + }, + { +ASC_POWER_ON_OR_SELFTEST_FAILURE , +0x00 ,0xff , +"Power-on or self-test failure" ,"" + }, + { +ASC_TAGGED_OVERLAPPED_COMMANDS , +0x00 ,0xff , +"Tagged overlapped commands" ,"task tag " + }, + { +ASC_DECOMPRESSION_EXCEPTION_SHORT_ALGORITHM_ID , +0x00 ,0xff , +"Decompression exception" ,"short algorithm id of " + }, + {0 ,0 ,0 ,NULL ,NULL } };/* description of the sense key values */ drivers/scsi/scsi.c +2
-1@@ -606,7 +606,8 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,return result;if (result &&scsi_sense_valid (&sshdr) && sshdr.sense_key ==ILLEGAL_REQUEST && - (sshdr.asc ==0x20 || sshdr.asc ==0x24 ) && sshdr.ascq ==0x00 ) + (sshdr.sense_code ==INVALID_COMMAND_OP_CODE || + sshdr.sense_code ==INVALID_FIELD_IN_CDB ))return -EINVAL ;if ((buffer[1 ] &3 ) ==3 )/* Command supported */ drivers/scsi/scsi_common.c +8
-4@@ -191,6 +191,8 @@ EXPORT_SYMBOL(int_to_scsilun);bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr) { +u8 asc =0 , ascq =0 ; +memset (sshdr,0 ,sizeof (struct scsi_sense_hdr ));if (!sense_buffer || !sb_len)@@ -208,9 +210,9 @@ bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,if (sb_len >1 ) sshdr->sense_key = (sense_buffer[1 ] &0xf );if (sb_len >2 ) - sshdr->asc = sense_buffer[2 ]; + asc = sense_buffer[2 ];if (sb_len >3 ) - sshdr->ascq = sense_buffer[3 ]; + ascq = sense_buffer[3 ];if (sb_len >7 ) sshdr->additional_length = sense_buffer[7 ]; }else {@@ -222,12 +224,14 @@ bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,if (sb_len >7 ) { sb_len =min (sb_len, sense_buffer[7 ] +8 );if (sb_len >12 ) - sshdr->asc = sense_buffer[12 ]; + asc = sense_buffer[12 ];if (sb_len >13 ) - sshdr->ascq = sense_buffer[13 ]; + ascq = sense_buffer[13 ]; } } + sshdr->sense_code =scsi_sense_code (asc, ascq); +return true; }EXPORT_SYMBOL (scsi_normalize_sense);drivers/scsi/scsi_error.c +57
-37@@ -490,24 +490,27 @@ static void scsi_report_sense(struct scsi_device *sdev,enum scsi_device_event evt_type =SDEV_EVT_MAXBITS ;/* i.e. none */ if (sshdr->sense_key ==UNIT_ATTENTION ) { -if (sshdr->asc ==0x3f && sshdr->ascq ==0x03 ) { +if (sshdr->sense_code ==INQUIRY_DATA_HAS_CHANGED ) { evt_type =SDEV_EVT_INQUIRY_CHANGE_REPORTED ;sdev_printk (KERN_WARNING , sdev,"Inquiry data has changed" ); - }else if (sshdr->asc ==0x3f && sshdr->ascq ==0x0e ) { + }else if (sshdr->sense_code ==REPORTED_LUNS_DATA_HAS_CHANGED ) { evt_type =SDEV_EVT_LUN_CHANGE_REPORTED ;scsi_report_lun_change (sdev);sdev_printk (KERN_WARNING , sdev,"LUN assignments on this target have " "changed. The Linux SCSI layer does not " "automatically remap LUN assignments.\n" ); - }else if (sshdr->asc ==0x3f ) + }else if (scsi_sense_asc (sshdr) == +ASC_TARGET_OPERATING_CONDITIONS_HAVE_CHANGED ) {sdev_printk (KERN_WARNING , sdev,"Operating parameters on this target have " "changed. The Linux SCSI layer does not " "automatically adjust these parameters.\n" ); + } -if (sshdr->asc ==0x38 && sshdr->ascq ==0x07 ) { +if (sshdr->sense_code == +THIN_PROVISIONING_SOFT_THRESHOLD_REACHED ) { evt_type =SDEV_EVT_SOFT_THRESHOLD_REACHED_REPORTED ;sdev_printk (KERN_WARNING , sdev, "Warning! Received an indication that the "@@ -515,7 +518,8 @@ static void scsi_report_sense(struct scsi_device *sdev, "threshold.\n"); } -if (sshdr->asc ==0x29 ) { +if (scsi_sense_asc (sshdr) == +ASC_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED ) { evt_type =SDEV_EVT_POWER_ON_RESET_OCCURRED ;/* * Do not print message if it is an expected side-effect @@ -526,21 +530,22 @@ static void scsi_report_sense(struct scsi_device *sdev, "Power-on or device reset occurred\n"); } -if (sshdr->asc ==0x2a && sshdr->ascq ==0x01 ) { +if (sshdr->sense_code ==MODE_PARAMETERS_CHANGED ) { evt_type =SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED ;sdev_printk (KERN_WARNING , sdev,"Mode parameters changed" ); - }else if (sshdr->asc ==0x2a && sshdr->ascq ==0x06 ) { + }else if (sshdr->sense_code ==ASYMMETRIC_ACCESS_STATE_CHANGED ) { evt_type =SDEV_EVT_ALUA_STATE_CHANGE_REPORTED ;sdev_printk (KERN_WARNING , sdev,"Asymmetric access state changed" ); - }else if (sshdr->asc ==0x2a && sshdr->ascq ==0x09 ) { + }else if (sshdr->sense_code ==CAPACITY_DATA_HAS_CHANGED ) { evt_type =SDEV_EVT_CAPACITY_CHANGE_REPORTED ;sdev_printk (KERN_WARNING , sdev,"Capacity data has changed" ); - }else if (sshdr->asc ==0x2a ) + }else if (scsi_sense_asc (sshdr) ==ASC_PARAMETERS_CHANGED ) {sdev_printk (KERN_WARNING , sdev,"Parameters changed" ); + } }if (evt_type !=SDEV_EVT_MAXBITS ) {@@ -582,9 +587,11 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)* that all ULDs interested in these can see that those have * happened, even if someone else gets the sense data. */ -if (sshdr.asc ==0x28 ) +if (scsi_sense_asc (&sshdr) == +ASC_NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED )atomic_inc (&sdev->ua_new_media_ctr); -else if (sshdr.asc ==0x29 ) +else if (scsi_sense_asc (&sshdr) == +ASC_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED )atomic_inc (&sdev->ua_por_ctr); }@@ -636,7 +643,8 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)return /* soft_error */ SUCCESS ;case ABORTED_COMMAND : -if (sshdr.asc ==0x10 )/* DIF */ +if (scsi_sense_asc (&sshdr) ==ASC_ID_CRC_OR_ECC_ERROR ) +/* DIF */ return SUCCESS ;/* @@ -647,18 +655,20 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)* COMMAND TIMEOUT DURING PROCESSING DUE TO ERROR RECOVERY * additional sense code qualifiers. */ -if (sshdr.asc ==0x2e && - sshdr.ascq >=0x01 && sshdr.ascq <=0x03 ) { +if (sshdr.sense_code >=COMMAND_TIMEOUT_BEFORE_PROCESSING && + sshdr.sense_code <= +COMMAND_TIMEOUT_DURING_PROCESSING_DUE_TO_ERROR_RECOVERY ) {set_scsi_ml_byte (scmd,SCSIML_STAT_DL_TIMEOUT ); req->cmd_flags |=REQ_FAILFAST_DEV ; req->rq_flags |=RQF_QUIET ;return SUCCESS ; } -if (sshdr.asc ==0x44 && sdev->sdev_bflags &BLIST_RETRY_ITF ) +if ((sdev->sdev_bflags &BLIST_RETRY_ITF ) && +scsi_sense_asc (&sshdr) ==ASC_INTERNAL_TARGET_FAILURE )return ADD_TO_MLQUEUE ; -if (sshdr.asc ==0xc1 && sshdr.ascq ==0x01 && - sdev->sdev_bflags &BLIST_RETRY_ASC_C1 ) +if ((sdev->sdev_bflags &BLIST_RETRY_ASC_C1 ) && + sshdr.sense_code ==scsi_sense_code (0xc1 ,0x01 ))return ADD_TO_MLQUEUE ;return NEEDS_RETRY ;@@ -672,12 +682,13 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)*/ if (scmd->device->expecting_cc_ua) {/* -* Because some device does not queue unit -* attentions correctly, we carefully check -* additional sense code and qualifier so as -* not to squash media change unit attention. +* Because some devices do not queue unit attentions +* correctly, we carefully check additional sense code +* and qualifier so as not to squash media change unit +* attention. */ -if (sshdr.asc !=0x28 || sshdr.ascq !=0x00 ) { +if (sshdr.sense_code != +NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED ) { scmd->device->expecting_cc_ua =0 ;return NEEDS_RETRY ; }@@ -688,21 +699,23 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)* REPORTED LUNS DATA HAS CHANGED. */ if (scmd->device->sdev_target->expecting_lun_change && - sshdr.asc ==0x3f && sshdr.ascq ==0x0e ) + sshdr.sense_code ==REPORTED_LUNS_DATA_HAS_CHANGED )return NEEDS_RETRY ;/* * if the device is in the process of becoming ready, we * should retry. */ -if ((sshdr.asc ==0x04 ) && - (sshdr.ascq ==0x01 || sshdr.ascq ==0x0a )) +if (sshdr.sense_code ==LU_IS_IN_PROCESS_OF_BECOMING_READY || + sshdr.sense_code == +LU_NOT_ACCESSIBLE_ASYMMETRIC_ACCESS_STATE_TRANSITION )return NEEDS_RETRY ;/* * if the device is not started, we need to wake * the error handler to start the motor */ if (scmd->device->allow_restart && - (sshdr.asc ==0x04 ) && (sshdr.ascq ==0x02 )) + sshdr.sense_code == +LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED )return FAILED ;/* * Pass the UA upwards for a determination in the completion @@ -712,7 +725,7 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)/* these are not supported */ case DATA_PROTECT : -if (sshdr.asc ==0x27 && sshdr.ascq ==0x07 ) { +if (sshdr.sense_code ==SPACE_ALLOCATION_FAILED_WRITE_PROTECT ) {/* Thin provisioning hard threshold reached */ set_scsi_ml_byte (scmd,SCSIML_STAT_NOSPC );return SUCCESS ;@@ -726,11 +739,14 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)return SUCCESS ;case MEDIUM_ERROR : -if (sshdr.asc ==0x11 ||/* UNRECOVERED READ ERR */ - sshdr.asc ==0x13 ||/* AMNF DATA FIELD */ - sshdr.asc ==0x14 ) {/* RECORD NOT FOUND */ +switch (scsi_sense_asc (&sshdr)) { +case ASC_UNRECOVERED_READ_ERROR : +case ASC_ADDRESS_MARK_NOT_FOUND_FOR_DATA_FIELD : +case ASC_RECORDED_ENTITY_NOT_FOUND :set_scsi_ml_byte (scmd,SCSIML_STAT_MED_ERROR );return SUCCESS ; +default : +break ; }return NEEDS_RETRY ;@@ -742,13 +758,17 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) fallthrough;case ILLEGAL_REQUEST : -if (sshdr.asc ==0x20 ||/* Invalid command operation code */ - sshdr.asc ==0x21 ||/* Logical block address out of range */ - sshdr.asc ==0x22 ||/* Invalid function */ - sshdr.asc ==0x24 ||/* Invalid field in cdb */ - sshdr.asc ==0x26 ||/* Parameter value invalid */ - sshdr.asc ==0x27 ) {/* Write protected */ +switch (scsi_sense_asc (&sshdr)) { +case ASC_INVALID_COMMAND_OP_CODE : +case ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE : +case ASC_ILLEGAL_FUNCTION : +case ASC_INVALID_FIELD_IN_CDB : +case ASC_INVALID_FIELD_IN_PARAMETER_LIST : +case ASC_WRITE_PROTECTED :set_scsi_ml_byte (scmd,SCSIML_STAT_TGT_FAILURE ); +break ; +default : +break ; }return SUCCESS ;@@ -760,7 +780,7 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)* that the command was in fact aborted because it exceeded its * duration limit. Never retry these commands. */ -if (sshdr.asc ==0x55 && sshdr.ascq ==0x0a ) { +if (sshdr.sense_code ==DATA_CURRENTLY_UNAVAILABLE ) {set_scsi_ml_byte (scmd,SCSIML_STAT_DL_TIMEOUT ); req->cmd_flags |=REQ_FAILFAST_DEV ; req->rq_flags |=RQF_QUIET ;drivers/scsi/scsi_ioctl.c +2
-1@@ -96,7 +96,8 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,"ioctl_internal_command: " "ILLEGAL REQUEST " "asc=0x%x ascq=0x%x\n" , - sshdr.asc, sshdr.ascq); +scsi_sense_asc (&sshdr), + scsi_sense_ascq(&sshdr));break ;case NOT_READY :/* This happens if there is no disc in drive */ if (sdev->removable)drivers/scsi/scsi_lib.c +64
-52@@ -252,14 +252,14 @@ static int scsi_check_passthrough(struct scsi_cmnd *scmd,if (failure->sense_key != sshdr.sense_key)continue ; -if (failure->asc ==SCMD_FAILURE_ASC_ANY ) +if (scsi_failure_asc (failure) ==SCMD_FAILURE_ASC_ANY ) goto maybe_retry; -if (failure->asc != sshdr.asc) +if (scsi_failure_asc (failure) !=scsi_sense_asc (&sshdr))continue ; -if (failure->ascq ==SCMD_FAILURE_ASCQ_ANY || - failure->ascq == sshdr.ascq) +if (scsi_failure_ascq (failure) ==SCMD_FAILURE_ASCQ_ANY || +scsi_failure_ascq (failure) ==scsi_sense_ascq (&sshdr)) goto maybe_retry; }@@ -839,6 +839,8 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)*/ action =ACTION_RETRY ; }else if (sense_valid && sense_current) { +u8 asc =scsi_sense_asc (&sshdr); +switch (sshdr.sense_key) {case UNIT_ATTENTION :if (cmd->device->removable) {@@ -865,64 +867,72 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)* where READ CAPACITY failed, we may have * read past the end of the disk. */ -if ((cmd->device->use_10_for_rw && - sshdr.asc ==0x20 && sshdr.ascq ==0x00 ) && +if (cmd->device->use_10_for_rw && + sshdr.sense_code ==INVALID_COMMAND_OP_CODE && (cmd->cmnd[0 ] ==READ_10 || cmd->cmnd[0 ] ==WRITE_10 )) {/* This will issue a new 6-byte command. */ cmd->device->use_10_for_rw =0 ; action =ACTION_REPREP ; - }else if (sshdr.asc ==0x10 )/* DIX */ { +break ; + } +if (asc ==ASC_ID_CRC_OR_ECC_ERROR ) { +/* DIX */ action =ACTION_FAIL ; blk_stat =BLK_STS_PROTECTION ; -/* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ - }else if (sshdr.asc ==0x20 || sshdr.asc ==0x24 ) { +break ; + } +if (asc ==ASC_INVALID_COMMAND_OP_CODE || + asc ==ASC_INVALID_FIELD_IN_CDB ) { action =ACTION_FAIL ; blk_stat =BLK_STS_TARGET ; - }else - action =ACTION_FAIL ; +break ; + } + action =ACTION_FAIL ;break ;case ABORTED_COMMAND : action =ACTION_FAIL ; -if (sshdr.asc ==0x10 )/* DIF */ +if (asc ==ASC_ID_CRC_OR_ECC_ERROR )/* DIF */ blk_stat =BLK_STS_PROTECTION ;break ;case NOT_READY :/* If the device is in the process of becoming * ready, or has a temporary blockage, retry. */ -if (sshdr.asc ==0x04 ) { -switch (sshdr.ascq) { -case 0x01 :/* becoming ready */ -case 0x04 :/* format in progress */ -case 0x05 :/* rebuild in progress */ -case 0x06 :/* recalculation in progress */ -case 0x07 :/* operation in progress */ -case 0x08 :/* Long write in progress */ -case 0x09 :/* self test in progress */ -case 0x11 :/* notify (enable spinup) required */ -case 0x14 :/* space allocation in progress */ -case 0x1a :/* start stop unit in progress */ -case 0x1b :/* sanitize in progress */ -case 0x1d :/* configuration in progress */ - action =ACTION_DELAYED_RETRY ; -break ; -case 0x0a :/* ALUA state transition */ - action =ACTION_DELAYED_REPREP ; -break ; -/* -* Depopulation might take many hours, -* thus it is not worthwhile to retry. -*/ -case 0x24 :/* depopulation in progress */ -case 0x25 :/* depopulation restore in progress */ - fallthrough; -default : - action =ACTION_FAIL ; -break ; - } - }else +if (asc !=ASC_LU_NOT_READY ) { action =ACTION_FAIL ; +break ; + } + +switch (sshdr.sense_code) { +case LU_IS_IN_PROCESS_OF_BECOMING_READY : +case LU_NOT_READY_FORMAT_IN_PROGRESS : +case LU_NOT_READY_REBUILD_IN_PROGRESS : +case LU_NOT_READY_RECALCULATION_IN_PROGRESS : +case LU_NOT_READY_OP_IN_PROGRESS : +case LU_NOT_READY_LONG_WRITE_IN_PROGRESS : +case LU_NOT_READY_SELFTEST_IN_PROGRESS : +case LU_NOT_READY_NOTIFY_REQUIRED : +case LU_NOT_READY_SPACE_ALLOCATION_IN_PROGRESS : +case LU_NOT_READY_START_STOP_UNIT_COMMAND_IN_PROGRESS : +case LU_NOT_READY_SANITIZE_IN_PROGRESS : +case LU_NOT_READY_CONFIG_IN_PROGRESS : + action =ACTION_DELAYED_RETRY ; +break ; +case LU_NOT_ACCESSIBLE_ASYMMETRIC_ACCESS_STATE_TRANSITION : + action =ACTION_DELAYED_REPREP ; +break ; +/* +* Depopulation might take many hours, thus it is not +* worthwhile to retry. +*/ +case DEPOPULATION_IN_PROGRESS : +case DEPOPULATION_RESTORATION_IN_PROGRESS : + fallthrough; +default : + action =ACTION_FAIL ; +break ; + }break ;case VOLUME_OVERFLOW :/* See SSC3rXX or current. */ @@ -930,11 +940,14 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)break ;case DATA_PROTECT : action =ACTION_FAIL ; -if ((sshdr.asc ==0x0C && sshdr.ascq ==0x12 ) || - (sshdr.asc ==0x55 && - (sshdr.ascq ==0x0E || sshdr.ascq ==0x0F ))) { -/* Insufficient zone resources */ +switch (sshdr.sense_code) { +case WRITE_ERROR_INSUFFICIENT_ZONE_RESOURCES : +case INSUFFICIENT_ZONE_RESOURCES : +case INSUFFICIENT_ZONE_RESOURCES_TO_COMPLETE_WRITE : blk_stat =BLK_STS_ZONE_OPEN_RESOURCE ; +break ; +default : +break ; }break ;case COMPLETED :@@ -1041,7 +1054,7 @@ static int scsi_io_completion_nz_result(struct scsi_cmnd *cmd, int result,* skip print since caller wants ATA registers. Only occurs * on SCSI ATA PASS_THROUGH commands when CK_COND=1 */ -if ((sshdr.asc ==0x0 ) && (sshdr.ascq ==0x1d )) +if (sshdr.sense_code ==ATA_PASS_THROUGH_INFORMATION_AVAILABLE ) do_print = false;else if (req->rq_flags &RQF_QUIET ) do_print = false;@@ -2373,8 +2386,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed = retries, .result =SAM_STAT_CHECK_CONDITION , },@@ -2432,8 +2444,8 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, int subpage,if (!scsi_status_is_good (result)) {if (scsi_sense_valid (sshdr)) { -if ((sshdr->sense_key ==ILLEGAL_REQUEST ) && - (sshdr->asc ==0x20 ) && (sshdr->ascq ==0 )) { +if (sshdr->sense_key ==ILLEGAL_REQUEST && + sshdr->sense_code ==INVALID_COMMAND_OP_CODE ) {/* * Invalid command operation code: retry using * MODE SENSE(6) if this was a MODE SENSE(10) drivers/scsi/scsi_lib_test.c +43
-30@@ -18,41 +18,42 @@ static void scsi_lib_test_multiple_sense(struct kunit *test)struct scsi_failure multiple_sense_failure_defs[] = { { .sense_key =DATA_PROTECT , - .asc =0x1 , - .ascq =0x1 , + .sense_code = +scsi_sense_code (ASC_NO_INDEX_SECTOR_SIGNAL , +0x1 ), .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =UNIT_ATTENTION , - .asc =0x11 , - .ascq =0x0 , + .sense_code =UNRECOVERED_READ_ERROR , .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =NOT_READY , - .asc =0x11 , - .ascq =0x22 , + .sense_code = +scsi_sense_code (ASC_UNRECOVERED_READ_ERROR , +0x22 ), .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =ABORTED_COMMAND , - .asc =0x11 , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code = +scsi_sense_code (ASC_UNRECOVERED_READ_ERROR , +SCMD_FAILURE_ASCQ_ANY ), .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =HARDWARE_ERROR , - .asc =SCMD_FAILURE_ASC_ANY , + .sense_code =scsi_sense_code (SCMD_FAILURE_ASC_ANY ,0 ), .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =ILLEGAL_REQUEST , - .asc =0x91 , - .ascq =0x36 , + .sense_code =scsi_sense_code (0x91 ,0x36 ), .allowed =SCSI_LIB_TEST_MAX_ALLOWED , .result =SAM_STAT_CHECK_CONDITION , },@@ -72,32 +73,37 @@ static void scsi_lib_test_multiple_sense(struct kunit *test)KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc, &failures));KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc,NULL ));/* Command failed but caller did not pass in a failures array */ -scsi_build_sense (&sc,0 ,ILLEGAL_REQUEST ,0x91 ,0x36 ); +scsi_set_sense (&sc,0 ,ILLEGAL_REQUEST ,scsi_sense_code (0x91 ,0x36 ));KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc,NULL ));/* Match end of array */ -scsi_build_sense (&sc,0 ,ILLEGAL_REQUEST ,0x91 ,0x36 ); +scsi_set_sense (&sc,0 ,ILLEGAL_REQUEST ,scsi_sense_code (0x91 ,0x36 ));KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));/* Basic match in array */ -scsi_build_sense (&sc,0 ,UNIT_ATTENTION ,0x11 ,0x0 ); +scsi_set_sense (&sc,0 ,UNIT_ATTENTION ,UNRECOVERED_READ_ERROR );KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));/* No matching sense entry */ -scsi_build_sense (&sc,0 ,MISCOMPARE ,0x11 ,0x11 ); +scsi_set_sense (&sc,0 ,MISCOMPARE ,READ_ERROR_LOSS_OF_STREAMING );KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc, &failures));/* Match using SCMD_FAILURE_ASCQ_ANY */ -scsi_build_sense (&sc,0 ,ABORTED_COMMAND ,0x11 ,0x22 ); +scsi_set_sense (&sc,0 ,ABORTED_COMMAND , +scsi_sense_code (ASC_UNRECOVERED_READ_ERROR ,0x22 ));KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));/* Fail to match */ -scsi_build_sense (&sc,0 ,ABORTED_COMMAND ,0x22 ,0x22 ); +scsi_set_sense (&sc,0 ,ABORTED_COMMAND , +scsi_sense_code (ASC_ILLEGAL_FUNCTION ,0x22 ));KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc, &failures));/* Match using SCMD_FAILURE_ASC_ANY */ -scsi_build_sense (&sc,0 ,HARDWARE_ERROR ,0x11 ,0x22 ); +scsi_set_sense (&sc,0 ,HARDWARE_ERROR , +scsi_sense_code (ASC_UNRECOVERED_READ_ERROR ,0x22 )); +KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));/* No matching status entry */ sc.result =SAM_STAT_RESERVATION_CONFLICT ;KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc, &failures));/* Test hitting allowed limit */ -scsi_build_sense (&sc,0 ,NOT_READY ,0x11 ,0x22 ); +scsi_set_sense (&sc,0 ,NOT_READY , +scsi_sense_code (ASC_UNRECOVERED_READ_ERROR ,0x22 ));for (i =0 ; i <SCSI_LIB_TEST_MAX_ALLOWED ; i++)KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures));@@ -108,7 +114,8 @@ static void scsi_lib_test_multiple_sense(struct kunit *test)scsi_failures_reset_retries (&failures);/* Test no retries allowed */ -scsi_build_sense (&sc,0 ,DATA_PROTECT ,0x1 ,0x1 ); +scsi_set_sense (&sc,0 ,DATA_PROTECT , +scsi_sense_code (ASC_NO_INDEX_SECTOR_SIGNAL ,0x1 ));KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc, &failures)); }@@ -118,7 +125,7 @@ static void scsi_lib_test_any_sense(struct kunit *test) { .sense_key = SCMD_FAILURE_SENSE_KEY_ANY, .allowed = SCSI_LIB_TEST_MAX_ALLOWED, - .result = SCMD_FAILURE_RESULT_ANY, + .result = SAM_STAT_CHECK_CONDITION, }, {} };@@ -132,7 +139,8 @@ static void scsi_lib_test_any_sense(struct kunit *test)/* Match using SCMD_FAILURE_SENSE_KEY_ANY */ failures.failure_definitions = any_sense_failure_defs; -scsi_build_sense (&sc,0 ,MEDIUM_ERROR ,0x11 ,0x22 ); +scsi_set_sense (&sc,0 ,MEDIUM_ERROR , +scsi_sense_code (ASC_UNRECOVERED_READ_ERROR ,0x22 ));KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures)); }@@ -217,8 +225,7 @@ static void scsi_lib_test_total_allowed(struct kunit *test)struct scsi_failure total_allowed_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ @@ -246,7 +253,8 @@ static void scsi_lib_test_total_allowed(struct kunit *test)scsi_failures_reset_retries (&failures); failures.total_allowed =SCSI_LIB_TEST_TOTAL_MAX_ALLOWED ; -scsi_build_sense (&sc,0 ,UNIT_ATTENTION ,0x28 ,0x0 ); +scsi_set_sense (&sc,0 ,UNIT_ATTENTION , +NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED );for (i =0 ; i <SCSI_LIB_TEST_TOTAL_MAX_ALLOWED ; i++)/* Retry since we under the total_allowed limit */ KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc,@@ -261,12 +269,14 @@ static void scsi_lib_test_mixed_total(struct kunit *test)struct scsi_failure mixed_total_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =0x28 , + .sense_code = +NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =UNIT_ATTENTION , - .asc =0x29 , + .sense_code = +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED , .result =SAM_STAT_CHECK_CONDITION , }, {@@ -292,7 +302,8 @@ static void scsi_lib_test_mixed_total(struct kunit *test)scsi_failures_reset_retries (&failures); failures.total_allowed =SCSI_LIB_TEST_TOTAL_MAX_ALLOWED ; -scsi_build_sense (&sc,0 ,UNIT_ATTENTION ,0x28 ,0x0 ); +scsi_set_sense (&sc,0 ,UNIT_ATTENTION , +NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED );for (i =0 ; i <SCSI_LIB_TEST_TOTAL_MAX_ALLOWED ; i++)/* Retry since we under the total_allowed limit */ KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc,@@ -301,7 +312,8 @@ static void scsi_lib_test_mixed_total(struct kunit *test)KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc, &failures));scsi_failures_reset_retries (&failures); -scsi_build_sense (&sc,0 ,UNIT_ATTENTION ,0x28 ,0x0 ); +scsi_set_sense (&sc,0 ,UNIT_ATTENTION , +NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED );for (i =0 ; i <SCSI_LIB_TEST_TOTAL_MAX_ALLOWED ; i++)/* Retry since we under the total_allowed limit */ KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc,@@ -309,7 +321,8 @@ static void scsi_lib_test_mixed_total(struct kunit *test) sc.result =DID_TIME_OUT <<16 ;/* Retry because this failure has a per failure limit */ KUNIT_EXPECT_EQ (test, -EAGAIN ,scsi_check_passthrough (&sc, &failures)); -scsi_build_sense (&sc,0 ,UNIT_ATTENTION ,0x29 ,0x0 ); +scsi_set_sense (&sc,0 ,UNIT_ATTENTION , +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED );/* total_allowed is now hit so no more retries */ KUNIT_EXPECT_EQ (test,0 ,scsi_check_passthrough (&sc, &failures)); }drivers/scsi/scsi_scan.c +6
-8@@ -652,19 +652,18 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,int pass, count, result, resid;struct scsi_failure failure_defs[] = {/* -* not-ready to ready transition [asc/ascq=0x28/0x0] or -* power-on, reset [asc/ascq=0x29/0x0], continue. INQUIRY -* should not yield UNIT_ATTENTION but many buggy devices do -* so anyway. +* not-ready to ready transition or power-on, reset, continue. +* INQUIRY should not yield UNIT_ATTENTION but many buggy +* devices do so anyway. */ { .sense_key =UNIT_ATTENTION , - .asc =0x28 , + .sense_code =NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =UNIT_ATTENTION , - .asc =0x29 , + .sense_code =POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED , .result =SAM_STAT_CHECK_CONDITION , }, {@@ -1458,8 +1457,7 @@ static int scsi_report_lun_scan(struct Scsi_Host *shost,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .result =SAM_STAT_CHECK_CONDITION , },/* Fail all CCs except the UA above */ drivers/scsi/scsi_transport_spi.c +1
-2@@ -113,8 +113,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =DV_RETRIES , .result =SAM_STAT_CHECK_CONDITION , },@@ -680,10 +679,9 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,if (result || !scsi_device_online (sdev)) {scsi_device_set_state (sdev,SDEV_QUIESCE );
drivers/scsi/scsi_transport_spi.c spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, · line 687
Quoted 10 lines
drivers/scsi/scsi_transport_spi.c +3
-4-if (result >0 &&scsi_sense_valid (&sshdr) - && sshdr.sense_key ==ILLEGAL_REQUEST -/* INVALID FIELD IN CDB */ - && sshdr.asc ==0x24 && sshdr.ascq ==0x00 ) +if (result >0 &&scsi_sense_valid (&sshdr) && + sshdr.sense_key ==ILLEGAL_REQUEST && + sshdr.sense_code ==INVALID_FIELD_IN_CDB )/* This would mean that the drive lied * to us about supporting an echo * buffer (unfortunately some Western
Why don't we check against the 16-bit code here?
Quoted 5 lines
include/trace/events/scsi.h +0
-0
include/trace/events/scsi.h DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template, · line 310
Quoted 10 lines
include/trace/events/scsi.h +2
-2@@ -303,8 +303,8 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,if (cmd->sense_buffer &&SCSI_SENSE_VALID (cmd) &&scsi_command_normalize_sense (cmd, &sshdr)) { __entry->sense_key = sshdr.sense_key; - __entry->asc = sshdr.asc; - __entry->ascq = sshdr.ascq; + __entry->asc =scsi_sense_asc (&sshdr); + __entry->ascq =scsi_sense_ascq (&sshdr); }else { __entry->sense_key =0 ; __entry->asc =0 ;
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 8/40 scsi: sd: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the SCSI disk driver to use as much as possible the 16-bits sense_code field of struct scsi_sense_hdr and struct scsi_failure and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/sd.c | 106 +++++++++++++++++++++--------------------- drivers/scsi/sd_zbc.c | 2 +- 2 files changed, 53 insertions(+), 55 deletions(-)
drivers/scsi/sd.c +52 -54
@@ -1786,8 +1786,7 @@ static int media_not_present(struct scsi_disk *sdkp,switch (sshdr->sense_key) {case UNIT_ATTENTION :case NOT_READY : -/* medium not present */ -if (sshdr->asc ==0x3A ) { +if (scsi_sense_asc (sshdr) ==ASC_MEDIUM_NOT_PRESENT ) {set_media_not_present (sdkp);return 1 ; }
@@ -1911,12 +1910,14 @@ static int sd_sync_cache(struct scsi_disk *sdkp)if (scsi_status_is_check_condition (res) &&scsi_sense_valid (&sshdr)) { +u8 asc =scsi_sense_asc (&sshdr); +sd_print_sense_hdr (sdkp, &sshdr);/* we need to evaluate the error return */ -if (sshdr.asc ==0x3a ||/* medium not present */ - sshdr.asc ==0x20 ||/* invalid command */ - (sshdr.asc ==0x74 && sshdr.ascq ==0x71 ))/* drive is password locked */ +if (asc ==ASC_MEDIUM_NOT_PRESENT || + asc ==ASC_INVALID_COMMAND_OP_CODE || + sshdr.sense_code ==LU_ACCESS_NOT_AUTHORIZED )/* this is no error here */ return 0 ;
@@ -1926,8 +1927,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* this is called during shutdown or suspend so just * return success so those operations can proceed. */ -if ((sshdr.asc ==0x04 && sshdr.ascq ==0x04 ) || - sshdr.sense_key ==ILLEGAL_REQUEST ) +if (sshdr.sense_key ==ILLEGAL_REQUEST || + sshdr.sense_code ==LU_NOT_READY_FORMAT_IN_PROGRESS )return 0 ; }
@@ -2015,7 +2016,9 @@ static int sd_scsi_to_pr_err(struct scsi_sense_hdr *sshdr, int result)return PR_STS_IOERR ;if (sshdr->sense_key ==ILLEGAL_REQUEST && - (sshdr->asc ==0x26 || sshdr->asc ==0x24 )) + (scsi_sense_asc (sshdr) == +ASC_INVALID_FIELD_IN_PARAMETER_LIST || +scsi_sense_asc (sshdr) ==ASC_INVALID_FIELD_IN_CDB ))return -EINVAL ; fallthrough;
@@ -2034,8 +2037,7 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =5 , .result =SAM_STAT_CHECK_CONDITION , },
@@ -2146,8 +2148,7 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =5 , .result =SAM_STAT_CHECK_CONDITION , },
@@ -2440,16 +2441,17 @@ static int sd_done(struct scsi_cmnd *SCpnt)memset (SCpnt->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE );break ;case ABORTED_COMMAND : -if (sshdr.asc ==0x10 )/* DIF: Target detected corruption */ +if (scsi_sense_asc (&sshdr) ==ASC_ID_CRC_OR_ECC_ERROR )/* DIF */ good_bytes =sd_completed_bytes (SCpnt);break ;case ILLEGAL_REQUEST : -switch (sshdr.asc) { -case 0x10 :/* DIX: Host detected corruption */ +switch (scsi_sense_asc (&sshdr)) { +case ASC_ID_CRC_OR_ECC_ERROR : +/* DIX */ good_bytes =sd_completed_bytes (SCpnt);break ; -case 0x20 :/* INVALID COMMAND OPCODE */ -case 0x24 :/* INVALID FIELD IN CDB */ +case ASC_INVALID_COMMAND_OP_CODE : +case ASC_INVALID_FIELD_IN_CDB :switch (SCpnt->cmnd[0 ]) {case UNMAP :sd_disable_discard (sdkp);
@@ -2495,14 +2497,14 @@ sd_spinup_disk(struct scsi_disk *sdkp)/* Do not retry Medium Not Present */ { .sense_key = UNIT_ATTENTION, - .asc = 0x3A, - .ascq = SCMD_FAILURE_ASCQ_ANY, + .sense_code = + MEDIUM_NOT_PRESENT | SCMD_FAILURE_ASCQ_ANY, .result = SAM_STAT_CHECK_CONDITION, }, { .sense_key = NOT_READY, - .asc = 0x3A, - .ascq = SCMD_FAILURE_ASCQ_ANY, + .sense_code = + MEDIUM_NOT_PRESENT | SCMD_FAILURE_ASCQ_ANY, .result = SAM_STAT_CHECK_CONDITION, }, /* Retry when scsi_status_is_good would return false 3 times */
@@ -2566,18 +2568,18 @@ sd_spinup_disk(struct scsi_disk *sdkp)break ;if (sense_valid && sshdr.sense_key ==NOT_READY ) { -if (sshdr.asc ==4 && sshdr.ascq ==3 ) -break ;/* manual intervention required */ -if (sshdr.asc ==4 && sshdr.ascq ==0xb ) -break ;/* standby */ -if (sshdr.asc ==4 && sshdr.ascq ==0xc ) -break ;/* unavailable */ -if (sshdr.asc ==4 && sshdr.ascq ==0x1b ) -break ;/* sanitize in progress */ -if (sshdr.asc ==4 && sshdr.ascq ==0x24 ) -break ;/* depopulation in progress */ -if (sshdr.asc ==4 && sshdr.ascq ==0x25 ) -break ;/* depopulation restoration in progress */ +switch (sshdr.sense_code) { +case LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED : +case LU_NOT_ACCESSIBLE_TARGET_PORT_IN_STANDBY_STATE : +case LU_NOT_ACCESSIBLE_TARGET_PORT_IN_UNAVAILABLE_STATE : +case LU_NOT_READY_SANITIZE_IN_PROGRESS : +case DEPOPULATION_IN_PROGRESS : +case DEPOPULATION_RESTORATION_IN_PROGRESS : + goto out; +default : +break ; + } +/* * Issue command to spin up drive when not ready */
@@ -2608,8 +2610,9 @@ sd_spinup_disk(struct scsi_disk *sdkp)* occur here. It's characteristic of these devices. */ }else if (sense_valid && - sshdr.sense_key ==UNIT_ATTENTION && - sshdr.asc ==0x28 ) { + sshdr.sense_key ==UNIT_ATTENTION && +scsi_sense_asc (&sshdr) == +ASC_NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED ) {if (!spintime) { spintime_expire = jiffies +5 *HZ ; spintime =1 ;
@@ -2628,6 +2631,7 @@ sd_spinup_disk(struct scsi_disk *sdkp) }while (spintime &&time_before_eq (jiffies, spintime_expire)); +out:if (spintime) {if (scsi_status_is_good (the_result))printk (KERN_CONT "ready\n" );
@@ -2753,15 +2757,14 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, sense_valid =scsi_sense_valid (&sshdr);if (sense_valid && sshdr.sense_key ==ILLEGAL_REQUEST && - (sshdr.asc ==0x20 || sshdr.asc ==0x24 ) && - sshdr.ascq ==0x00 ) -/* Invalid Command Operation Code or -* Invalid Field in CDB, just retry -* silently with RC10 */ + (sshdr.sense_code ==INVALID_COMMAND_OP_CODE || + sshdr.sense_code ==INVALID_FIELD_IN_CDB )) +/* Just retry silently with RC10 */ return -EINVAL ;if (sense_valid && sshdr.sense_key ==UNIT_ATTENTION && - sshdr.asc ==0x29 && sshdr.ascq ==0x00 ) + sshdr.sense_code == +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED )/* Device reset might occur several times, * give it one more chance */ if (--reset_retries >0 )
@@ -2818,18 +2821,18 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,/* Do not retry Medium Not Present */ { .sense_key = UNIT_ATTENTION, - .asc = 0x3A, + .sense_code = MEDIUM_NOT_PRESENT, .result = SAM_STAT_CHECK_CONDITION, }, { .sense_key = NOT_READY, - .asc = 0x3A, + .sense_code = MEDIUM_NOT_PRESENT, .result = SAM_STAT_CHECK_CONDITION, }, /* Device reset might occur several times so retry a lot */ { .sense_key = UNIT_ATTENTION, - .asc = 0x29, + .sense_code = POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED, .allowed = READ_CAPACITY_RETRIES_ON_RESET, .result = SAM_STAT_CHECK_CONDITION, },
@@ -3258,8 +3261,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) bad_sense:if (res == -EIO &&scsi_sense_valid (&sshdr) && sshdr.sense_key ==ILLEGAL_REQUEST && - sshdr.asc ==0x24 && sshdr.ascq ==0x0 ) -/* Invalid field in CDB */ + sshdr.sense_code ==INVALID_FIELD_IN_CDB )sd_first_printk (KERN_NOTICE , sdkp,"Cache data unavailable\n" );else sd_first_printk(KERN_ERR, sdkp,
@@ -4160,22 +4162,19 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) { /* Power on, reset, or bus device reset occurred */ .sense_key = UNIT_ATTENTION, - .asc = 0x29, - .ascq = 0, + .sense_code = POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED, .result = SAM_STAT_CHECK_CONDITION, }, { /* Power on occurred */ .sense_key = UNIT_ATTENTION, - .asc = 0x29, - .ascq = 1, + .sense_code = POWER_ON_OCCURRED, .result = SAM_STAT_CHECK_CONDITION, }, { /* SCSI bus reset */ .sense_key = UNIT_ATTENTION, - .asc = 0x29, - .ascq = 2, + .sense_code = SCSI_BUS_RESET_OCCURRED, .result = SAM_STAT_CHECK_CONDITION, }, {}
@@ -4207,8 +4206,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)sd_print_result (sdkp,"Start/Stop Unit failed" , res);if (res >0 &&scsi_sense_valid (&sshdr)) {sd_print_sense_hdr (sdkp, &sshdr); -/* 0x3a is medium not present */ -if (sshdr.asc ==0x3a ) +if (scsi_sense_asc (&sshdr) ==ASC_MEDIUM_NOT_PRESENT ) res =0 ; } }
drivers/scsi/sd_zbc.c +1 -1
@@ -369,7 +369,7 @@ unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,if (op_is_zone_mgmt (req_op (rq)) && result && sshdr->sense_key ==ILLEGAL_REQUEST && - sshdr->asc ==0x24 ) { + sshdr->sense_code ==INVALID_FIELD_IN_CDB ) {/* * INVALID FIELD IN CDB error: a zone management command was * attempted on a conventional zone. Nothing to worry about,
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 08/40] scsi: sd: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Refactor the SCSI disk driver to use as much as possible the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Re: [PATCH v2 08/40] scsi: sd: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 7 lines · Damien Le Moal
Refactor the SCSI disk driver to use as much as possible the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 8 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/sd.c | 106 +++++++++++++++++++++--------------------- drivers/scsi/sd_zbc.c | 2 +- 2 files changed, 53 insertions(+), 55 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 9/40 scsi: sr: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the SCSI CDROM driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/sr.c | 3 ++- drivers/scsi/sr_ioctl.c | 29 +++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-)
drivers/scsi/sr.c +2 -1
@@ -253,7 +253,8 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,* (ASC 0x3a). */ cd->media_present =scsi_status_is_good (ret) || - (scsi_sense_valid (&sshdr) && sshdr.asc !=0x3a ); + (scsi_sense_valid (&sshdr) && +scsi_sense_asc (&sshdr) !=ASC_MEDIUM_NOT_PRESENT );if (last_present != cd->media_present) cd->device->changed =1 ;
drivers/scsi/sr_ioctl.c +11 -18
@@ -226,9 +226,8 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) err = -ENOMEDIUM ;break ;case NOT_READY :/* This happens if there is no disc in drive */ -if (sshdr->asc ==0x04 && - sshdr->ascq ==0x01 ) { -/* sense: Logical unit is in process of becoming ready */ +if (sshdr->sense_code == +LU_IS_IN_PROCESS_OF_BECOMING_READY ) {if (!cgc->quiet)sr_printk (KERN_INFO , cd,"CDROM not ready yet.\n" );
@@ -250,9 +249,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)break ;case ILLEGAL_REQUEST : err = -EIO ; -if (sshdr->asc ==0x20 && - sshdr->ascq ==0x00 ) -/* sense: Invalid command operation code */ +if (sshdr->sense_code ==INVALID_COMMAND_OP_CODE ) err = -EDRIVE_CANT_DO_THIS ;break ;default :
@@ -303,9 +300,8 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)if (!scsi_test_unit_ready (cd->device,SR_TIMEOUT ,MAX_RETRIES , &sshdr))return CDS_DISC_OK ; -/* SK/ASC/ASCQ of 2/4/1 means "unit is becoming ready" */ -if (scsi_sense_valid (&sshdr) && sshdr.sense_key ==NOT_READY - && sshdr.asc ==0x04 && sshdr.ascq ==0x01 ) +if (scsi_sense_valid (&sshdr) && sshdr.sense_key ==NOT_READY && + sshdr.sense_code ==LU_IS_IN_PROCESS_OF_BECOMING_READY )return CDS_DRIVE_NOT_READY ;if (!cdrom_get_media_event (cdi, &med)) {
@@ -318,18 +314,18 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot) }/* -* SK/ASC/ASCQ of 2/4/2 means "initialization required" * Using CD_TRAY_OPEN results in an START_STOP_UNIT to close * the tray, which resolves the initialization requirement. */ -if (scsi_sense_valid (&sshdr) && sshdr.sense_key ==NOT_READY - && sshdr.asc ==0x04 && sshdr.ascq ==0x02 ) +if (scsi_sense_valid (&sshdr) && sshdr.sense_key ==NOT_READY && + sshdr.sense_code ==LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED )return CDS_TRAY_OPEN ;/* * 0x04 is format in progress .. but there must be a disc present! */ -if (sshdr.sense_key ==NOT_READY && sshdr.asc ==0x04 ) +if (sshdr.sense_key ==NOT_READY && +scsi_sense_asc (&sshdr) ==ASC_LU_NOT_READY )return CDS_DISC_OK ;/*
@@ -338,13 +334,10 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot)* any other way to detect this... */ if (scsi_sense_valid (&sshdr) && -/* 0x3a is medium not present */ - sshdr.asc ==0x3a ) +scsi_sense_asc (&sshdr) ==ASC_MEDIUM_NOT_PRESENT )return CDS_NO_DISC ; -else -return CDS_TRAY_OPEN ; -return CDS_DRIVE_NOT_READY ; +return CDS_TRAY_OPEN ; }int sr_disk_status (struct cdrom_device_info *cdi)
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 09/40] scsi: sr: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the SCSI CDROM driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
Re: [PATCH v2 09/40] scsi: sr: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the SCSI CDROM driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 8 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/sr.c | 3 ++- drivers/scsi/sr_ioctl.c | 29 +++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 10/40 scsi: ses: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the SCSI stroage enclosure driver to use the 16-bits sense_code field of struct scsi_failure and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/ses.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/scsi/ses.c +7 -8
@@ -72,6 +72,9 @@ static void init_device_slot_control(unsigned char *dest_desc, dest_desc[3 ] &=0x3c ; } +#define POWER_ON_RESET_ANY \ + scsi_sense_code(ASC_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED, \ + SCMD_FAILURE_ASCQ_ANY)static int ses_recv_diag (struct scsi_device *sdev,int page_code,void *buf,int bufflen)
@@ -89,15 +92,13 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =0x29 , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =POWER_ON_RESET_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =NOT_READY , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , },
@@ -146,15 +147,13 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =0x29 , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =POWER_ON_RESET_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =NOT_READY , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =SES_RETRIES , .result =SAM_STAT_CHECK_CONDITION , },
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 10/40] scsi: ses: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the SCSI stroage enclosure driver to use the 16-bits
sense_codefield of structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Re: [PATCH v2 10/40] scsi: ses: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the SCSI stroage enclosure driver to use the 16-bits
sense_codefield of structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/ses.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 11/40 scsi: ch: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the SCSI media changer driver to use the 16-bits sense_code field of struct scsi_sense_hdr and struct scsi_failure and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/ch.c | 53 ++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 31 deletions(-)
drivers/scsi/ch.c +22 -31
@@ -123,38 +123,32 @@ static DEFINE_IDR(ch_index_idr);static DEFINE_SPINLOCK (ch_index_lock);static const struct { -unsigned char sense; -unsigned char asc; -unsigned char ascq; -int errno; +u8 sense_key; +u16 sense_code; +int errno; } ch_err[] = {/* Just filled in what looks right. Hav'nt checked any standard paper for these errno assignments, so they may be wrong... */ { - .sense =ILLEGAL_REQUEST , - .asc =0x21 , - .ascq =0x01 , - .errno =EBADSLT ,/* Invalid element address */ + .sense_key =ILLEGAL_REQUEST , + .sense_code =INVALID_ELEMENT_ADDRESS , + .errno =EBADSLT , },{ - .sense =ILLEGAL_REQUEST , - .asc =0x28 , - .ascq =0x01 , - .errno =EBADE ,/* Import or export element accessed */ + .sense_key =ILLEGAL_REQUEST , + .sense_code =IMPORT_OR_EXPORT_ELEMENT_ACCESSED , + .errno =EBADE , },{ - .sense =ILLEGAL_REQUEST , - .asc =0x3B , - .ascq =0x0D , - .errno =EXFULL ,/* Medium destination element full */ + .sense_key =ILLEGAL_REQUEST , + .sense_code =MEDIUM_DESTINATION_ELEMENT_FULL , + .errno =EXFULL , },{ - .sense =ILLEGAL_REQUEST , - .asc =0x3B , - .ascq =0x0E , - .errno =EBADE ,/* Medium source element empty */ + .sense_key =ILLEGAL_REQUEST , + .sense_code =MEDIUM_SOURCE_ELEMENT_EMPTY , + .errno =EBADE , },{ - .sense =ILLEGAL_REQUEST , - .asc =0x20 , - .ascq =0x00 , - .errno =EBADRQC ,/* Invalid command operation code */ + .sense_key =ILLEGAL_REQUEST , + .sense_code =INVALID_COMMAND_OP_CODE , + .errno =EBADRQC , },{/* end of list */ }
@@ -167,12 +161,10 @@ static int ch_find_errno(struct scsi_sense_hdr *sshdr)int i,errno =0 ;/* Check to see if additional sense information is available */ -if (scsi_sense_valid (sshdr) && - sshdr->asc !=0 ) { +if (scsi_sense_valid (sshdr) &&scsi_sense_asc (sshdr) !=0 ) {for (i =0 ; ch_err[i].errno !=0 ; i++) { -if (ch_err[i].sense == sshdr->sense_key && - ch_err[i].asc == sshdr->asc && - ch_err[i].ascq == sshdr->ascq) { +if (ch_err[i].sense_key == sshdr->sense_key && + ch_err[i].sense_code == sshdr->sense_code) { errno = -ch_err[i].errno;break ; }
@@ -192,8 +184,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len,struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =3 , .result =SAM_STAT_CHECK_CONDITION , },
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 11/40] scsi: ch: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Refactor the SCSI media changer driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
Re: [PATCH v2 11/40] scsi: ch: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 7 lines · Damien Le Moal
Refactor the SCSI media changer driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/ch.c | 53 ++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 31 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 12/40 scsi: st: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the SCSI tape driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/st.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/scsi/st.c +19 -16
@@ -421,11 +421,13 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) STp->cln_sense_mask) != 0); }if (cmdstatp->have_sense && - cmdstatp->sense_hdr.asc ==0 && cmdstatp->sense_hdr.ascq ==0x17 ) - STp->cleaning_req =1 ;/* ASC and ASCQ => cleaning requested */ + cmdstatp->sense_hdr.sense_code ==CLEANING_REQUESTED ) + STp->cleaning_req =1 ;if (cmdstatp->have_sense && scode ==UNIT_ATTENTION && - cmdstatp->sense_hdr.asc ==0x29 && !STp->pos_unknown) { - STp->pos_unknown =1 ;/* ASC => power on / reset */ +scsi_sense_asc (&cmdstatp->sense_hdr) == +ASC_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED && + !STp->pos_unknown) { + STp->pos_unknown =1 ;st_printk (KERN_WARNING , STp,"Power on/reset recognized." ); }
@@ -1003,7 +1005,8 @@ static int test_ready(struct scsi_tape *STp, int do_wait) scode = cmdstatp->sense_hdr.sense_key;if (scode ==UNIT_ATTENTION ) {/* New media? */ -if (cmdstatp->sense_hdr.asc ==0x28 ) {/* New media */ +if (scsi_sense_asc (&cmdstatp->sense_hdr) == +ASC_NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED ) { new_session =1 ;DEBC_printk (STp,"New tape session." ); }
@@ -1026,14 +1029,13 @@ static int test_ready(struct scsi_tape *STp, int do_wait) waits++;continue ; } -else { -if ((STp->device)->scsi_level >=SCSI_2 && - cmdstatp->sense_hdr.asc ==0x3a )/* Check ASC */ - retval =CHKRES_NO_TAPE ; -else - retval =CHKRES_NOT_READY ; -break ; - } +if ((STp->device)->scsi_level >=SCSI_2 && +scsi_sense_asc (&cmdstatp->sense_hdr) == +ASC_MEDIUM_NOT_PRESENT ) + retval =CHKRES_NO_TAPE ; +else + retval =CHKRES_NOT_READY ; +break ; } }
@@ -3105,9 +3107,10 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon cmd_in == MTSETDRVBUFFER || cmd_in == SET_DENS_AND_BLK) {if (cmdstatp->sense_hdr.sense_key ==ILLEGAL_REQUEST && - cmdstatp->sense_hdr.asc ==0x24 && - (STp->device)->scsi_level <=SCSI_2 && - !(STp->use_pf &PF_TESTED )) { +scsi_sense_asc (&cmdstatp->sense_hdr) == +ASC_INVALID_FIELD_IN_CDB && + (STp->device)->scsi_level <=SCSI_2 && + !(STp->use_pf &PF_TESTED )) {/* Try the other possible state of Page Format if not already tried */ STp->use_pf = (STp->use_pf ^USE_PF ) |PF_TESTED ;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 12/40] scsi: st: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the SCSI tape driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
Re: [PATCH v2 12/40] scsi: st: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the SCSI tape driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/st.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 13/40 scsi: device_handlers: hp_sw: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the HP sw device handler driver to use the 16-bits sense_code field of struct scsi_sense_hdr and struct scsi_failure and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 25 +++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/scsi/device_handler/scsi_dh_hp_sw.c +11 -14
@@ -47,7 +47,8 @@ static int tur_done(struct scsi_device *sdev, struct hp_sw_dh_data *h,switch (sshdr->sense_key) {case NOT_READY : -if (sshdr->asc ==0x04 && sshdr->ascq ==2 ) { +if (sshdr->sense_code == +LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED ) {/* * LUN not ready - Initialization command required *
@@ -61,8 +62,8 @@ static int tur_done(struct scsi_device *sdev, struct hp_sw_dh_data *h,default :sdev_printk (KERN_WARNING , sdev,"%s: sending tur failed, sense %x/%x/%x\n" , -HP_SW_NAME , sshdr->sense_key, sshdr->asc, - sshdr->ascq); +HP_SW_NAME , sshdr->sense_key, +scsi_sense_asc (sshdr),scsi_sense_ascq (sshdr));break ; }return ret;
@@ -85,8 +86,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)struct scsi_failure failure_defs[] = { { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .allowed =SCMD_FAILURE_NO_LIMIT , .result =SAM_STAT_CHECK_CONDITION , },
@@ -133,14 +133,9 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER ;struct scsi_failure failure_defs[] = { { -/* -* LUN not ready - manual intervention required -* -* Switch-over in progress, retry. -*/ +/* Switch-over in progress, retry. */ .sense_key =NOT_READY , - .asc =0x04 , - .ascq =0x03 , + .sense_code =LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED , .allowed =HP_SW_RETRIES , .result =SAM_STAT_CHECK_CONDITION , },
@@ -167,7 +162,8 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)switch (sshdr.sense_key) {case NOT_READY : -if (sshdr.asc ==0x04 && sshdr.ascq ==3 ) { +if (sshdr.sense_code == +LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED ) { rc =SCSI_DH_RETRY ;break ; }
@@ -176,7 +172,8 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)sdev_printk (KERN_WARNING , sdev,"%s: sending start_stop_unit failed, " "sense %x/%x/%x\n" ,HP_SW_NAME , - sshdr.sense_key, sshdr.asc, sshdr.ascq); + sshdr.sense_key,scsi_sense_asc (&sshdr), +scsi_sense_ascq (&sshdr)); rc =SCSI_DH_IO ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 13/40] scsi: device_handlers: hp_sw: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Refactor the HP sw device handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
Re: [PATCH v2 13/40] scsi: device_handlers: hp_sw: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 7 lines · Damien Le Moal
Refactor the HP sw device handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 25 +++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 14/40 scsi: device_handlers: rdac: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the NetApp E-Series RDAC SCSI device handler driver to use the 16-bits sense_code field of struct scsi_sense_hdr and struct scsi_failure and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/device_handler/scsi_dh_rdac.c | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-)
drivers/scsi/device_handler/scsi_dh_rdac.c +21 -24
@@ -493,7 +493,8 @@ static int mode_select_handle_sense(struct scsi_device *sdev,RDAC_LOG (RDAC_LOG_FAILOVER , sdev,"array %s, ctlr %d, " "MODE_SELECT returned with sense %02x/%02x/%02x" , (char *) h->ctlr->array_name, h->ctlr->index, - sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq); + sense_hdr->sense_key,scsi_sense_asc (sense_hdr), +scsi_sense_ascq (sense_hdr));return SCSI_DH_IO ; }
@@ -515,34 +516,28 @@ static void send_mode_select(struct work_struct *work)struct scsi_failure failure_defs[] = { { .sense_key =NO_SENSE , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =ABORTED_COMMAND , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .result =SAM_STAT_CHECK_CONDITION , }, { .sense_key =UNIT_ATTENTION , - .asc =SCMD_FAILURE_ASC_ANY , - .ascq =SCMD_FAILURE_ASCQ_ANY , + .sense_code =SCMD_FAILURE_SENSE_CODE_ANY , .result =SAM_STAT_CHECK_CONDITION , }, -/* LUN Not Ready and is in the Process of Becoming Ready */ { .sense_key =NOT_READY , - .asc =0x04 , - .ascq =0x01 , + .sense_code =LU_IS_IN_PROCESS_OF_BECOMING_READY , .result =SAM_STAT_CHECK_CONDITION , }, -/* Command Lock contention */ +/* Command Lock contention (not a standard sense code) */ { .sense_key =ILLEGAL_REQUEST , - .asc =0x91 , - .ascq =0x36 , + .sense_code =scsi_sense_code (0x91 ,0x36 ), .allowed =SCMD_FAILURE_NO_LIMIT , .result =SAM_STAT_CHECK_CONDITION , },
@@ -674,33 +669,34 @@ static enum scsi_disposition rdac_check_sense(struct scsi_device *sdev, {struct rdac_dh_data *h = sdev->handler_data; -RDAC_LOG (RDAC_LOG_SENSE , sdev,"array %s, ctlr %d, " -"I/O returned with sense %02x/%02x/%02x" , - (char *) h->ctlr->array_name, h->ctlr->index, - sense_hdr->sense_key, sense_hdr->asc, sense_hdr->ascq); +RDAC_LOG (RDAC_LOG_SENSE , sdev, +"array %s, ctlr %d, I/O returned with sense %02x/%02x/%02x" , + (char *) h->ctlr->array_name, h->ctlr->index, + sense_hdr->sense_key,scsi_sense_asc (sense_hdr), +scsi_sense_ascq (sense_hdr));switch (sense_hdr->sense_key) {case NOT_READY : -if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x01 ) +if (sense_hdr->sense_code ==LU_IS_IN_PROCESS_OF_BECOMING_READY )/* LUN Not Ready - Logical Unit Not Ready and is in * the process of becoming ready * Just retry. */ return ADD_TO_MLQUEUE ; -if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x81 ) +if (sense_hdr->sense_code ==scsi_sense_code (0x04 ,0x81 ))/* LUN Not Ready - Storage firmware incompatible * Manual code synchonisation required. * * Nothing we can do here. Try to bypass the path. */ return SUCCESS ; -if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0xA1 ) +if (sense_hdr->sense_code ==scsi_sense_code (0x04 ,0xA1 ))/* LUN Not Ready - Quiescense in progress * * Just retry and wait. */ return ADD_TO_MLQUEUE ; -if (sense_hdr->asc ==0xA1 && sense_hdr->ascq ==0x02 ) +if (sense_hdr->sense_code ==scsi_sense_code (0xA1 ,0x02 ))/* LUN Not Ready - Quiescense in progress * or has been achieved * Just retry.
@@ -708,7 +704,7 @@ static enum scsi_disposition rdac_check_sense(struct scsi_device *sdev,return ADD_TO_MLQUEUE ;break ;case ILLEGAL_REQUEST : -if (sense_hdr->asc ==0x94 && sense_hdr->ascq ==0x01 ) { +if (sense_hdr->sense_code ==scsi_sense_code (0x94 ,0x01 )) {/* Invalid Request - Current Logical Unit Ownership. * Controller is not the current owner of the LUN, * Fail the path, so that the other path be used.
@@ -718,12 +714,13 @@ static enum scsi_disposition rdac_check_sense(struct scsi_device *sdev, }break ;case UNIT_ATTENTION : -if (sense_hdr->asc ==0x29 && sense_hdr->ascq ==0x00 ) +if (sense_hdr->sense_code == +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED )/* * Power On, Reset, or Bus Device Reset, just retry. */ return ADD_TO_MLQUEUE ; -if (sense_hdr->asc ==0x8b && sense_hdr->ascq ==0x02 ) +if (sense_hdr->sense_code ==scsi_sense_code (0x8b ,0x02 ))/* * Quiescence in progress , just retry. */
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 14/40] scsi: device_handlers: rdac: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Refactor the NetApp E-Series RDAC SCSI device handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
Re: [PATCH v2 14/40] scsi: device_handlers: rdac: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 7 lines · Damien Le Moal
Refactor the NetApp E-Series RDAC SCSI device handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand structscsi_failureand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/device_handler/scsi_dh_rdac.c | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 15/40 scsi: device_handlers: emc: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the EMC SCSI device handler driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/device_handler/scsi_dh_emc.c | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/scsi/device_handler/scsi_dh_emc.c +15 -13
@@ -105,10 +105,10 @@ static int trespass_endio(struct scsi_device *sdev,sdev_printk (KERN_ERR , sdev,"%s: Found valid sense data 0x%2x, " "0x%2x, 0x%2x while sending CLARiiON trespass " "command.\n" ,CLARIION_NAME , sshdr->sense_key, - sshdr->asc, sshdr->ascq); +scsi_sense_asc (sshdr),scsi_sense_ascq (sshdr)); -if (sshdr->sense_key ==0x05 && sshdr->asc ==0x04 && - sshdr->ascq ==0x00 ) { +if (sshdr->sense_key ==ILLEGAL_REQUEST && + sshdr->sense_code ==LU_NOT_READY ) {/* * Array based copy in progress -- do not send * mode_select or copy will be aborted mid-stream.
@@ -117,18 +117,18 @@ static int trespass_endio(struct scsi_device *sdev,"progress while sending CLARiiON trespass " "command.\n", CLARIION_NAME); err =SCSI_DH_DEV_TEMP_BUSY ; - }else if (sshdr->sense_key ==0x02 && sshdr->asc ==0x04 && - sshdr->ascq ==0x03 ) { -/* -* LUN Not Ready - Manual Intervention Required -* indicates in-progress ucode upgrade (NDU). -*/ + }else if (sshdr->sense_key ==NOT_READY && + sshdr->sense_code == +LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED ) { +/* Indicates in-progress ucode upgrade (NDU). */ sdev_printk (KERN_INFO , sdev,"%s: Detected in-progress " "ucode upgrade NDU operation while sending " "CLARiiON trespass command.\n" ,CLARIION_NAME ); err =SCSI_DH_DEV_TEMP_BUSY ; - }else + }else { err =SCSI_DH_DEV_FAILED ; + } +return err; }
@@ -288,7 +288,8 @@ static enum scsi_disposition clariion_check_sense(struct scsi_device *sdev, {switch (sense_hdr->sense_key) {case NOT_READY : -if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x03 ) +if (sense_hdr->sense_code == +LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED )/* * LUN Not Ready - Manual Intervention Required * indicates this is a passive path.
@@ -305,7 +306,7 @@ static enum scsi_disposition clariion_check_sense(struct scsi_device *sdev,return SUCCESS ;break ;case ILLEGAL_REQUEST : -if (sense_hdr->asc ==0x25 && sense_hdr->ascq ==0x01 ) +if (sense_hdr->sense_code ==scsi_sense_code (0x25 ,0x01 ))/* * An array based copy is in progress. Do not * fail the path, do not bypass to another PG,
@@ -319,7 +320,8 @@ static enum scsi_disposition clariion_check_sense(struct scsi_device *sdev,return SUCCESS ;break ;case UNIT_ATTENTION : -if (sense_hdr->asc ==0x29 && sense_hdr->ascq ==0x00 ) +if (sense_hdr->sense_code == +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED )/* * Unit Attention Code. This is the first IO * to the new path, so just retry.
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 15/40] scsi: device_handlers: emc: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the EMC SCSI device handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=15
Re: [PATCH v2 15/40] scsi: device_handlers: emc: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the EMC SCSI device handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/device_handler/scsi_dh_emc.c | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 16/40 scsi: device_handlers: alua: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the SCSI ALUA devie handler driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/device_handler/scsi_dh_alua.c | 55 ++++++++-------------- 1 file changed, 19 insertions(+), 36 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +19 -36
@@ -433,61 +433,43 @@ static enum scsi_disposition alua_check_sense(struct scsi_device *sdev, {switch (sense_hdr->sense_key) {case NOT_READY : -if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x0a ) { -/* -* LUN Not Accessible - ALUA state transition -*/ +if (sense_hdr->sense_code == +LU_NOT_ACCESSIBLE_ASYMMETRIC_ACCESS_STATE_TRANSITION ) {alua_handle_state_transition (sdev);return NEEDS_RETRY ; }break ;case UNIT_ATTENTION : -if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x0a ) { -/* -* LUN Not Accessible - ALUA state transition -*/ +if (sense_hdr->sense_code == +LU_NOT_ACCESSIBLE_ASYMMETRIC_ACCESS_STATE_TRANSITION ) {alua_handle_state_transition (sdev);return NEEDS_RETRY ; } -if (sense_hdr->asc ==0x29 && sense_hdr->ascq ==0x00 ) { +if (sense_hdr->sense_code == +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED ) {/* -* Power On, Reset, or Bus Device Reset. * Might have obscured a state transition, * so schedule a recheck. */ alua_check (sdev, true);return ADD_TO_MLQUEUE ; } -if (sense_hdr->asc ==0x29 && sense_hdr->ascq ==0x04 ) -/* -* Device internal reset -*/ +if (sense_hdr->sense_code ==DEVICE_INTERNAL_RESET )return ADD_TO_MLQUEUE ; -if (sense_hdr->asc ==0x2a && sense_hdr->ascq ==0x01 ) -/* -* Mode Parameters Changed -*/ +if (sense_hdr->sense_code ==MODE_PARAMETERS_CHANGED )return ADD_TO_MLQUEUE ; -if (sense_hdr->asc ==0x2a && sense_hdr->ascq ==0x06 ) { -/* -* ALUA state changed -*/ +if (sense_hdr->sense_code ==ASYMMETRIC_ACCESS_STATE_CHANGED ) {alua_check (sdev, true);return ADD_TO_MLQUEUE ; } -if (sense_hdr->asc ==0x2a && sense_hdr->ascq ==0x07 ) { -/* -* Implicit ALUA state transition failed -*/ +if (sense_hdr->sense_code == +IMPLICIT_ASYMMETRIC_ACCESS_STATE_TRANSITION_FAILED ) {alua_check (sdev, true);return ADD_TO_MLQUEUE ; } -if (sense_hdr->asc ==0x3f && sense_hdr->ascq ==0x03 ) -/* -* Inquiry data has changed -*/ +if (sense_hdr->sense_code ==INQUIRY_DATA_HAS_CHANGED )return ADD_TO_MLQUEUE ; -if (sense_hdr->asc ==0x3f && sense_hdr->ascq ==0x0e ) +if (sense_hdr->sense_code ==REPORTED_LUNS_DATA_HAS_CHANGED )/* * REPORTED_LUNS_DATA_HAS_CHANGED is reported * when switching controllers on targets like
@@ -517,12 +499,12 @@ static int alua_tur(struct scsi_device *sdev) ALUA_FAILOVER_RETRIES, &sense_hdr);if ((sense_hdr.sense_key ==NOT_READY || sense_hdr.sense_key ==UNIT_ATTENTION ) && - sense_hdr.asc ==0x04 && sense_hdr.ascq ==0x0a ) + sense_hdr.sense_code == +LU_NOT_ACCESSIBLE_ASYMMETRIC_ACCESS_STATE_TRANSITION )return SCSI_DH_RETRY ; -else if (retval) +if (retval)return SCSI_DH_IO ; -else -return SCSI_DH_OK ; +return SCSI_DH_OK ; }/*
@@ -619,7 +601,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)* transition. So set the state to 'transitioning' directly. */ if (sense_hdr.sense_key ==NOT_READY && - sense_hdr.asc ==0x04 && sense_hdr.ascq ==0x0a ) { + sense_hdr.sense_code == +LU_NOT_ACCESSIBLE_ASYMMETRIC_ACCESS_STATE_TRANSITION ) { transitioning_sense = true; goto skip_rtpg; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 16/40] scsi: device_handlers: alua: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the SCSI ALUA devie handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
Re: [PATCH v2 16/40] scsi: device_handlers: alua: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the SCSI ALUA devie handler driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/device_handler/scsi_dh_alua.c | 55 ++++++++-------------- 1 file changed, 19 insertions(+), 36 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 17/40 scsi: mpt3sas: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the mpt3sas driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 69 +++++++++++++++------------- 1 file changed, 36 insertions(+), 33 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +36 -33
@@ -5401,23 +5401,23 @@ _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,static void _scsih_eedp_error_handling (struct scsi_cmnd *scmd,u16 ioc_status) { -u8 ascq; +u16 sense_code;switch (ioc_status) {case MPI2_IOCSTATUS_EEDP_GUARD_ERROR : - ascq =0x01 ; + sense_code =LOGICAL_BLOCK_GUARD_CHECK_FAILED ;break ;case MPI2_IOCSTATUS_EEDP_APP_TAG_ERROR : - ascq =0x02 ; + sense_code =LOGICAL_BLOCK_APPLICATION_TAG_CHECK_FAILED ;break ;case MPI2_IOCSTATUS_EEDP_REF_TAG_ERROR : - ascq =0x03 ; + sense_code =LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED ;break ;default : - ascq =0x00 ; + sense_code =ID_CRC_OR_ECC_ERROR ;break ; } -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x10 , ascq); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , sense_code);set_host_byte (scmd,DID_ABORT ); }
@@ -5474,7 +5474,8 @@ static enum scsi_qc_status scsih_qcmd(struct Scsi_Host *shost,if (handle ==MPT3SAS_INVALID_DEVICE_HANDLE || sas_device_priv_data->block) {if (scsi_get_host_state (scmd->device->host) ==SHOST_RECOVERY && scmd->cmnd[0 ] ==TEST_UNIT_READY ) { -scsi_build_sense (scmd,0 ,UNIT_ATTENTION ,0x29 ,0x07 ); +scsi_set_sense (scmd,0 ,UNIT_ATTENTION , +I_T_NEXUS_LOSS_OCCURRED );scsi_done (scmd);return 0 ; }
@@ -5986,7 +5987,7 @@ _scsih_smart_predicted_fault(struct MPT3SAS_ADAPTER *ioc, u16 handle) event_data = (Mpi2EventDataSasDeviceStatusChange_t *) event_reply->EventData; event_data->ReasonCode =MPI2_EVENT_SAS_DEV_STAT_RC_SMART_DATA ; - event_data->ASC =0x5D ; + event_data->ASC =ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED ; event_data->DevHandle =cpu_to_le16 (handle); event_data->SASAddress =cpu_to_le64 (sas_target_priv_data->sas_address);mpt3sas_ctl_add_to_event_log (ioc, event_reply);
@@ -6109,8 +6110,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) le32_to_cpu(mpi_reply->SenseCount));memcpy (scmd->sense_buffer, sense_data, sz);_scsih_normalize_sense (scmd->sense_buffer, &data); -/* failure prediction threshold exceeded */ -if (data.asc ==0x5D ) +if (data.asc ==ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED )_scsih_smart_predicted_fault (ioc,le16_to_cpu (mpi_reply->DevHandle));mpt3sas_trigger_scsi (ioc, data.skey, data.asc, data.ascq);
@@ -6199,8 +6199,8 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)else if (!xfer_cnt && scmd->cmnd[0 ] ==REPORT_LUNS ) { mpi_reply->SCSIState =MPI2_SCSI_STATE_AUTOSENSE_VALID ; mpi_reply->SCSIStatus =SAM_STAT_CHECK_CONDITION ; -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST , -0x20 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_COMMAND_OP_CODE ); }break ;
@@ -7691,38 +7691,41 @@ _scsih_determine_disposition(struct MPT3SAS_ADAPTER *ioc,if (check_sense) {_scsih_normalize_sense (transfer_packet->sense, &sense_info); -if (sense_info.skey ==UNIT_ATTENTION ) +if (sense_info.skey ==UNIT_ATTENTION ) { rc =DEVICE_RETRY_UA ; -else if (sense_info.skey ==NOT_READY ) { -/* medium isn't present */ -if (sense_info.asc ==0x3a ) + }else if (sense_info.skey ==NOT_READY ) { +if (sense_info.asc ==ASC_MEDIUM_NOT_PRESENT ) { rc =DEVICE_READY ; -/* LOGICAL UNIT NOT READY */ -else if (sense_info.asc ==0x04 ) { -if (sense_info.ascq ==0x03 || - sense_info.ascq ==0x0b || - sense_info.ascq ==0x0c ) { + }else if (sense_info.asc ==ASC_LU_NOT_READY ) { +u16 scode =scsi_sense_code (sense_info.asc, + sense_info.ascq); + +if (scode == +LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED || + scode == +LU_NOT_ACCESSIBLE_TARGET_PORT_IN_STANDBY_STATE || + scode == +LU_NOT_ACCESSIBLE_TARGET_PORT_IN_UNAVAILABLE_STATE ) rc =DEVICE_ERROR ; - }else +else rc =DEVICE_START_UNIT ; - } -/* LOGICAL UNIT HAS NOT SELF-CONFIGURED YET */ -else if (sense_info.asc ==0x3e && !sense_info.ascq) + }else if (sense_info.asc == +ASC_LU_HAS_NOT_SELF_CONFIGURED_YET && + !sense_info.ascq) { rc =DEVICE_START_UNIT ; + } }else if (sense_info.skey ==ILLEGAL_REQUEST && - transfer_packet->cdb[0 ] ==REPORT_LUNS ) { + transfer_packet->cdb[0 ] ==REPORT_LUNS ) { rc =DEVICE_READY ; }else if (sense_info.skey ==MEDIUM_ERROR ) { - -/* medium is corrupt, lets add the device so -* users can collect some info as needed +/* +* medium is corrupt, lets add the device so users can +* collect some info as needed */ - -if (sense_info.asc ==0x31 ) +if (sense_info.asc ==ASC_MEDIUM_FORMAT_CORRUPTED ) rc =DEVICE_READY ; }else if (sense_info.skey ==HARDWARE_ERROR ) { -/* Defect List Error, still add the device */ -if (sense_info.asc ==0x19 ) +if (sense_info.asc ==ASC_DEFECT_LIST_ERROR ) rc =DEVICE_READY ; } }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 17/40] scsi: mpt3sas: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
Refactor the mpt3sas driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17
Re: [PATCH v2 17/40] scsi: mpt3sas: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 5 lines · Damien Le Moal
Refactor the mpt3sas driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 69 +++++++++++++++------------- 1 file changed, 36 insertions(+), 33 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 18/40 scsi: mpi3mr: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the mpi3mr driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 3 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 50 +++++++++++++++++---------------- 2 files changed, 28 insertions(+), 25 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_fw.c +2 -1
@@ -404,7 +404,8 @@ static void mpi3mr_process_admin_reply_desc(struct mpi3mr_ioc *mrioc,scsi_normalize_sense (sense_buf, sense_count, &sshdr);mpi3mr_scsisense_trigger (mrioc, sshdr.sense_key, - sshdr.asc, sshdr.ascq); +scsi_sense_asc (&sshdr), +scsi_sense_ascq (&sshdr)); } }mpi3mr_reply_trigger (mrioc, masked_ioc_status, ioc_loginfo);
drivers/scsi/mpi3mr/mpi3mr_os.c +26 -24
132 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 18/40] scsi: mpi3mr: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the mpi3mr driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=18
Re: [PATCH v2 18/40] scsi: mpi3mr: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the mpi3mr driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 8 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 3 +- drivers/scsi/mpi3mr/mpi3mr_os.c | 50 +++++++++++++++++---------------- 2 files changed, 28 insertions(+), 25 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 19/40 scsi: 3w-xxxx: use 16-bits defined sense codes
In reply to Damien Le MoalModify the function tw_scsi_queue_lck() of the 3w-xxxx driver to use scsi_set_sense() and replace the hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/3w-xxxx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/3w-xxxx.c +2 -1
@@ -1977,7 +1977,8 @@ static enum scsi_qc_status tw_scsi_queue_lck(struct scsi_cmnd *SCpnt)printk (KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n" , tw_dev->host->host_no, *command); tw_dev->state[request_id] =TW_S_COMPLETED ;tw_state_request_finish (tw_dev, request_id); -scsi_build_sense (SCpnt,1 ,ILLEGAL_REQUEST ,0x20 ,0 ); +scsi_set_sense (SCpnt,1 ,ILLEGAL_REQUEST , +INVALID_COMMAND_OP_CODE );done (SCpnt); retval =0 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 19/40] scsi: 3w-xxxx: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Modify the function
tw_scsi_queue_lck()of the 3w-xxxx driver to usescsi_set_sense()and replace the hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=19
Re: [PATCH v2 19/40] scsi: 3w-xxxx: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Modify the function
tw_scsi_queue_lck()of the 3w-xxxx driver to usescsi_set_sense()and replace the hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/3w-xxxx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 20/40 scsi: leapraid: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the leapraid driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
With this change, the locally defined macros for ASC and ASCQ values are deleted.
No functional change intended.
--- drivers/scsi/leapraid/leapraid_func.h | 7 ------- drivers/scsi/leapraid/leapraid_os.c | 15 +++++++-------- 2 files changed, 7 insertions(+), 15 deletions(-)
drivers/scsi/leapraid/leapraid_func.h +0 -7
@@ -113,7 +113,6 @@#define DESC_FORMAT_THRESHOLD 0x72#define SENSE_KEY_MASK 0x0F#define SCSI_SENSE_RESPONSE_CODE_MASK 0x7F -#define ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED 0x5D#define LEAPRAID_LARGE_DISK_THRESHOLD 0x200000UL#define LEAPRAID_LARGE_DISK_HEADS 255#define LEAPRAID_LARGE_DISK_SECTORS 63
@@ -126,12 +125,6 @@#define LEAPRAID_SCSI_HOST_SHIFT 16#define LEAPRAID_SCSI_DRIVER_SHIFT 24 -/* SCSI ASC/ASCQ definitions. */ -#define LEAPRAID_SCSI_ASCQ_DEFAULT 0x00 -#define LEAPRAID_SCSI_ASC_POWER_ON_RESET 0x29 -#define LEAPRAID_SCSI_ASC_INVALID_CMD_CODE 0x20 -#define LEAPRAID_SCSI_ASCQ_POWER_ON_RESET 0x07 -/* VPD Page 0x89 (ATA Information). */ #define LEAPRAID_VPD_PAGE_ATA_INFO 0x89#define LEAPRAID_VPD_PG89_MAX_LEN 255
drivers/scsi/leapraid/leapraid_os.c +7 -8
@@ -382,9 +382,8 @@ static void leapraid_handle_data_underrun( }else if (!xfer_cnt && scmd->cmnd[0 ] ==REPORT_LUNS ) { scsiio_rep->scsi_state =LEAPRAID_SCSI_STATE_AUTOSENSE_VALID ; scsiio_rep->scsi_status =SAM_STAT_CHECK_CONDITION ; -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST , -LEAPRAID_SCSI_ASC_INVALID_CMD_CODE , -LEAPRAID_SCSI_ASCQ_DEFAULT ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_COMMAND_OP_CODE ); } }
@@ -515,8 +514,9 @@ static void leapraid_scsiio_done_dispatch( &sshdr))dev_warn (&adapter->pdev->dev,"Sense: key=0x%x asc=0x%x ascq=0x%x\n" , - sshdr.sense_key, sshdr.asc, - sshdr.ascq); + sshdr.sense_key, +scsi_sense_asc (&sshdr), +scsi_sense_ascq (&sshdr)); else dev_warn(&adapter->pdev->dev, "Sense: Invalid sense data\n");
@@ -810,9 +810,8 @@ static bool leapraid_should_queuecommand(struct leapraid_adapter *adapter,if (sdev_priv->block &&scsi_get_host_state (scmd->device->host) ==SHOST_RECOVERY && scmd->cmnd[0 ] ==TEST_UNIT_READY ) { -scsi_build_sense (scmd,0 ,UNIT_ATTENTION , -LEAPRAID_SCSI_ASC_POWER_ON_RESET , -LEAPRAID_SCSI_ASCQ_POWER_ON_RESET ); +scsi_set_sense (scmd,0 ,UNIT_ATTENTION , +I_T_NEXUS_LOSS_OCCURRED ); goto scsiio_done; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 20/40] scsi: leapraid: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 6 lines
Refactor the leapraid driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 6 lines
With this change, the locally defined macros for ASC and ASCQ values are deleted.
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=20
Re: [PATCH v2 20/40] scsi: leapraid: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 9 lines · Damien Le Moal
Refactor the leapraid driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.With this change, the locally defined macros for ASC and ASCQ values are deleted.
Quoted 8 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/leapraid/leapraid_func.h | 7 ------- drivers/scsi/leapraid/leapraid_os.c | 15 +++++++-------- 2 files changed, 7 insertions(+), 15 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 21/40 scsi: megaraid: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the megaraid driver to use the scsi_set_sense() function and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/megaraid.c | 8 +++++--- drivers/scsi/megaraid/mega_common.h | 2 -- drivers/scsi/megaraid/megaraid_mbox.c | 12 +++++++----- 3 files changed, 12 insertions(+), 10 deletions(-)
drivers/scsi/megaraid.c +5 -3
@@ -1592,9 +1592,11 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) epthru->reqsensearea, 14); cmd->result =SAM_STAT_CHECK_CONDITION ; - }else -scsi_build_sense (cmd,0 , -ABORTED_COMMAND ,0 ,0 ); + }else { +scsi_set_sense (cmd,0 , +ABORTED_COMMAND , +NO_ADDITIONAL_SENSE_INFORMATION ); + } }break ;
drivers/scsi/megaraid/mega_common.h +0 -2
@@ -37,8 +37,6 @@#define PCI_CONF_AMISIG64 0xa4#define MEGA_SCSI_INQ_EVPD 1 -#define MEGA_INVALID_FIELD_IN_CDB 0x24 -/** * scb_t - scsi command control block
drivers/scsi/megaraid/megaraid_mbox.c +7 -5
@@ -1577,8 +1577,8 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, }if (scp->cmnd[1 ] &MEGA_SCSI_INQ_EVPD ) { -scsi_build_sense (scp,0 ,ILLEGAL_REQUEST , -MEGA_INVALID_FIELD_IN_CDB ,0 ); +scsi_set_sense (scp,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB );return NULL ; }
@@ -2311,9 +2311,11 @@ megaraid_mbox_dpc(unsigned long devp) epthru->reqsensearea, 14); scp->result =SAM_STAT_CHECK_CONDITION ; - }else -scsi_build_sense (scp,0 , -ABORTED_COMMAND ,0 ,0 ); + }else { +scsi_set_sense (scp,0 , +ABORTED_COMMAND , +NO_ADDITIONAL_SENSE_INFORMATION ); + } }break ;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 21/40] scsi: megaraid: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the megaraid driver to use the
scsi_set_sense()function and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=21
Re: [PATCH v2 21/40] scsi: megaraid: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the megaraid driver to use the
scsi_set_sense()function and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 9 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/megaraid.c | 8 +++++--- drivers/scsi/megaraid/mega_common.h | 2 -- drivers/scsi/megaraid/megaraid_mbox.c | 12 +++++++----- 3 files changed, 12 insertions(+), 10 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 22/40 scsi: myrX: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the Mylex RAID controller driver to use scsi_set_sense() and the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/myrb.c | 67 +++++++++++++++++++++++---------------------- drivers/scsi/myrs.c | 23 ++++++++++------ 2 files changed, 48 insertions(+), 42 deletions(-)
drivers/scsi/myrb.c +34 -33
@@ -314,17 +314,19 @@ static void myrb_get_event(struct myrb_hba *cb, unsigned int event)scsi_normalize_sense (ev_buf->sense,32 , &sshdr);if (sshdr.sense_key ==VENDOR_SPECIFIC && - sshdr.asc ==0x80 && - sshdr.ascq <ARRAY_SIZE (myrb_event_msg)) +scsi_sense_asc (&sshdr) ==0x80 && +scsi_sense_ascq (&sshdr) <ARRAY_SIZE (myrb_event_msg))shost_printk (KERN_CRIT , cb->host,"Physical drive %d:%d: %s\n" , ev_buf->channel, ev_buf->target, - myrb_event_msg[sshdr.ascq]); + myrb_event_msg[scsi_sense_ascq (&sshdr)]);else shost_printk (KERN_CRIT , cb->host,"Physical drive %d:%d: Sense: %X/%02X/%02X\n" , ev_buf->channel, ev_buf->target, - sshdr.sense_key, sshdr.asc, sshdr.ascq); + sshdr.sense_key, +scsi_sense_asc (&sshdr), +scsi_sense_ascq (&sshdr)); } dma_free_coherent(&cb->pdev->dev, sizeof(struct myrb_log_entry),
@@ -1398,7 +1400,7 @@ myrb_mode_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd,static void myrb_request_sense (struct myrb_hba *cb,struct scsi_cmnd *scmd) { -scsi_build_sense (scmd,0 ,NO_SENSE ,0 ,0 ); +scsi_set_sense (scmd,0 ,NO_SENSE ,NO_ADDITIONAL_SENSE_INFORMATION );scsi_sg_copy_from_buffer (scmd, scmd->sense_buffer,SCSI_SENSE_BUFFERSIZE ); }
@@ -1446,8 +1448,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,return 0 ;case INQUIRY :if (scmd->cmnd[1 ] &1 ) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB ); }else {myrb_inquiry (cb, scmd); scmd->result = (DID_OK <<16 );
@@ -1461,8 +1463,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,case MODE_SENSE :if ((scmd->cmnd[2 ] &0x3F ) !=0x3F && (scmd->cmnd[2 ] &0x3F ) !=0x08 ) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB ); }else {myrb_mode_sense (cb, scmd, ldev_info); scmd->result = (DID_OK <<16 );
@@ -1472,15 +1474,15 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,case READ_CAPACITY :if ((scmd->cmnd[1 ] &1 ) || (scmd->cmnd[8 ] &1 )) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB );scsi_done (scmd);return 0 ; } lba =get_unaligned_be32 (&scmd->cmnd[2 ]);if (lba) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB );scsi_done (scmd);return 0 ; }
@@ -1493,8 +1495,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,return 0 ;case SEND_DIAGNOSTIC :if (scmd->cmnd[1 ] !=0x04 ) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB ); }else {/* Assume good status */ scmd->result = (DID_OK <<16 );
@@ -1503,8 +1505,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,return 0 ;case READ_6 :if (ldev_info->state ==MYRB_DEVICE_WO ) { -/* Data protect, attempt to read invalid data */ -scsi_build_sense (scmd,0 ,DATA_PROTECT ,0x21 ,0x06 ); +scsi_set_sense (scmd,0 ,DATA_PROTECT , +ATTEMPT_TO_READ_INVALID_DATA );scsi_done (scmd);return 0 ; }
@@ -1517,8 +1519,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,break ;case READ_10 :if (ldev_info->state ==MYRB_DEVICE_WO ) { -/* Data protect, attempt to read invalid data */ -scsi_build_sense (scmd,0 ,DATA_PROTECT ,0x21 ,0x06 ); +scsi_set_sense (scmd,0 ,DATA_PROTECT , +ATTEMPT_TO_READ_INVALID_DATA );scsi_done (scmd);return 0 ; }
@@ -1531,8 +1533,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,break ;case READ_12 :if (ldev_info->state ==MYRB_DEVICE_WO ) { -/* Data protect, attempt to read invalid data */ -scsi_build_sense (scmd,0 ,DATA_PROTECT ,0x21 ,0x06 ); +scsi_set_sense (scmd,0 ,DATA_PROTECT , +ATTEMPT_TO_READ_INVALID_DATA );scsi_done (scmd);return 0 ; }
@@ -1544,8 +1546,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost, block_cnt =get_unaligned_be32 (&scmd->cmnd[6 ]);break ;default : -/* Illegal request, invalid opcode */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x20 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_COMMAND_OP_CODE );scsi_done (scmd);return 0 ; }
@@ -2328,20 +2330,19 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk,dev_dbg (&scmd->device->sdev_gendev,"Bad Data Encountered\n" );if (scmd->sc_data_direction ==DMA_FROM_DEVICE ) -/* Unrecovered read error */ -scsi_build_sense (scmd,0 ,MEDIUM_ERROR ,0x11 ,0 ); +scsi_set_sense (scmd,0 ,MEDIUM_ERROR , +UNRECOVERED_READ_ERROR );else -/* Write error */ -scsi_build_sense (scmd,0 ,MEDIUM_ERROR ,0x0C ,0 ); +scsi_set_sense (scmd,0 ,MEDIUM_ERROR ,WRITE_ERROR );break ;case MYRB_STATUS_IRRECOVERABLE_DATA_ERROR :scmd_printk (KERN_ERR , scmd,"Irrecoverable Data Error\n" );if (scmd->sc_data_direction ==DMA_FROM_DEVICE ) -/* Unrecovered read error, auto-reallocation failed */ -scsi_build_sense (scmd,0 ,MEDIUM_ERROR ,0x11 ,0x04 ); +scsi_set_sense (scmd,0 ,MEDIUM_ERROR , +UNRECOVERED_READ_ERROR_AUTO_REALLOCATE_FAILED );else -/* Write error, auto-reallocation failed */ -scsi_build_sense (scmd,0 ,MEDIUM_ERROR ,0x0C ,0x02 ); +scsi_set_sense (scmd,0 ,MEDIUM_ERROR , +WRITE_ERROR_AUTO_REALLOCATION_FAILED );break ;case MYRB_STATUS_LDRV_NONEXISTENT_OR_OFFLINE : dev_dbg(&scmd->device->sdev_gendev,
@@ -2351,8 +2352,8 @@ static void myrb_handle_scsi(struct myrb_hba *cb, struct myrb_cmdblk *cmd_blk,case MYRB_STATUS_ACCESS_BEYOND_END_OF_LDRV :dev_dbg (&scmd->device->sdev_gendev,"Attempt to Access Beyond End of Logical Drive" ); -/* Logical block address out of range */ -scsi_build_sense (scmd,0 ,NOT_READY ,0x21 ,0 ); +scsi_set_sense (scmd,0 ,NOT_READY , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );break ;case MYRB_STATUS_DEVICE_NONRESPONSIVE :dev_dbg (&scmd->device->sdev_gendev,"Device nonresponsive\n" );
drivers/scsi/myrs.c +14 -9
@@ -816,7 +816,7 @@ static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev)struct Scsi_Host *shost = cs->host;struct scsi_device *sdev;struct scsi_sense_hdr sshdr = {0 }; -unsigned char sense_info[4 ]; +unsigned char asc, sense_info[4 ];unsigned char cmd_specific[4 ];if (ev->ev_code ==0x1C ) {
@@ -829,9 +829,11 @@ static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev)memcpy (cmd_specific, &ev->sense_data[7 ],4 ); } } + asc =scsi_sense_asc (&sshdr);if (sshdr.sense_key ==VENDOR_SPECIFIC && - (sshdr.asc ==0x80 || sshdr.asc ==0x81 )) - ev->ev_code = ((sshdr.asc -0x80 ) <<8 | sshdr.ascq); + (asc ==0x80 || asc ==0x81 )) + ev->ev_code =scsi_sense_code (asc -0x80 , +scsi_sense_ascq (&sshdr));while (true) { ev_code = myrs_ev_list[ev_idx].ev_code;if (ev_code == ev->ev_code || ev_code ==0 )
@@ -891,8 +893,9 @@ static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev)case 'S' :if (sshdr.sense_key ==NO_SENSE || (sshdr.sense_key ==NOT_READY && - sshdr.asc ==0x04 && (sshdr.ascq ==0x01 || - sshdr.ascq ==0x02 ))) + (sshdr.sense_code ==LU_IS_IN_PROCESS_OF_BECOMING_READY || + sshdr.sense_code == +LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED )))break ; shost_printk(KERN_INFO, shost, "event %d: Physical Device %d:%d %s\n",
@@ -900,7 +903,8 @@ static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev)shost_printk (KERN_INFO , shost,"Physical Device %d:%d Sense Key = %X, ASC = %02X, ASCQ = %02X\n" , ev->channel, ev->target, - sshdr.sense_key, sshdr.asc, sshdr.ascq); + sshdr.sense_key,scsi_sense_asc (&sshdr), +scsi_sense_ascq (&sshdr)); shost_printk(KERN_INFO, shost, "Physical Device %d:%d Sense Information = %02X%02X%02X%02X %02X%02X%02X%02X\n", ev->channel, ev->target,
@@ -1603,7 +1607,8 @@ static enum scsi_qc_status myrs_queuecommand(struct Scsi_Host *shost,switch (scmd->cmnd[0 ]) {case REPORT_LUNS : -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x20 ,0x0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_COMMAND_OP_CODE );scsi_done (scmd);return 0 ;case MODE_SENSE :
@@ -1612,8 +1617,8 @@ static enum scsi_qc_status myrs_queuecommand(struct Scsi_Host *shost,if ((scmd->cmnd[2 ] &0x3F ) !=0x3F && (scmd->cmnd[2 ] &0x3F ) !=0x08 ) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB ); }else {myrs_mode_sense (cs, scmd, ldev_info); scmd->result = (DID_OK <<16 );
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 22/40] scsi: myrX: use 16-bits defined sense codes
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Data Corruption: Incorrect offset used for writing the SCSI mode parameter block descriptor corrupts the 24-bit block length.
- [High] Command Timeout: The REQUEST_SENSE command in myrb_ldev_queuecommand returns without calling scsi_done(), leading to a hanging command.
- [High] Resource Leak: Returning SCSI_MLQUEUE_HOST_BUSY after a successful scsi_dma_map() without unmapping causes a DMA mapping leak.
- [High] Memory Leak: DMA pool allocations are leaked on the SG mapping error path in myrs_queuecommand.
--
commit 3eaecf993e28ec2a9d1c5ee8b1fc650d068a56f8
Author: Damien Le Moal <[email protected]>
scsi: myrX: use 16-bits defined sense codes
Refactor the Mylex RAID controller driver to use scsi_set_sense() and the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 4 lines
drivers/scsi/myrb.c +0
-0
[ ... ]
drivers/scsi/myrb.c myrb_mode_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd, · line 1406
Quoted 9 lines
drivers/scsi/myrb.c +1
-1@@ -1398,7 +1400,7 @@ myrb_mode_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd,static void myrb_request_sense (struct myrb_hba *cb,struct scsi_cmnd *scmd) { -scsi_build_sense (scmd,0 ,NO_SENSE ,0 ,0 ); +scsi_set_sense (scmd,0 ,NO_SENSE ,NO_ADDITIONAL_SENSE_INFORMATION );scsi_sg_copy_from_buffer (scmd, scmd->sense_buffer,SCSI_SENSE_BUFFERSIZE ); }
[Severity: High]
This is a pre-existing issue, but looking at how myrb_request_sense() is used in myrb_ldev_queuecommand() in drivers/scsi/myrb.c:
case REQUEST_SENSE: myrb_request_sense(cb, scmd); scmd->result = (DID_OK << 16); return 0;
Because returning 0 indicates to the SCSI midlayer that the driver has accepted the command and will complete it asynchronously, does failing to call scsi_done(scmd) here cause the command to hang indefinitely and eventually trigger a SCSI timeout?
[ ... ]
drivers/scsi/myrb.c static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost, · line 1469
Quoted 10 lines
drivers/scsi/myrb.c +2
-2@@ -1461,8 +1463,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,case MODE_SENSE :if ((scmd->cmnd[2 ] &0x3F ) !=0x3F && (scmd->cmnd[2 ] &0x3F ) !=0x08 ) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB ); }else {myrb_mode_sense (cb, scmd, ldev_info);
[Severity: Critical]
This is a pre-existing issue, but I noticed myrb_mode_sense() in drivers/scsi/myrb.c writes the block size to the mode page block descriptor using put_unaligned_be32():
static void myrb_mode_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd,
struct myrb_ldev_info *ldev_info)
{
...
put_unaligned_be32(cb->ldev_block_size, &block_desc[5]);
Since the block length in the descriptor is a 24-bit field located at offsets 5, 6, and 7, won't writing a 32-bit value at offset 5 overflow the LSB into offset 8 (the start of the mode page header)? For a typical 512 byte block size, it seems this writes 2 instead of 512, completely corrupting capacity reporting.
Quoted 1 line
drivers/scsi/myrb.c +0
-0scmd->result = (DID_OK <<16 );
[ ... ]
drivers/scsi/myrb.c static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost, · line 1553
Quoted 11 lines
drivers/scsi/myrb.c +2
-2@@ -1544,8 +1546,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost, block_cnt =get_unaligned_be32 (&scmd->cmnd[6 ]);break ;default : -/* Illegal request, invalid opcode */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x20 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_COMMAND_OP_CODE );scsi_done (scmd);return 0 ; }
[Severity: High]
This is a pre-existing issue, but later in myrb_ldev_queuecommand() in drivers/scsi/myrb.c, after the switch statement, the function maps DMA memory:
nsge = scsi_dma_map(scmd);
...
} else {
struct myrb_sge *hw_sgl;
dma_addr_t hw_sgl_addr;
int i;
hw_sgl = dma_pool_alloc(cb->sg_pool, GFP_ATOMIC, &hw_sgl_addr);
if (!hw_sgl)
return SCSI_MLQUEUE_HOST_BUSY;Does returning SCSI_MLQUEUE_HOST_BUSY without calling scsi_dma_unmap() cause a DMA mapping and IOMMU resource leak when the midlayer retries the command and maps it again?
Quoted 4 lines
drivers/scsi/myrs.c +0
-0
[ ... ]
Quoted 11 lines
drivers/scsi/myrs.c +2
-1@@ -1603,7 +1607,8 @@ static enum scsi_qc_status myrs_queuecommand(struct Scsi_Host *shost,switch (scmd->cmnd[0 ]) {case REPORT_LUNS : -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x20 ,0x0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_COMMAND_OP_CODE );scsi_done (scmd);return 0 ;case MODE_SENSE :
drivers/scsi/myrs.c static enum scsi_qc_status myrs_queuecommand(struct Scsi_Host *shost, · line 1623
Quoted 9 lines
drivers/scsi/myrs.c +2
-2@@ -1612,8 +1617,8 @@ static enum scsi_qc_status myrs_queuecommand(struct Scsi_Host *shost,if ((scmd->cmnd[2 ] &0x3F ) !=0x3F && (scmd->cmnd[2 ] &0x3F ) !=0x08 ) { -/* Illegal request, invalid field in CDB */ -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST , +INVALID_FIELD_IN_CDB ); }else {myrs_mode_sense (cs, scmd, ldev_info);
[Severity: Critical]
This is a pre-existing issue, but myrs_mode_sense() in drivers/scsi/myrs.c has the identical bug as myrb_mode_sense() when writing the mode page block descriptor:
static void myrs_mode_sense(struct myrs_hba *cs, struct scsi_cmnd *scmd,
struct myrs_ldev_info *ldev_info)
{
...
put_unaligned_be32(ldev_info->devsize_bytes, &block_desc[5]);
Does this similarly corrupt the 24-bit block length by writing a 32-bit value?
[Severity: High]
Additionally, this is another pre-existing issue in myrs_queuecommand() in drivers/scsi/myrs.c. When processing commands with scatterlists, if dma_pool_alloc() fails it returns SCSI_MLQUEUE_HOST_BUSY:
hw_sgl = dma_pool_alloc(cs->sg_pool, GFP_ATOMIC,
&hw_sgl_addr);
if (WARN_ON(!hw_sgl)) {
if (cmd_blk->dcdb) {
dma_pool_free(cs->dcdb_pool,
cmd_blk->dcdb,
cmd_blk->dcdb_dma);
...
return SCSI_MLQUEUE_HOST_BUSY;
}Since scsi_dma_map() was already called earlier in the function, does returning here without calling scsi_dma_unmap() leak the DMA mapping?
[Severity: High]
Finally, in the same scatterlist loop in myrs_queuecommand(), there is a sanity check on hw_sgl:
scsi_for_each_sg(scmd, sgl, nsge, i) {
if (WARN_ON(!hw_sgl)) {
scsi_dma_unmap(scmd);
scmd->result = (DID_ERROR << 16);
scsi_done(scmd);
return 0;
}When taking this error path, it calls scsi_done(scmd) but bypasses the normal completion routine myrs_handle_scsi(). Does this permanently leak the dma_pool_alloc() blocks for cmd_blk->sense and cmd_blk->dcdb?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=22
Re: [PATCH v2 22/40] scsi: myrX: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 7 lines · Damien Le Moal
Refactor the Mylex RAID controller driver to use
scsi_set_sense()and the 16-bitssense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 8 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/myrb.c | 67 +++++++++++++++++++++++---------------------- drivers/scsi/myrs.c | 23 ++++++++++------ 2 files changed, 48 insertions(+), 42 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 23/40 scsi: smartpqi: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the smartpqi driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/smartpqi/smartpqi_init.c | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +18 -13
@@ -3249,15 +3249,15 @@ static void pqi_process_raid_io_error(struct pqi_io_request *io_request) sense_data_length =sizeof (error_info->data);if (scsi_status ==SAM_STAT_CHECK_CONDITION && -scsi_normalize_sense (error_info->data, - sense_data_length, &sshdr) && - sshdr.sense_key ==HARDWARE_ERROR && - sshdr.asc ==0x3e ) { +scsi_normalize_sense (error_info->data, + sense_data_length, &sshdr) && + sshdr.sense_key ==HARDWARE_ERROR && +scsi_sense_asc (&sshdr) ==ASC_LU_HAS_NOT_SELF_CONFIGURED_YET ) {struct pqi_ctrl_info *ctrl_info =shost_to_hba (scmd->device->host);struct pqi_scsi_dev *device = scmd->device->hostdata; -switch (sshdr.ascq) { -case 0x1 :/* LOGICAL UNIT FAILURE */ +switch (sshdr.sense_code) { +case LU_FAILURE :if (printk_ratelimit ())scmd_printk (KERN_ERR , scmd,"received 'logical unit failure' from controller for scsi %d:%d:%d:%d\n" , ctrl_info->scsi_host->host_no, device->bus, device->target, device->lun);
@@ -3265,10 +3265,15 @@ static void pqi_process_raid_io_error(struct pqi_io_request *io_request) host_byte =DID_NO_CONNECT ;break ; -default :/* See http://www.t10.org/lists/asc-num.htm#ASC_3E */ +default : +/* include/scsi/scsi_sense.h */ if (printk_ratelimit ()) -scmd_printk (KERN_ERR , scmd,"received unhandled error %d from controller for scsi %d:%d:%d:%d\n" , - sshdr.ascq, ctrl_info->scsi_host->host_no, device->bus, device->target, device->lun); +scmd_printk (KERN_ERR , scmd, +"received unhandled error %d from controller for scsi %d:%d:%d:%d\n" , +scsi_sense_ascq (&sshdr), + ctrl_info->scsi_host->host_no, + device->bus, device->target, + device->lun);break ; } }
@@ -3286,11 +3291,11 @@ static void pqi_process_raid_io_error(struct pqi_io_request *io_request) sense_data_length && scsi_normalize_sense(error_info->data, sense_data_length, &sshdr) && sshdr.sense_key == ILLEGAL_REQUEST && - sshdr.asc == 0x26 && - sshdr.ascq == 0x0) { + sshdr.sense_code == INVALID_FIELD_IN_PARAMETER_LIST) { host_byte =DID_NO_CONNECT ;pqi_take_device_offline (scmd->device,"AIO" ); -scsi_build_sense_buffer (0 , scmd->sense_buffer,HARDWARE_ERROR ,0x3e ,0x1 ); +scsi_set_sense_buffer (0 , scmd->sense_buffer,HARDWARE_ERROR , +LU_FAILURE ); } scmd->result = scsi_status;
@@ -3380,7 +3385,7 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request) }if (device_offline && sense_data_length ==0 ) -scsi_build_sense (scmd,0 ,HARDWARE_ERROR ,0x3e ,0x1 ); +scsi_set_sense (scmd,0 ,HARDWARE_ERROR ,LU_FAILURE ); scmd->result = scsi_status;set_host_byte (scmd, host_byte);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 23/40] scsi: smartpqi: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the smartpqi driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=23
Re: [PATCH v2 23/40] scsi: smartpqi: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the smartpqi driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/smartpqi/smartpqi_init.c | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 24/40 scsi: qla2xxx: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the qla2xxx driver to use scsi_set_sense() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/qla2xxx/qla_isr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_isr.c +6 -3
@@ -3263,21 +3263,24 @@ qla2x00_handle_dif_error(srb_t *sp, void *pkt)/* check guard */ if (e_guard != a_guard) { -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );set_host_byte (cmd,DID_ABORT );return 1 ; }/* check ref tag */ if (e_ref_tag != a_ref_tag) { -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );set_host_byte (cmd,DID_ABORT );return 1 ; }/* check appl tag */ if (e_app_tag != a_app_tag) { -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_APPLICATION_TAG_CHECK_FAILED );set_host_byte (cmd,DID_ABORT );return 1 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 24/40] scsi: qla2xxx: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the qla2xxx driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=24
Re: [PATCH v2 24/40] scsi: qla2xxx: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the qla2xxx driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/qla2xxx/qla_isr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 25/40 scsi: ps3rom: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the PS3 DVD driver to use scsi_set_sense() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/ps3rom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/ps3rom.c +3 -2
@@ -233,7 +233,8 @@ static enum scsi_qc_status ps3rom_queuecommand_lck(struct scsi_cmnd *cmd) }if (res) { -scsi_build_sense (cmd,0 ,ILLEGAL_REQUEST ,0 ,0 ); +scsi_set_sense (cmd,0 ,ILLEGAL_REQUEST , +NO_ADDITIONAL_SENSE_INFORMATION ); cmd->result = res; priv->curr_cmd =NULL ;scsi_done (cmd);
@@ -316,7 +317,7 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data) goto done; } -scsi_build_sense (cmd,0 , sense_key, asc, ascq); +scsi_set_sense (cmd,0 , sense_key,scsi_sense_code (asc, ascq)); done: priv->curr_cmd =NULL ;
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 25/40] scsi: ps3rom: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the PS3 DVD driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=25
Re: [PATCH v2 25/40] scsi: ps3rom: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the PS3 DVD driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/ps3rom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 26/40 scsi: lpfc: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the lpfc driver to use scsi_set_sense() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/lpfc/lpfc_scsi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +12 -6
@@ -2848,7 +2848,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) } out:if (err_type ==BGS_GUARD_ERR_MASK ) { -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );set_host_byte (cmd,DID_ABORT ); phba->bg_guard_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2857,7 +2858,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) sum, guard_tag); }else if (err_type ==BGS_REFTAG_ERR_MASK ) { -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );set_host_byte (cmd,DID_ABORT ); phba->bg_reftag_err_cnt++;
@@ -2867,7 +2869,8 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) ref_tag, start_ref_tag); }else if (err_type ==BGS_APPTAG_ERR_MASK ) { -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_APPLICATION_TAG_CHECK_FAILED );set_host_byte (cmd,DID_ABORT ); phba->bg_apptag_err_cnt++;
@@ -2970,7 +2973,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_guard_err (bgstat)) { ret =1 ; -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );set_host_byte (cmd,DID_ABORT ); phba->bg_guard_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2983,7 +2987,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_reftag_err (bgstat)) { ret =1 ; -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );set_host_byte (cmd,DID_ABORT ); phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2996,7 +3001,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_apptag_err (bgstat)) { ret =1 ; -scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 ); +scsi_set_sense (cmd,1 ,ILLEGAL_REQUEST , +LOGICAL_BLOCK_APPLICATION_TAG_CHECK_FAILED );set_host_byte (cmd,DID_ABORT ); phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 26/40] scsi: lpfc: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the lpfc driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=26
Re: [PATCH v2 26/40] scsi: lpfc: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the lpfc driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/lpfc/lpfc_scsi.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 27/40 scsi: stex: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the stex driver to use scsi_set_sense() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/stex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/stex.c +1 -2
@@ -401,8 +401,7 @@ static struct status_msg *stex_get_status(struct st_hba *hba)static void stex_invalid_field (struct scsi_cmnd *cmd,void (*done)(struct scsi_cmnd *)) { -/* "Invalid field in cdb" */ -scsi_build_sense (cmd,0 ,ILLEGAL_REQUEST ,0x24 ,0x0 ); +scsi_set_sense (cmd,0 ,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );done (cmd); }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 27/40] scsi: stex: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the stex driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=27
Re: [PATCH v2 27/40] scsi: stex: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the stex driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/stex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 28/40 scsi: mvumi: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the Marvell UMI driver to use scsi_set_sense() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/mvumi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mvumi.c +1 -1
@@ -2067,7 +2067,7 @@ static unsigned char mvumi_build_frame(struct mvumi_hba *mhba,return 0 ; error: -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return -1 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 28/40] scsi: mvumi: use 16-bits defined sense codes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Failure of dma_map_sg() is incorrectly treated as success, leading to potential data corruption. --
commit fe977aa03b75003e40bf53c83a27104877ab66a8
Author: Damien Le Moal <[email protected]>
scsi: mvumi: use 16-bits defined sense codes
Refactor the Marvell UMI driver to use scsi_set_sense() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
drivers/scsi/mvumi.c static unsigned char mvumi_build_frame(struct mvumi_hba *mhba, · line 2070
Quoted 10 lines
drivers/scsi/mvumi.c +1
-1@@ -2067,7 +2067,7 @@ static unsigned char mvumi_build_frame(struct mvumi_hba *mhba,return 0 ; error: -scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); +scsi_set_sense (scmd,0 ,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );
[Severity: High]
This isn't a bug introduced by this patch, but looking at how we reach this error block, does the driver mishandle a dma_map_sg() failure?
In mvumi_build_frame(), we call mvumi_make_sgl(). If dma_map_sg() fails inside mvumi_make_sgl(), it returns 0:
drivers/scsi/mvumi.c:mvumi_make_sgl() {
...
*sg_count = dma_map_sg(&mhba->pdev->dev, scsi_sglist(scmd), sgnum,
scmd->sc_data_direction);
if (*sg_count > mhba->max_sge) {
...
return -1;
}
...
return 0;
}Because 0 is not greater than mhba->max_sge, the error check is skipped, and mvumi_make_sgl() returns 0 (success) instead of -1.
Back in mvumi_build_frame(), this bypasses the goto error:
drivers/scsi/mvumi.c:mvumi_build_frame() {
...
if (scsi_bufflen(scmd)) {
if (mvumi_make_sgl(mhba, scmd, &pframe->payload[0],
&pframe->sg_counts))
goto error;
pframe->data_transfer_length = scsi_bufflen(scmd);
}
...
}Will this cause the hardware to reuse stale DMA addresses from a previous command frame since data_transfer_length is set but sg_counts is 0?
Quoted 3 lines
drivers/scsi/mvumi.c +0
-0return -1 ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=28
Re: [PATCH v2 28/40] scsi: mvumi: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the Marvell UMI driver to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/mvumi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 29/40 scsi: libiscsi: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor libiscsi to use scsi_set_sense() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/libiscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/libiscsi.c +2 -1
@@ -892,7 +892,8 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ascq = session->tt->check_protection (task, §or);if (ascq) { -scsi_build_sense (sc,1 ,ILLEGAL_REQUEST ,0x10 , ascq); +scsi_set_sense (sc,1 ,ILLEGAL_REQUEST , +scsi_sense_code (ASC_ID_CRC_OR_ECC_ERROR , ascq));scsi_set_sense_information (sc->sense_buffer,SCSI_SENSE_BUFFERSIZE , sector);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 29/40] scsi: libiscsi: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
Refactor libiscsi to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=29
Re: [PATCH v2 29/40] scsi: libiscsi: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 5 lines · Damien Le Moal
Refactor libiscsi to use
scsi_set_sense()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/libiscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 30/40 scsi: ibmvscsi_tgt: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the IBM virtual SCSI target driver to use scsi_set_sense_buffer() and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +2 -3
@@ -3757,9 +3757,8 @@ static int ibmvscsis_queue_data_in(struct se_cmd *se_cmd)dev_err (&vscsi->dev,"srp_transfer_data failed: %d\n" , rc); se_cmd->scsi_sense_length =18 ;memset (se_cmd->sense_buffer,0 , se_cmd->scsi_sense_length); -/* Logical Unit Communication Time-out asc/ascq = 0x0801 */ -scsi_build_sense_buffer (0 , se_cmd->sense_buffer,MEDIUM_ERROR , -0x08 ,0x01 ); +scsi_set_sense_buffer (0 , se_cmd->sense_buffer,MEDIUM_ERROR , +LU_COMMUNICATION_TIMEOUT ); }srp_build_response (vscsi, cmd, &len);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 30/40] scsi: ibmvscsi_tgt: use 16-bits defined sense codes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing assignment of SAM_STAT_CHECK_CONDITION to scsi_status causes the constructed sense buffer to be silently ignored and a falsely successful response to be sent. --
commit b057f4e0cc70d975ef62438361ce78cb340d3412
Author: Damien Le Moal <[email protected]>
scsi: ibmvscsi_tgt: use 16-bits defined sense codes
This commit refactors the IBM virtual SCSI target driver to use scsi_set_sense_buffer() and standard enum values for sense codes. This improves code clarity by removing hard-coded ASC/ASCQ values.
Quoted 5 lines
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +0
-0
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c static int ibmvscsis_queue_data_in(struct se_cmd *se_cmd) · line 3763
Quoted 10 lines
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +2
-3@@ -3757,9 +3757,8 @@ static int ibmvscsis_queue_data_in(struct se_cmd *se_cmd)dev_err (&vscsi->dev,"srp_transfer_data failed: %d\n" , rc); se_cmd->scsi_sense_length =18 ;memset (se_cmd->sense_buffer,0 , se_cmd->scsi_sense_length); -/* Logical Unit Communication Time-out asc/ascq = 0x0801 */ -scsi_build_sense_buffer (0 , se_cmd->sense_buffer,MEDIUM_ERROR , -0x08 ,0x01 ); +scsi_set_sense_buffer (0 , se_cmd->sense_buffer,MEDIUM_ERROR , +LU_COMMUNICATION_TIMEOUT ); }
[Severity: High]
This isn't a bug introduced by this patch, but does this error path properly set the SCSI status?
When srp_transfer_data() fails in ibmvscsis_queue_data_in(), the code builds a sense buffer but doesn't appear to update se_cmd->scsi_status to SAM_STAT_CHECK_CONDITION.
Because of this, does srp_build_response() evaluate rsp->status as SAM_STAT_GOOD (0)? If so, it skips the logic that copies the sense buffer and sends a falsely successful response without any sense data. Masking this transfer failure could cause the initiator to consume uninitialized or stale memory as valid read data.
Quoted 1 line
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +0
-0srp_build_response (vscsi, cmd, &len);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=30
Re: [PATCH v2 30/40] scsi: ibmvscsi_tgt: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the IBM virtual SCSI target driver to use
scsi_set_sense_buffer()and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 31/40 scsi: scsi_debug: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the scsi_debug driver to replace hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
The functions mk_sense_buffer() and mk_sense_info_tape() are modified to take a 16-bits sense code as argument.
No functional change intended.
--- drivers/scsi/scsi_debug.c | 332 ++++++++++++++++++++------------------ 1 file changed, 171 insertions(+), 161 deletions(-)
drivers/scsi/scsi_debug.c +171 -161
@@ -67,9 +67,6 @@ static const char *sdebug_version_date = "20210520";#define MY_NAME "scsi_debug" -/* Additional Sense Code Qualifier (ASCQ) */ -#define ACK_NAK_TO 0x3 -/* Default values for driver parameters */ #define DEF_NUM_HOST 1#define DEF_NUM_TGTS 1
@@ -1320,9 +1317,13 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp,sdev_printk (KERN_ERR , scp->device,"sense_buffer is NULL\n" );return ; } - asc = c_d ?INVALID_FIELD_IN_CDB :INVALID_FIELD_IN_PARAM_LIST ; +if (c_d) + asc =ASC_INVALID_FIELD_IN_CDB ; +else + asc =ASC_INVALID_FIELD_IN_PARAMETER_LIST ;memset (sbuff,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense (scp, sdebug_dsense,ILLEGAL_REQUEST , asc,0 ); +scsi_set_sense (scp, sdebug_dsense,ILLEGAL_REQUEST , +scsi_sense_code (asc,0 ));memset (sks,0 ,sizeof (sks)); sks[0 ] =0x80 ;if (c_d)
@@ -1346,7 +1347,7 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp, my_name, asc, c_d ? 'C' : 'D', in_byte, in_bit); } -static void mk_sense_buffer (struct scsi_cmnd *scp,int key,int asc,int asq) +static void mk_sense_buffer (struct scsi_cmnd *scp,u8 key,u16 code) {if (!scp->sense_buffer) {sdev_printk (KERN_ERR , scp->device,"sense_buffer is NULL\n" );
@@ -1354,16 +1355,16 @@ static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq) }memset (scp->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense (scp, sdebug_dsense, key, asc, asq); +scsi_set_sense (scp, sdebug_dsense, key, code);if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device, -"%s: [sense_key,asc,ascq]: [0x%x,0x%x,0x%x]\n" , - my_name, key, asc, asq); +"%s: [sense_key,sense_code]: [0x%02x,0x%04x]\n" , + my_name, key, code); }/* Sense data that has information fields for tapes */ -static void mk_sense_info_tape (struct scsi_cmnd *scp,int key,int asc,int asq, +static void mk_sense_info_tape (struct scsi_cmnd *scp,u8 key,u16 code,unsigned int information,unsigned char tape_flags) {if (!scp->sense_buffer) {
@@ -1372,7 +1373,7 @@ static void mk_sense_info_tape(struct scsi_cmnd *scp, int key, int asc, int asq, }memset (scp->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense (scp,/* sdebug_dsense */ 0 , key, asc, asq); +scsi_set_sense (scp,/* sdebug_dsense */ 0 , key, code);/* only fixed format so far */ scp->sense_buffer[0 ] |=0x80 ;/* valid */
@@ -1381,13 +1382,13 @@ static void mk_sense_info_tape(struct scsi_cmnd *scp, int key, int asc, int asq,if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device, -"%s: [sense_key,asc,ascq]: [0x%x,0x%x,0x%x]\n" , - my_name, key, asc, asq); +"%s: [sense_key,sense_code]: [0x%02x,0x%04x]\n" , + my_name, key, code); }static void mk_sense_invalid_opcode (struct scsi_cmnd *scp) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_OPCODE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_COMMAND_OP_CODE ); } static int scsi_debug_ioctl(struct scsi_device *dev, unsigned int cmd,
@@ -1484,46 +1485,43 @@ static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)switch (k) {case SDEBUG_UA_POR : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_RESET_ASC , -POWER_ON_RESET_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED );if (sdebug_verbose) cp ="power on reset" ;break ;case SDEBUG_UA_POOCCUR : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_RESET_ASC , -POWER_ON_OCCURRED_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION ,POWER_ON_OCCURRED );if (sdebug_verbose) cp ="power on occurred" ;break ;case SDEBUG_UA_BUS_RESET : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_RESET_ASC , -BUS_RESET_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +SCSI_BUS_RESET_OCCURRED );if (sdebug_verbose) cp ="bus reset" ;break ;case SDEBUG_UA_MODE_CHANGED : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_CHANGED_ASC , -MODE_CHANGED_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +MODE_PARAMETERS_CHANGED );if (sdebug_verbose) cp ="mode parameters changed" ;break ;case SDEBUG_UA_CAPACITY_CHANGED : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_CHANGED_ASC , -CAPACITY_CHANGED_ASCQ ); +mk_sense_buffer (scp,UNIT_ATTENTION , +CAPACITY_DATA_HAS_CHANGED );if (sdebug_verbose) cp ="capacity data changed" ;break ;case SDEBUG_UA_MICROCODE_CHANGED :mk_sense_buffer (scp,UNIT_ATTENTION , -TARGET_CHANGED_ASC , -MICROCODE_CHANGED_ASCQ ); +MICROCODE_HAS_BEEN_CHANGED );if (sdebug_verbose) cp ="microcode has been changed" ;break ;case SDEBUG_UA_MICROCODE_CHANGED_WO_RESET :mk_sense_buffer (scp,UNIT_ATTENTION , -TARGET_CHANGED_ASC , -MICROCODE_CHANGED_WO_RESET_ASCQ ); +MICROCODE_HAS_BEEN_CHANGED_WITHOUT_RESET );if (sdebug_verbose) cp ="microcode has been changed without reset" ;break ;
@@ -1539,14 +1537,13 @@ static int make_ua(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (sdebug_scsi_level >=6 )/* SPC-4 and above */ clear_luns_changed_on_target (devip);mk_sense_buffer (scp,UNIT_ATTENTION , -TARGET_CHANGED_ASC , -LUNS_CHANGED_ASCQ ); +REPORTED_LUNS_DATA_HAS_CHANGED );if (sdebug_verbose) cp ="reported luns data has changed" ;break ;case SDEBUG_UA_NOT_READY_TO_READY : -mk_sense_buffer (scp,UNIT_ATTENTION ,UA_READY_ASC , -0 ); +mk_sense_buffer (scp,UNIT_ATTENTION , +NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED );if (sdebug_verbose) cp ="not ready to ready transition/media change" ;break ;
@@ -2184,14 +2181,14 @@ static int resp_requests(struct scsi_cmnd *scp,if (dsense) { arr[0 ] =0x72 ; arr[1 ] =NOT_READY ; - arr[2 ] =LOGICAL_UNIT_NOT_READY ; + arr[2 ] =ASC_LU_NOT_READY ; arr[3 ] = (stopped_state ==2 ) ?0x1 :0x2 ; len =8 ; }else { arr[0 ] =0x70 ; arr[2 ] =NOT_READY ;/* NO_SENSE in sense_key */ arr[7 ] =0xa ;/* 18 byte sense buffer */ - arr[12 ] =LOGICAL_UNIT_NOT_READY ; + arr[12 ] =ASC_LU_NOT_READY ; arr[13 ] = (stopped_state ==2 ) ?0x1 :0x2 ; } }else if ((iec_m_pg[2 ] &0x4 ) && (6 == (iec_m_pg[3 ] &0xf ))) {
@@ -2199,14 +2196,14 @@ static int resp_requests(struct scsi_cmnd *scp,if (dsense) { arr[0 ] =0x72 ; arr[1 ] =0x0 ;/* NO_SENSE in sense_key */ - arr[2 ] =THRESHOLD_EXCEEDED ; + arr[2 ] =ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED ; arr[3 ] =0xff ;/* Failure prediction(false) */ len =8 ; }else { arr[0 ] =0x70 ; arr[2 ] =0x0 ;/* NO_SENSE in sense_key */ arr[7 ] =0xa ;/* 18 byte sense buffer */ - arr[12 ] =THRESHOLD_EXCEEDED ; + arr[12 ] =ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED ; arr[13 ] =0xff ;/* Failure prediction(false) */ } }else {/* nothing to report */
@@ -2457,8 +2454,7 @@ static int resp_rsup_opcodes(struct scsi_cmnd *scp, a_len = alloc_len; arr =kzalloc ((a_len <256 ) ?320 : a_len +64 ,GFP_ATOMIC );if (NULL == arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }switch (reporting_opts) {
@@ -2924,8 +2920,9 @@ static int resp_mode_sense(struct scsi_cmnd *scp,else bd_len =0 ; alloc_len = msense_6 ? cmd[4 ] :get_unaligned_be16 (cmd +7 ); -if (0x3 == pcontrol) {/* Saving values not supported */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,SAVING_PARAMS_UNSUP ,0 ); +if (0x3 == pcontrol) { +mk_sense_buffer (scp,ILLEGAL_REQUEST , +SAVING_PARAMETERS_NOT_SUPPORTED );return check_condition_result; } target_dev_id = ((devip->sdbg_host->shost->host_no + 1) * 2000) +
@@ -3174,7 +3171,7 @@ static int resp_mode_select(struct scsi_cmnd *scp, (arr[off +1 ] +2 );if ((pg_len + off) > param_len) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -PARAMETER_LIST_LENGTH_ERR ,0 ); +PARAMETER_LIST_LENGTH_ERROR );return check_condition_result; }switch (mpage) {
@@ -3256,7 +3253,7 @@ static int resp_ie_l_pg(unsigned char *arr)memcpy (arr, ie_l_pg,sizeof (ie_l_pg));if (iec_m_pg[2 ] &0x4 ) {/* TEST bit set */ - arr[4 ] =THRESHOLD_EXCEEDED ; + arr[4 ] =ASC_FAILURE_PREDICTION_THRESHOLD_EXCEEDED ; arr[5 ] =0xff ; }return sizeof (ie_l_pg);
@@ -3413,7 +3410,8 @@ static int resp_locate(struct scsi_cmnd *scp,break ;if (i < pos) { devip->tape_location[partition] = i; -mk_sense_buffer (scp,BLANK_CHECK ,0x05 ,0 ); +mk_sense_buffer (scp,BLANK_CHECK , +LU_DOES_NOT_RESPOND_TO_SELECTION );return check_condition_result; } devip->tape_location[partition] = pos;
@@ -3438,8 +3436,9 @@ static int resp_write_filemarks(struct scsi_cmnd *scp,for (i =0 , pos = devip->tape_location[partition]; i < count; i++, pos++) {if (pos >= devip->tape_eop[partition] -1 ) {/* don't overwrite EOD */ devip->tape_location[partition] = devip->tape_eop[partition] -1 ; -mk_sense_info_tape (scp,VOLUME_OVERFLOW ,NO_ADDITIONAL_SENSE , -EOP_EOM_DETECTED_ASCQ , count,SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,VOLUME_OVERFLOW , +END_OF_PARTITION_MEDIUM_DETECTED , + count,SENSE_FLAG_EOM );return check_condition_result; } (devip->tape_blocks[partition] + pos)->fl_size = data;
@@ -3540,31 +3539,28 @@ static int resp_space(struct scsi_cmnd *scp, is_fm: devip->tape_location[partition] = pos; -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -FILEMARK_DETECTED_ASCQ , count - i, -SENSE_FLAG_FILEMARK ); +mk_sense_info_tape (scp,NO_SENSE ,FILEMARK_DETECTED , + count - i,SENSE_FLAG_FILEMARK );return check_condition_result; is_eod: devip->tape_location[partition] = pos; -mk_sense_info_tape (scp,BLANK_CHECK ,NO_ADDITIONAL_SENSE , -EOD_DETECTED_ASCQ , count - i, -0 ); +mk_sense_info_tape (scp,BLANK_CHECK ,END_OF_DATA_DETECTED , + count - i,0 );return check_condition_result; is_bop: devip->tape_location[partition] =0 ; -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -BEGINNING_OF_P_M_DETECTED_ASCQ , count - i, -SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,NO_SENSE , +BEGINNING_OF_PARTITION_MEDIUM_DETECTED , + count - i,SENSE_FLAG_EOM ); devip->tape_location[partition] =0 ;return check_condition_result; is_eop: devip->tape_location[partition] = devip->tape_eop[partition] -1 ; -mk_sense_info_tape (scp,MEDIUM_ERROR ,NO_ADDITIONAL_SENSE , -EOP_EOM_DETECTED_ASCQ , (unsigned int )i, -SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,MEDIUM_ERROR ,END_OF_PARTITION_MEDIUM_DETECTED , + (unsigned int )i,SENSE_FLAG_EOM );return check_condition_result; }
@@ -3852,8 +3848,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,/* For host-managed, reads cannot cross zone types boundaries */ if (zsp->z_type != zsp_end->z_type) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -READ_INVDATA_ASCQ ); +ATTEMPT_TO_READ_INVALID_DATA );return check_condition_result; }return 0 ;
@@ -3861,8 +3856,8 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,/* Writing into a gap zone is not allowed */ if (zbc_zone_is_gap (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE , -ATTEMPT_ACCESS_GAP ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +ATTEMPT_TO_ACCESS_GAP_ZONE );return check_condition_result; }
@@ -3870,8 +3865,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,if (zbc_zone_is_conv (zsp)) {if (!zbc_zone_is_conv (zsp_end)) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -WRITE_BOUNDARY_ASCQ ); +WRITE_BOUNDARY_VIOLATION );return check_condition_result; }return 0 ;
@@ -3881,21 +3875,19 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,/* Writes cannot cross sequential zone boundaries */ if (zsp_end != zsp) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -WRITE_BOUNDARY_ASCQ ); +WRITE_BOUNDARY_VIOLATION );return check_condition_result; }/* Cannot write full zones */ if (zsp->z_cond ==ZC5_FULL ) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -INVALID_FIELD_IN_CDB ,0 ); +INVALID_FIELD_IN_CDB );return check_condition_result; }/* Writes must be aligned to the zone WP */ if (lba != zsp->z_wp) {mk_sense_buffer (scp,ILLEGAL_REQUEST , -LBA_OUT_OF_RANGE , -UNALIGNED_WRITE_ASCQ ); +UNALIGNED_WRITE_COMMAND );return check_condition_result; } }
@@ -3905,8 +3897,7 @@ static int check_zbc_access_params(struct scsi_cmnd *scp,if (devip->max_open && devip->nr_exp_open >= devip->max_open) {mk_sense_buffer (scp,DATA_PROTECT , -INSUFF_RES_ASC , -INSUFF_ZONE_ASCQ ); +INSUFFICIENT_ZONE_RESOURCES );return check_condition_result; }zbc_open_zone (devip, zsp, false);
@@ -3923,17 +3914,18 @@ static inline int check_device_access_paramsstruct sdebug_dev_info *devip = (struct sdebug_dev_info *)sdp->hostdata;if (lba + num > sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }/* transfer length excessive (tie in to block limits VPD page) */ if (num > sdebug_store_sectors) {/* needs work to find which cdb byte 'num' comes from */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return check_condition_result; }if (write &&unlikely (sdebug_wp)) { -mk_sense_buffer (scp,DATA_PROTECT ,WRITE_PROTECTED ,0x2 ); +mk_sense_buffer (scp,DATA_PROTECT ,LU_SOFTWARE_WRITE_PROTECTED );return check_condition_result; }if (sdebug_dev_is_zoned (devip))
@@ -4442,17 +4434,17 @@ static int resp_read_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) i++, pos++, blp++) { devip->tape_location[partition] = pos +1 ;if (IS_TAPE_BLOCK_FM (blp->fl_size)) { -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -FILEMARK_DETECTED_ASCQ , fixed ? num - i : size, -SENSE_FLAG_FILEMARK ); +mk_sense_info_tape (scp,NO_SENSE ,FILEMARK_DETECTED , + fixed ? num - i : size, +SENSE_FLAG_FILEMARK );scsi_set_resid (scp, (num - i) * size);return check_condition_result; }/* Assume no REW */ if (IS_TAPE_BLOCK_EOD (blp->fl_size)) { -mk_sense_info_tape (scp,BLANK_CHECK ,NO_ADDITIONAL_SENSE , -EOD_DETECTED_ASCQ , fixed ? num - i : size, -0 ); +mk_sense_info_tape (scp,BLANK_CHECK , +END_OF_DATA_DETECTED , + fixed ? num - i : size,0 ); devip->tape_location[partition] = pos;scsi_set_resid (scp, (num - i) * size);return check_condition_result;
@@ -4464,9 +4456,9 @@ static int resp_read_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (fixed) {if (blp->fl_size != devip->tape_blksize) {scsi_set_resid (scp, (num - i) * size); -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -0 , num - i, -SENSE_FLAG_ILI ); +mk_sense_info_tape (scp,NO_SENSE , +NO_ADDITIONAL_SENSE_INFORMATION , + num - i,SENSE_FLAG_ILI );return check_condition_result; } }else {
@@ -4474,18 +4466,19 @@ static int resp_read_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (blp->fl_size < size)scsi_set_resid (scp, size - blp->fl_size);if (!sili) { -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -0 , size - blp->fl_size, -SENSE_FLAG_ILI ); +mk_sense_info_tape (scp,NO_SENSE , +NO_ADDITIONAL_SENSE_INFORMATION , + size - blp->fl_size, +SENSE_FLAG_ILI );return check_condition_result; } } } }if (pos >= devip->tape_eop[partition]) { -mk_sense_info_tape (scp,NO_SENSE ,NO_ADDITIONAL_SENSE , -EOP_EOM_DETECTED_ASCQ , fixed ? num - i : size, -SENSE_FLAG_EOM ); +mk_sense_info_tape (scp,NO_SENSE , +END_OF_PARTITION_MEDIUM_DETECTED , + fixed ? num - i : size,SENSE_FLAG_EOM ); devip->tape_location[partition] = pos -1 ;return check_condition_result; }
@@ -4572,8 +4565,7 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely ((SDEBUG_OPT_MEDIUM_ERR & sdebug_opts) && (lba <= (sdebug_medium_error_start + sdebug_medium_error_count -1 )) && ((lba + num) > sdebug_medium_error_start))) { -/* claim unrecoverable read error */ -mk_sense_buffer (scp,MEDIUM_ERROR ,UNRECOVERED_READ_ERR ,0 ); +mk_sense_buffer (scp,MEDIUM_ERROR ,UNRECOVERED_READ_ERROR );/* set info field and valid bit for fixed descriptor */ if (0x70 == (scp->sense_buffer[0 ] &0x7f )) { scp->sense_buffer[0 ] |=0x80 ;/* Valid bit */
@@ -4597,22 +4589,26 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)case 1 :/* Guard tag error */ if (cmd[1 ] >>5 !=3 ) {/* RDPROTECT != 3 */ sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return check_condition_result; }else if (scp->prot_flags &SCSI_PROT_GUARD_CHECK ) {sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return illegal_condition_result; }break ;case 3 :/* Reference tag error */ if (cmd[1 ] >>5 !=3 ) {/* RDPROTECT != 3 */ sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,3 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return check_condition_result; }else if (scp->prot_flags &SCSI_PROT_REF_CHECK ) {sdeb_meta_read_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,3 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return illegal_condition_result; }break ;
@@ -4630,16 +4626,18 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely ((sdebug_opts &SDEBUG_OPT_RECOV_DIF_DIX ) &&atomic_read (&sdeb_inject_pending))) {if (sdebug_opts &SDEBUG_OPT_RECOVERED_ERR ) { -mk_sense_buffer (scp,RECOVERED_ERROR ,THRESHOLD_EXCEEDED ,0 ); +mk_sense_buffer (scp,RECOVERED_ERROR , +FAILURE_PREDICTION_THRESHOLD_EXCEEDED );atomic_set (&sdeb_inject_pending,0 );return check_condition_result; }else if (sdebug_opts &SDEBUG_OPT_DIF_ERR ) { -/* Logical block guard check failed */ -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }else if (SDEBUG_OPT_DIX_ERR & sdebug_opts) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }
@@ -4846,16 +4844,14 @@ static int resp_write_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) blp->fl_size =TAPE_BLOCK_EOD_FLAG ;if (pos >= devip->tape_eop[partition] -1 ) {mk_sense_info_tape (scp,VOLUME_OVERFLOW , -NO_ADDITIONAL_SENSE ,EOP_EOM_DETECTED_ASCQ , - fixed ? num - i : transfer, -SENSE_FLAG_EOM ); +END_OF_PARTITION_MEDIUM_DETECTED , + fixed ? num - i : transfer,SENSE_FLAG_EOM );return check_condition_result; }if (ew) {/* early warning */ mk_sense_info_tape (scp,NO_SENSE , -NO_ADDITIONAL_SENSE ,EOP_EOM_DETECTED_ASCQ , - fixed ? num - i : transfer, -SENSE_FLAG_EOM ); +END_OF_PARTITION_MEDIUM_DETECTED , + fixed ? num - i : transfer,SENSE_FLAG_EOM );return check_condition_result; }
@@ -4877,8 +4873,7 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely (sdebug_opts &SDEBUG_OPT_UNALIGNED_WRITE &&atomic_read (&sdeb_inject_pending))) {atomic_set (&sdeb_inject_pending,0 ); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE , -UNALIGNED_WRITE_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,UNALIGNED_WRITE_COMMAND );return check_condition_result; }
@@ -4959,22 +4954,26 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)case 1 :/* Guard tag error */ if (scp->prot_flags &SCSI_PROT_GUARD_CHECK ) {sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return illegal_condition_result; }else if (scp->cmnd[1 ] >>5 !=3 ) {/* WRPROTECT != 3 */ sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );return check_condition_result; }break ;case 3 :/* Reference tag error */ if (scp->prot_flags &SCSI_PROT_REF_CHECK ) {sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,3 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return illegal_condition_result; }else if (scp->cmnd[1 ] >>5 !=3 ) {/* WRPROTECT != 3 */ sdeb_meta_write_unlock (sip); -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,3 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED );return check_condition_result; }break ;
@@ -5002,16 +5001,18 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)if (unlikely ((sdebug_opts &SDEBUG_OPT_RECOV_DIF_DIX ) &&atomic_read (&sdeb_inject_pending))) {if (sdebug_opts &SDEBUG_OPT_RECOVERED_ERR ) { -mk_sense_buffer (scp,RECOVERED_ERROR ,THRESHOLD_EXCEEDED ,0 ); +mk_sense_buffer (scp,RECOVERED_ERROR , +FAILURE_PREDICTION_THRESHOLD_EXCEEDED );atomic_set (&sdeb_inject_pending,0 );return check_condition_result; }else if (sdebug_opts &SDEBUG_OPT_DIF_ERR ) { -/* Logical block guard check failed */ -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }else if (sdebug_opts &SDEBUG_OPT_DIX_ERR ) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 );return illegal_condition_result; }
@@ -5074,7 +5075,7 @@ static int resp_write_scat(struct scsi_cmnd *scp,if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device,"%s: LB Data Offset field bad\n" , my_name); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return illegal_condition_result; } lbdof_blen = lbdof * lb_size;
@@ -5082,7 +5083,7 @@ static int resp_write_scat(struct scsi_cmnd *scp,if (sdebug_verbose)sdev_printk (KERN_INFO , scp->device,"%s: LBA range descriptors don't fit\n" , my_name); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return illegal_condition_result; } lrdp =kzalloc (lbdof_blen,GFP_ATOMIC | __GFP_NOWARN);
@@ -5123,8 +5124,7 @@ static int resp_write_scat(struct scsi_cmnd *scp,sdev_printk (KERN_INFO , scp->device,"%s: sum of blocks > data provided\n" , my_name); -mk_sense_buffer (scp,ILLEGAL_REQUEST ,WRITE_ERROR_ASC , -0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,WRITE_ERROR ); ret = illegal_condition_result; goto err_out_unlock; }
@@ -5135,8 +5135,9 @@ static int resp_write_scat(struct scsi_cmnd *scp, ei_lba);if (prot_ret) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 , - prot_ret); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +scsi_sense_code (ASC_ID_CRC_OR_ECC_ERROR , + prot_ret)); ret = illegal_condition_result; goto err_out_unlock; }
@@ -5163,18 +5164,20 @@ static int resp_write_scat(struct scsi_cmnd *scp,if (unlikely ((sdebug_opts &SDEBUG_OPT_RECOV_DIF_DIX ) &&atomic_read (&sdeb_inject_pending))) {if (sdebug_opts &SDEBUG_OPT_RECOVERED_ERR ) { -mk_sense_buffer (scp,RECOVERED_ERROR ,THRESHOLD_EXCEEDED ,0 ); +mk_sense_buffer (scp,RECOVERED_ERROR , +FAILURE_PREDICTION_THRESHOLD_EXCEEDED );atomic_set (&sdeb_inject_pending,0 ); ret = check_condition_result; goto err_out_unlock; }else if (sdebug_opts &SDEBUG_OPT_DIF_ERR ) { -/* Logical block guard check failed */ -mk_sense_buffer (scp,ABORTED_COMMAND ,0x10 ,1 ); +mk_sense_buffer (scp,ABORTED_COMMAND , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 ); ret = illegal_condition_result; goto err_out_unlock; }else if (sdebug_opts &SDEBUG_OPT_DIX_ERR ) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,0x10 ,1 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_GUARD_CHECK_FAILED );atomic_set (&sdeb_inject_pending,0 ); ret = illegal_condition_result; goto err_out_unlock;
@@ -5393,8 +5396,7 @@ static int resp_comp_write(struct scsi_cmnd *scp, dnum =2 * num; arr =kcalloc (lb_size, dnum,GFP_ATOMIC );if (NULL == arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }
@@ -5410,7 +5412,8 @@ static int resp_comp_write(struct scsi_cmnd *scp,sdeb_data_write_lock (sip);sdeb_meta_write_lock (sip);if (!comp_write_worker (sip, lba, num, arr, false)) { -mk_sense_buffer (scp,MISCOMPARE ,MISCOMPARE_VERIFY_ASC ,0 ); +mk_sense_buffer (scp,MISCOMPARE , +MISCOMPARE_DURING_VERIFY_OPERATION ); retval = check_condition_result; goto cleanup_unlock; }
@@ -5453,8 +5456,7 @@ static int resp_unmap(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) buf =kzalloc (scsi_bufflen (scp),GFP_ATOMIC );if (!buf) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }
@@ -5592,7 +5594,8 @@ static int resp_sync_cache(struct scsi_cmnd *scp, num_blocks =get_unaligned_be32 (cmd +10 ); }if (lba + num_blocks > sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }if (!write_since_sync || (cmd[1 ] &0x2 ))
@@ -5630,7 +5633,8 @@ static int resp_pre_fetch(struct scsi_cmnd *scp, nblks =get_unaligned_be32 (cmd +10 ); }if (lba + nblks > sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }if (!fsp)
@@ -5801,8 +5805,7 @@ static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) arr =kcalloc (lb_size, vnum,GFP_ATOMIC | __GFP_NOWARN);if (!arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFFICIENT_RESOURCES );return check_condition_result; }/* Not changing store, so only need read access */
@@ -5823,7 +5826,8 @@ static int resp_verify(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) } ret =0 ;if (!comp_write_worker (sip, lba, vnum, arr, true)) { -mk_sense_buffer (scp,MISCOMPARE ,MISCOMPARE_VERIFY_ASC ,0 ); +mk_sense_buffer (scp,MISCOMPARE , +MISCOMPARE_DURING_VERIFY_OPERATION ); ret = check_condition_result; goto cleanup; }
@@ -5862,7 +5866,8 @@ static int resp_report_zones(struct scsi_cmnd *scp, partial = cmd[14 ] &0x80 ;if (zs_lba >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE );return check_condition_result; }
@@ -5873,8 +5878,8 @@ static int resp_report_zones(struct scsi_cmnd *scp, arr =kzalloc (arr_len,GFP_ATOMIC | __GFP_NOWARN);if (!arr) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INSUFF_RES_ASC , -INSUFF_RES_ASCQ ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +INSUFFICIENT_RESOURCES );return check_condition_result; }
@@ -5939,8 +5944,7 @@ static int resp_report_zones(struct scsi_cmnd *scp,continue ;break ;default : -mk_sense_buffer (scp,ILLEGAL_REQUEST , -INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); ret = check_condition_result; goto fini; }
@@ -6005,13 +6009,13 @@ static int resp_atomic_write(struct scsi_cmnd *scp,if (sdebug_atomic_wr_align &&do_div (lba_tmp, sdebug_atomic_wr_align)) {/* Does not meet alignment requirement */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return check_condition_result; }if (sdebug_atomic_wr_gran && len % sdebug_atomic_wr_gran) {/* Does not meet alignment requirement */ -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB );return check_condition_result; }
@@ -6072,8 +6076,8 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)/* Check if all closed zones can be open */ if (devip->max_open && devip->nr_exp_open + devip->nr_closed > devip->max_open) { -mk_sense_buffer (scp,DATA_PROTECT ,INSUFF_RES_ASC , -INSUFF_ZONE_ASCQ ); +mk_sense_buffer (scp,DATA_PROTECT , +INSUFFICIENT_ZONE_RESOURCES ); res = check_condition_result; goto fini; }
@@ -6085,19 +6089,20 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)/* Open the specified zone */ z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -6107,8 +6112,7 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) goto fini;if (devip->max_open && devip->nr_exp_open >= devip->max_open) { -mk_sense_buffer (scp,DATA_PROTECT ,INSUFF_RES_ASC , -INSUFF_ZONE_ASCQ ); +mk_sense_buffer (scp,DATA_PROTECT ,INSUFFICIENT_ZONE_RESOURCES ); res = check_condition_result; goto fini; }
@@ -6152,19 +6156,20 @@ static int resp_close_zone(struct scsi_cmnd *scp,/* Close specified zone */ z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -6224,19 +6229,20 @@ static int resp_finish_zone(struct scsi_cmnd *scp,/* Finish the specified zone */ z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -6303,19 +6309,20 @@ static int resp_rwp_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) z_id =get_unaligned_be64 (cmd +2 );if (z_id >= sdebug_capacity) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,LBA_OUT_OF_RANGE ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST , +LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE ); res = check_condition_result; goto fini; } zsp =zbc_zone (devip, z_id);if (z_id != zsp->z_start) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }if (zbc_zone_is_conv (zsp)) { -mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ,0 ); +mk_sense_buffer (scp,ILLEGAL_REQUEST ,INVALID_FIELD_IN_CDB ); res = check_condition_result; goto fini; }
@@ -7186,7 +7193,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip, cmnd->result = scsi_result;if (cmnd->result ==0 &&unlikely (sdebug_opts &SDEBUG_OPT_TRANSPORT_ERR )) {if (atomic_read (&sdeb_inject_pending)) { -mk_sense_buffer (cmnd,ABORTED_COMMAND ,TRANSPORT_PROBLEM ,ACK_NAK_TO ); +mk_sense_buffer (cmnd,ABORTED_COMMAND ,ACK_NAK_TIMEOUT );atomic_set (&sdeb_inject_pending,0 ); cmnd->result = check_condition_result; }
@@ -8979,7 +8986,8 @@ static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)return 0 ; } } -mk_sense_buffer (scp,NOT_READY ,LOGICAL_UNIT_NOT_READY ,0x1 ); +mk_sense_buffer (scp,NOT_READY , +LU_IS_IN_PROCESS_OF_BECOMING_READY );if (sdebug_verbose)sdev_printk (KERN_INFO , sdp,"%s: Not ready: in process of becoming ready\n" , my_name);
@@ -8997,7 +9005,8 @@ static int resp_not_ready(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)return check_condition_result; } } -mk_sense_buffer (scp,NOT_READY ,LOGICAL_UNIT_NOT_READY ,0x2 ); +mk_sense_buffer (scp,NOT_READY , +LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED );if (sdebug_verbose)sdev_printk (KERN_INFO , sdp,"%s: Not ready: initializing command required\n" , my_name);
@@ -9194,7 +9203,8 @@ static int sdebug_fail_cmd(struct scsi_cmnd *cmnd, int *retval, out_handle:if (err->cnt <0 ) err->cnt++; -mk_sense_buffer (cmnd, err->sense_key, err->asc, err->asq); +mk_sense_buffer (cmnd, err->sense_key, +scsi_sense_code (err->asc, err->asq)); result = err->status_byte | err->host_byte <<16 | err->driver_byte <<24 ; *info = *err; *retval =schedule_resp (cmnd, devip, result,NULL ,0 ,0 );
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 31/40] scsi: scsi_debug: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
Refactor the
scsi_debugdriver to replace hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.The functions
mk_sense_buffer()andmk_sense_info_tape()are modified to take a 16-bits sense code as argument.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=31
Re: [PATCH v2 31/40] scsi: scsi_debug: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 8 lines · Damien Le Moal
Refactor the
scsi_debugdriver to replace hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.The functions
mk_sense_buffer()andmk_sense_info_tape()are modified to take a 16-bits sense code as argument.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/scsi_debug.c | 332 ++++++++++++++++++++------------------ 1 file changed, 171 insertions(+), 161 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 32/40 scsi: hpsa: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the hpsa driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
The function decode_sense_data() is also modified to take a pointer to a 16-bits sense_code variable in place of the two pointers to the additional sense code and its code qualifier. The local definitions of ASCs and ASCQs are deleted too.
No functional change intended, but the function hpsa_volume_offline() was checking only the addditional sense code qualifier with checking the additional sense code. This change assumes that the intended additional sense code to check is ASC_LU_NOT_READY.
--- drivers/scsi/hpsa.c | 69 +++++++++++++++++++++-------------------- drivers/scsi/hpsa_cmd.h | 23 -------------- 2 files changed, 35 insertions(+), 57 deletions(-)
drivers/scsi/hpsa.c +35 -34
@@ -353,14 +353,13 @@ static inline bool hpsa_is_cmd_idle(struct CommandList *c)/* extract sense key, asc, and ascq from sense data. -1 means invalid. */ static void decode_sense_data (const u8 *sense_data,int sense_data_len, -u8 *sense_key,u8 *asc,u8 *ascq) +u8 *sense_key,u16 *sense_code) {struct scsi_sense_hdr sshdr;bool rc; *sense_key =-1 ; - *asc =-1 ; - *ascq =-1 ; + *sense_code =-1 ;if (sense_data_len <1 )return ;
@@ -368,15 +367,15 @@ static void decode_sense_data(const u8 *sense_data, int sense_data_len, rc =scsi_normalize_sense (sense_data, sense_data_len, &sshdr);if (rc) { *sense_key = sshdr.sense_key; - *asc = sshdr.asc; - *ascq = sshdr.ascq; + *sense_code = sshdr.sense_code; } }static int check_for_unit_attention (struct ctlr_info *h,struct CommandList *c) { -u8 sense_key, asc, ascq; +u8 sense_key; +u16 sense_code;int sense_len;if (c->err_info->SenseLen >sizeof (c->err_info->SenseInfo))
@@ -385,34 +384,35 @@ static int check_for_unit_attention(struct ctlr_info *h, sense_len = c->err_info->SenseLen;decode_sense_data (c->err_info->SenseInfo, sense_len, - &sense_key, &asc, &ascq); -if (sense_key !=UNIT_ATTENTION || asc ==0xff ) + &sense_key, &sense_code); +if (sense_key !=UNIT_ATTENTION || +scsi_sense_code_asc (sense_code) ==0xff )return 0 ; -switch (asc) { -case STATE_CHANGED : +switch (scsi_sense_code_asc (sense_code)) { +case ASC_PARAMETERS_CHANGED :dev_warn (&h->pdev->dev,"%s: a state change detected, command retried\n" , h->devname);break ; -case LUN_FAILED : +case ASC_LU_HAS_NOT_SELF_CONFIGURED_YET :dev_warn (&h->pdev->dev,"%s: LUN failure detected\n" , h->devname);break ; -case REPORT_LUNS_CHANGED : +case ASC_TARGET_OPERATING_CONDITIONS_HAVE_CHANGED :dev_warn (&h->pdev->dev,"%s: report LUN data changed\n" , h->devname);/* -* Note: this REPORT_LUNS_CHANGED condition only occurs on the external -* target (array) devices. +* Note: this ASC_TARGET_OPERATING_CONDITIONS_HAVE_CHANGED condition +* only occurs on the external target (array) devices. */ break ; -case POWER_OR_RESET : +case ASC_POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED :dev_warn (&h->pdev->dev,"%s: a power on or device reset detected\n" , h->devname);break ; -case UNIT_ATTENTION_CLEARED : +case ASC_COMMANDS_CLEARED_BY_ANOTHER_INITIATOR :dev_warn (&h->pdev->dev,"%s: unit attention cleared by another initiator\n" , h->devname);
@@ -2562,10 +2562,8 @@ static void complete_scsi_command(struct CommandList *cp)struct ErrorInfo *ei;struct hpsa_scsi_dev_t *dev;struct io_accel2_cmd *c2; -u8 sense_key; -u8 asc;/* additional sense code */ -u8 ascq;/* additional sense code qualifier */ +u16 sense_code;unsigned long sense_data_size; ei = cp->err_info;
@@ -2666,18 +2664,19 @@ static void complete_scsi_command(struct CommandList *cp)memcpy (cmd->sense_buffer, ei->SenseInfo, sense_data_size);if (ei->ScsiStatus)decode_sense_data (ei->SenseInfo, sense_data_size, - &sense_key, &asc, &ascq); + &sense_key, &sense_code);if (ei->ScsiStatus ==SAM_STAT_CHECK_CONDITION ) {switch (sense_key) {case ABORTED_COMMAND : cmd->result |=DID_SOFT_ERROR <<16 ;break ;case UNIT_ATTENTION : -if (asc ==0x3F && ascq ==0x0E ) +if (sense_code == +REPORTED_LUNS_DATA_HAS_CHANGED ) h->drv_req_rescan =1 ;break ;case ILLEGAL_REQUEST : -if (asc ==0x25 && ascq ==0x00 ) { +if (sense_code ==LU_NOT_SUPPORTED ) { dev->removed =1 ; cmd->result =DID_NO_CONNECT <<16 ; }
@@ -2693,7 +2692,9 @@ static void complete_scsi_command(struct CommandList *cp)"Sense: 0x%x, ASC: 0x%x, ASCQ: 0x%x, " "Returning result: 0x%x\n" , cp, ei->ScsiStatus, - sense_key, asc, ascq, + sense_key, +scsi_sense_code_asc (sense_code), +scsi_sense_code_ascq (sense_code), cmd->result); }else {/* scsi status is zero??? How??? */ dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. "
@@ -2919,7 +2920,8 @@ static void hpsa_scsi_interpret_error(struct ctlr_info *h, {const struct ErrorInfo *ei = cp->err_info;struct device *d = &cp->h->pdev->dev; -u8 sense_key, asc, ascq; +u8 sense_key; +u16 sense_code;int sense_len;switch (ei->CommandStatus) {
@@ -2928,12 +2930,13 @@ static void hpsa_scsi_interpret_error(struct ctlr_info *h, sense_len =sizeof (ei->SenseInfo); else sense_len = ei->SenseLen; -decode_sense_data (ei->SenseInfo, sense_len, - &sense_key, &asc, &ascq); +decode_sense_data (ei->SenseInfo, sense_len, &sense_key, + &sense_code);hpsa_print_cmd (h,"SCSI status" , cp);if (ei->ScsiStatus ==SAM_STAT_CHECK_CONDITION )dev_warn (d,"SCSI Status = 02, Sense key = 0x%02x, ASC = 0x%02x, ASCQ = 0x%02x\n" , - sense_key, asc, ascq); + sense_key,scsi_sense_code_asc (sense_code), +scsi_sense_code_ascq (sense_code));else dev_warn (d,"SCSI Status = 0x%02x\n" , ei->ScsiStatus);if (ei->ScsiStatus ==0 )
@@ -3868,12 +3871,10 @@ static unsigned char hpsa_volume_offline(struct ctlr_info *h, {struct CommandList *c;unsigned char *sense; -u8 sense_key, asc, ascq; +u8 sense_key; +u16 sense_code;int sense_len;int rc, ldstat =0 ; -#define ASC_LUN_NOT_READY 0x04 -#define ASCQ_LUN_NOT_READY_FORMAT_IN_PROGRESS 0x04 -#define ASCQ_LUN_NOT_READY_INITIALIZING_CMD_REQ 0x02 c =cmd_alloc (h);
@@ -3889,7 +3890,7 @@ static unsigned char hpsa_volume_offline(struct ctlr_info *h, sense_len =sizeof (c->err_info->SenseInfo); else sense_len = c->err_info->SenseLen; -decode_sense_data (sense, sense_len, &sense_key, &asc, &ascq); +decode_sense_data (sense, sense_len, &sense_key, &sense_code);cmd_free (h, c);/* Determine the reason for not ready state */
@@ -3912,8 +3913,8 @@ static unsigned char hpsa_volume_offline(struct ctlr_info *h,/* If VPD status page isn't available, * use ASC/ASCQ to determine state */ -if ((ascq ==ASCQ_LUN_NOT_READY_FORMAT_IN_PROGRESS ) || - (ascq ==ASCQ_LUN_NOT_READY_INITIALIZING_CMD_REQ )) +if (sense_code ==LU_NOT_READY_FORMAT_IN_PROGRESS || + sense_code ==LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED )return ldstat;break ;default :
drivers/scsi/hpsa_cmd.h +0 -23
@@ -63,29 +63,6 @@#define CISS_TMF_WRONG_LUN 0x09#define CISS_TMF_OVERLAPPED_TAG 0x0a -/* Unit Attentions ASC's as defined for the MSA2012sa */ -#define POWER_OR_RESET 0x29 -#define STATE_CHANGED 0x2a -#define UNIT_ATTENTION_CLEARED 0x2f -#define LUN_FAILED 0x3e -#define REPORT_LUNS_CHANGED 0x3f - -/* Unit Attentions ASCQ's as defined for the MSA2012sa */ - -/* These ASCQ's defined for ASC = POWER_OR_RESET */ -#define POWER_ON_RESET 0x00 -#define POWER_ON_REBOOT 0x01 -#define SCSI_BUS_RESET 0x02 -#define MSA_TARGET_RESET 0x03 -#define CONTROLLER_FAILOVER 0x04 -#define TRANSCEIVER_SE 0x05 -#define TRANSCEIVER_LVD 0x06 - -/* These ASCQ's defined for ASC = STATE_CHANGED */ -#define RESERVATION_PREEMPTED 0x03 -#define ASYM_ACCESS_CHANGED 0x06 -#define LUN_CAPACITY_CHANGED 0x09 -/* transfer direction */ #define XFER_NONE 0x00#define XFER_WRITE 0x01
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 32/40] scsi: hpsa: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
Refactor the hpsa driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.The function
decode_sense_data()is also modified to take a pointer to a 16-bitssense_codevariable in place of the two pointers to the additional sense code and its code qualifier. The local definitions of ASCs and ASCQs are deleted too.
Quoted 6 lines
No functional change intended, but the function
hpsa_volume_offline()was checking only the addditional sense code qualifier with checking the additional sense code. This change assumes that the intended additional sense code to check isASC_LU_NOT_READY.Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=32
Re: [PATCH v2 32/40] scsi: hpsa: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 15 lines · Damien Le Moal
Refactor the hpsa driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.The function
decode_sense_data()is also modified to take a pointer to a 16-bitssense_codevariable in place of the two pointers to the additional sense code and its code qualifier. The local definitions of ASCs and ASCQs are deleted too.No functional change intended, but the function
hpsa_volume_offline()was checking only the addditional sense code qualifier with checking the additional sense code. This change assumes that the intended additional sense code to check isASC_LU_NOT_READY.
Quoted 6 lines
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/hpsa.c | 69 +++++++++++++++++++++-------------------- drivers/scsi/hpsa_cmd.h | 23 -------------- 2 files changed, 35 insertions(+), 57 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 33/40 scsi: storvsc: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the storvsc driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/scsi/storvsc_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/scsi/storvsc_drv.c +9 -6
@@ -1016,7 +1016,7 @@ static int storvsc_channel_init(struct hv_device *device, bool is_fc)static void storvsc_handle_error (struct vmscsi_request *vm_srb,struct scsi_cmnd *scmnd,struct Scsi_Host *host, -u8 asc,u8 ascq) +struct scsi_sense_hdr *sshdr) {struct storvsc_scan_work *wrk;void (*process_err_fn)(struct work_struct *work);
@@ -1033,7 +1033,7 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,case SRB_STATUS_DATA_OVERRUN :if (vm_srb->srb_status &SRB_STATUS_AUTOSENSE_VALID ) {/* Check for capacity change */ -if ((asc ==0x2a ) && (ascq ==0x9 )) { +if (sshdr->sense_code ==CAPACITY_DATA_HAS_CHANGED ) { process_err_fn = storvsc_device_scan;/* Retry the I/O that triggered this. */ set_host_byte (scmnd,DID_REQUEUE );
@@ -1049,8 +1049,12 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,* want scsi_report_sense() to output a message * that a sysadmin wouldn't know what to do with. */ -if ((asc ==0x3f ) && (ascq !=0x03 ) && - (ascq !=0x0e )) { +if (scsi_sense_asc (sshdr) == +ASC_TARGET_OPERATING_CONDITIONS_HAVE_CHANGED && + sshdr->sense_code != +INQUIRY_DATA_HAS_CHANGED && + sshdr->sense_code != +REPORTED_LUNS_DATA_HAS_CHANGED ) { process_err_fn = storvsc_device_scan;set_host_byte (scmnd,DID_REQUEUE ); goto do_work;
@@ -1141,8 +1145,7 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request, }if (vm_srb->srb_status !=SRB_STATUS_SUCCESS ) { -storvsc_handle_error (vm_srb, scmnd, host, sense_hdr.asc, - sense_hdr.ascq); +storvsc_handle_error (vm_srb, scmnd, host, &sense_hdr);/* * The Windows driver set data_transfer_length on * SRB_STATUS_DATA_OVERRUN. On other errors, this value
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 33/40] scsi: storvsc: use 16-bits defined sense codes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The sense_hdr structure is read uninitialized in storvsc_handle_error if a command completes with scsi_status == 0 but an SRB error status and the AUTOSENSE_VALID flag set. --
commit 08f20503dd93893c68326306a042bfdb6e31394b
Author: Damien Le Moal <[email protected]>
scsi: storvsc: use 16-bits defined sense codes
This commit refactors the storvsc driver to use the 16-bit sense_code field of struct scsi_sense_hdr and replaces hard-coded additional sense codes with enum values defined in include/scsi/scsi_sense.h.
Quoted 4 lines
drivers/scsi/storvsc_drv.c +0
-0
[ ... ]
drivers/scsi/storvsc_drv.c static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request, · line 1148
Quoted 7 lines
drivers/scsi/storvsc_drv.c +1
-2@@ -1141,8 +1145,7 @@ static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request, }if (vm_srb->srb_status !=SRB_STATUS_SUCCESS ) { -storvsc_handle_error (vm_srb, scmnd, host, sense_hdr.asc, - sense_hdr.ascq); +storvsc_handle_error (vm_srb, scmnd, host, &sense_hdr);
[Severity: High]
This isn't a bug introduced by this patch, but does passing &sense_hdr here risk reading uninitialized memory if the command completes with scsi_status == 0?
In storvsc_command_completion(), sense_hdr is declared on the stack without initialization. It is only populated if scmnd->result is non-zero:
storvsc_command_completion() {
struct scsi_sense_hdr sense_hdr;
...
if (scmnd->result) {
sense_ok = scsi_normalize_sense(..., &sense_hdr);
...
}
if (vm_srb->srb_status != SRB_STATUS_SUCCESS) {
storvsc_handle_error(vm_srb, scmnd, host, &sense_hdr);If the Hyper-V host returns scsi_status == 0 but an SRB error occurred (for example, with AUTOSENSE_VALID set), storvsc_handle_error() is called with the uninitialized sense_hdr.
Inside storvsc_handle_error(), this leads directly to evaluating uninitialized stack memory when checking sshdr->sense_code for CAPACITY_DATA_HAS_CHANGED or other statuses.
Quoted 3 lines
drivers/scsi/storvsc_drv.c +0
-0/* * The Windows driver set data_transfer_length on * SRB_STATUS_DATA_OVERRUN. On other errors, this value
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=33
Re: [PATCH v2 33/40] scsi: storvsc: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the storvsc driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/storvsc_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 34/40 target: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the target core code to use the 16-bits sense codes for building sense and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/target/target_core_spc.c | 11 +++++----- drivers/target/target_core_transport.c | 11 +++++----- drivers/target/target_core_ua.c | 28 ++++++++++---------------- drivers/target/target_core_ua.h | 7 +++---- 4 files changed, 25 insertions(+), 32 deletions(-)
drivers/target/target_core_spc.c +6 -5
@@ -1226,9 +1226,9 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) {unsigned char *cdb = cmd->t_task_cdb;unsigned char *rbuf; -u8 ua_asc =0 , ua_ascq =0 ;unsigned char buf[SE_SENSE_BUF ];bool desc_format =target_sense_desc_format (cmd->se_dev); +u16 sense_code;memset (buf,0 ,SE_SENSE_BUF );
@@ -1242,11 +1242,12 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd)if (!rbuf)return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ; -if (!core_scsi3_ua_clear_for_request_sense (cmd, &ua_asc, &ua_ascq)) -scsi_build_sense_buffer (desc_format, buf,UNIT_ATTENTION , - ua_asc, ua_ascq); +if (!core_scsi3_ua_clear_for_request_sense (cmd, &sense_code)) +scsi_set_sense_buffer (desc_format, buf,UNIT_ATTENTION , + sense_code);else -scsi_build_sense_buffer (desc_format, buf,NO_SENSE ,0x0 ,0x0 ); +scsi_set_sense_buffer (desc_format, buf,NO_SENSE , +NO_ADDITIONAL_SENSE_INFORMATION );memcpy (rbuf, buf,min_t (u32,sizeof (buf), cmd->data_length));transport_kunmap_data_sg (cmd);
drivers/target/target_core_transport.c +5 -6
@@ -3555,7 +3555,8 @@ static void translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason)const struct sense_detail *sd;u8 *buffer = cmd->sense_buffer;int r = (__force int )reason; -u8 key, asc, ascq; +u16 code; +u8 key;bool desc_format =target_sense_desc_format (cmd->se_dev);if (r <ARRAY_SIZE (sense_detail_table) && sense_detail_table[r].key)
@@ -3566,21 +3567,19 @@ static void translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) key = sd->key;if (reason ==TCM_CHECK_CONDITION_UNIT_ATTENTION ) { -if (!core_scsi3_ua_for_check_condition (cmd, &key, &asc, - &ascq)) { +if (!core_scsi3_ua_for_check_condition (cmd, &key, &code)) { cmd->scsi_status =SAM_STAT_BUSY ;return ; } }else {WARN_ON_ONCE (sd->asc ==0 ); - asc = sd->asc; - ascq = sd->ascq; + code =scsi_sense_code (sd->asc, sd->ascq); } cmd->se_cmd_flags |=SCF_EMULATED_TASK_SENSE ; cmd->scsi_status =SAM_STAT_CHECK_CONDITION ; cmd->scsi_sense_length =TRANSPORT_SENSE_BUFFER ; -scsi_build_sense_buffer (desc_format, buffer, key, asc, ascq); +scsi_set_sense_buffer (desc_format, buffer, key, code);if (sd->add_sense_info) WARN_ON_ONCE(scsi_set_sense_information(buffer, cmd->scsi_sense_length,
drivers/target/target_core_ua.c +11 -17
@@ -187,11 +187,10 @@ void core_scsi3_ua_release_all(/* * Dequeue a unit attention from the unit attention list. This function -* returns true if the dequeuing succeeded and if *@key, *@asc and *@ascq have +* returns true if the dequeuing succeeded and if *@key and *@code have * been set. */ -bool core_scsi3_ua_for_check_condition (struct se_cmd *cmd,u8 *key,u8 *asc, -u8 *ascq) +bool core_scsi3_ua_for_check_condition (struct se_cmd *cmd,u8 *key,u16 *code) {struct se_device *dev = cmd->se_dev;struct se_dev_entry *deve;
@@ -214,8 +213,7 @@ bool core_scsi3_ua_for_check_condition(struct se_cmd *cmd, u8 *key, u8 *asc,if (!deve) {rcu_read_unlock (); *key =ILLEGAL_REQUEST ; - *asc =0x25 ;/* LOGICAL UNIT NOT SUPPORTED */ - *ascq =0 ; + *code =LU_NOT_SUPPORTED ;return true; } *key =UNIT_ATTENTION ;
@@ -232,8 +230,7 @@ bool core_scsi3_ua_for_check_condition(struct se_cmd *cmd, u8 *key, u8 *asc,* clearing it. */ if (!dev_ua_intlck_clear) { - *asc = ua->ua_asc; - *ascq = ua->ua_ascq; + *code =scsi_sense_code (ua->ua_asc, ua->ua_ascq);break ; }/*
@@ -242,8 +239,7 @@ bool core_scsi3_ua_for_check_condition(struct se_cmd *cmd, u8 *key, u8 *asc,* (head of the list) in the outgoing CHECK_CONDITION + sense. */ if (head) { - *asc = ua->ua_asc; - *ascq = ua->ua_ascq; + *code =scsi_sense_code (ua->ua_asc, ua->ua_ascq); head =0 ; }list_del (&ua->ua_nacl_list);
@@ -258,15 +254,13 @@ bool core_scsi3_ua_for_check_condition(struct se_cmd *cmd, u8 *key, u8 *asc, nacl->se_tpg->se_tpg_tfo->fabric_name, dev_ua_intlck_clear ?"Releasing" :"Reporting" , dev->dev_attrib.emulate_ua_intlck_ctrl, - cmd->orig_fe_lun, cmd->t_task_cdb[0], *asc, *ascq); + cmd->orig_fe_lun, cmd->t_task_cdb[0 ], + scsi_sense_code_asc(*code), scsi_sense_code_ascq(*code));return head ==0 ; } -int core_scsi3_ua_clear_for_request_sense ( -struct se_cmd *cmd, -u8 *asc, -u8 *ascq) +int core_scsi3_ua_clear_for_request_sense (struct se_cmd *cmd,u16 *code) {struct se_dev_entry *deve;struct se_session *sess = cmd->se_sess;
@@ -304,8 +298,7 @@ int core_scsi3_ua_clear_for_request_sense(spin_lock (&deve->ua_lock);list_for_each_entry_safe (ua, ua_p, &deve->ua_list, ua_nacl_list) {if (head) { - *asc = ua->ua_asc; - *ascq = ua->ua_ascq; + *code =scsi_sense_code (ua->ua_asc, ua->ua_ascq); head =0 ; }list_del (&ua->ua_nacl_list);
@@ -317,7 +310,8 @@ int core_scsi3_ua_clear_for_request_sense(pr_debug ("[%s]: Released UNIT ATTENTION condition, mapped" " LUN: %llu, got REQUEST_SENSE reported ASC: 0x%02x," " ASCQ: 0x%02x\n" , nacl->se_tpg->se_tpg_tfo->fabric_name, - cmd->orig_fe_lun, *asc, *ascq); + cmd->orig_fe_lun,scsi_sense_code_asc (*code), +scsi_sense_code_ascq (*code));return (head) ? -EPERM :0 ; }
drivers/target/target_core_ua.h +3 -4
@@ -37,9 +37,8 @@ extern sense_reason_t target_scsi3_ua_check(struct se_cmd *);extern int core_scsi3_ua_allocate (struct se_dev_entry *,u8 ,u8 );extern void target_ua_allocate_lun (struct se_node_acl *,u32 ,u8 ,u8 );extern void core_scsi3_ua_release_all (struct se_dev_entry *); -extern bool core_scsi3_ua_for_check_condition (struct se_cmd *,u8 *,u8 *, -u8 *); -extern int core_scsi3_ua_clear_for_request_sense (struct se_cmd *, -u8 *,u8 *); +extern bool core_scsi3_ua_for_check_condition (struct se_cmd *cmd,u8 *key, +u16 *code); +extern int core_scsi3_ua_clear_for_request_sense (struct se_cmd *cmd,u16 *code);#endif /* TARGET_CORE_UA_H */
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 34/40] target: use 16-bits defined sense codes
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Uninitialized stack variable read in debug log due to concurrent list modification
Pre-existing issues:
- [High] Logic error causes Unit Attention Interlock to fail and incorrectly return SAM_STAT_BUSY --
commit 95a802c45c6965b17dd9cccbc6b6421dcf571862
Author: Damien Le Moal <[email protected]>
target: use 16-bits defined sense codes
Refactor the target core code to use the 16-bits sense codes for building sense and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
drivers/target/target_core_spc.c static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) · line 1231
Quoted 12 lines
drivers/target/target_core_spc.c +1
-1@@ -1226,9 +1226,9 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) {unsigned char *cdb = cmd->t_task_cdb;unsigned char *rbuf; -u8 ua_asc =0 , ua_ascq =0 ;unsigned char buf[SE_SENSE_BUF ];bool desc_format =target_sense_desc_format (cmd->se_dev); +u16 sense_code;
[Severity: Medium]
Could this uninitialized variable cause an issue?
The previous code initialized ua_asc and ua_ascq to 0, but sense_code is left uninitialized here.
[ ... ]
Quoted 4 lines
drivers/target/target_core_ua.c +0
-0
[ ... ]
drivers/target/target_core_ua.c bool core_scsi3_ua_for_check_condition(struct se_cmd *cmd, u8 *key, u8 *asc, · line 235
Quoted 9 lines
drivers/target/target_core_ua.c +1
-2@@ -232,8 +230,7 @@ bool core_scsi3_ua_for_check_condition(struct se_cmd *cmd, u8 *key, u8 *asc,* clearing it. */ if (!dev_ua_intlck_clear) { - *asc = ua->ua_asc; - *ascq = ua->ua_ascq; + *code =scsi_sense_code (ua->ua_asc, ua->ua_ascq);break ; }
[Severity: High]
This is a pre-existing issue, but if dev_ua_intlck_clear is false, the loop breaks early without updating the head variable to 0.
Since head remains 1, core_scsi3_ua_for_check_condition() later returns head == 0, which evaluates to false.
Does this incorrect return value mislead the target core into aborting the sense processing in translate_sense_reason() and returning a SAM_STAT_BUSY status instead of a CHECK CONDITION?
[ ... ]
drivers/target/target_core_ua.c int core_scsi3_ua_clear_for_request_sense( · line 317
Quoted 10 lines
drivers/target/target_core_ua.c +2
-1@@ -317,7 +310,8 @@ int core_scsi3_ua_clear_for_request_sense(pr_debug ("[%s]: Released UNIT ATTENTION condition, mapped" " LUN: %llu, got REQUEST_SENSE reported ASC: 0x%02x," " ASCQ: 0x%02x\n" , nacl->se_tpg->se_tpg_tfo->fabric_name, - cmd->orig_fe_lun, *asc, *ascq); + cmd->orig_fe_lun,scsi_sense_code_asc (*code), +scsi_sense_code_ascq (*code));return (head) ? -EPERM :0 ; }
[Severity: Medium]
Is it possible for this debug log to read the uninitialized stack variable from spc_emulate_request_sense()?
If the list is cleared concurrently between the lockless list_empty_careful() check and acquiring the ua_lock, the loop is skipped and *code is never assigned.
Will this unconditionally pass uninitialized memory to pr_debug() and potentially trigger a KMSAN warning?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=34
Re: [PATCH v2 34/40] target: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 8 lines · Damien Le Moal
Refactor the target core code to use the 16-bits sense codes for building sense and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Quoted 8 lines
Signed-off-by Damien Le Moal <[email protected]>--- drivers/target/target_core_spc.c | 11 +++++----- drivers/target/target_core_transport.c | 11 +++++----- drivers/target/target_core_ua.c | 28 ++++++++++---------------- drivers/target/target_core_ua.h | 7 +++---- 4 files changed, 25 insertions(+), 32 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 35/40 usb: storage: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the USB mass storage driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/usb/gadget/function/f_mass_storage.c | 34 +++++----- drivers/usb/gadget/function/storage_common.h | 71 +++++++++++++++----- drivers/usb/storage/transport.c | 5 +- 3 files changed, 74 insertions(+), 36 deletions(-)
drivers/usb/gadget/function/f_mass_storage.c +18 -16
@@ -1103,9 +1103,9 @@ static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh)* FSG normally uses option a); enable this code to use option b). */ #if 0 -if (curlun && curlun->unit_attention_data !=SS_NO_SENSE ) { +if (curlun && curlun->unit_attention_data !=NO_SENSE ) { curlun->sense_data = curlun->unit_attention_data; - curlun->unit_attention_data =SS_NO_SENSE ; + curlun->unit_attention_data =NO_SENSE ; }#endif
@@ -1118,18 +1118,18 @@ static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh) sd = curlun->sense_data; sdinfo = curlun->sense_data_info; valid = curlun->info_valid <<7 ; - curlun->sense_data =SS_NO_SENSE ; + curlun->sense_data =NO_SENSE ; curlun->sense_data_info =0 ; curlun->info_valid =0 ; }memset (buf,0 ,18 ); buf[0 ] = valid |0x70 ;/* Valid, current error */ - buf[2 ] =SK (sd); + buf[2 ] =usb_sense_key (sd);put_unaligned_be32 (sdinfo, &buf[3 ]);/* Sense information */ buf[7 ] =18 -8 ;/* Additional sense length */ - buf[12 ] =ASC (sd); - buf[13 ] =ASCQ (sd); + buf[12 ] =usb_sense_asc (sd); + buf[13 ] =usb_sense_ascq (sd);return 18 ; }
@@ -1678,21 +1678,23 @@ static void send_status(struct fsg_common *common)if (curlun) { sd = curlun->sense_data; sdinfo = curlun->sense_data_info; - }else if (common->bad_lun_okay) - sd =SS_NO_SENSE ; -else + }else if (common->bad_lun_okay) { + sd =NO_SENSE ; + }else { sd =SS_LOGICAL_UNIT_NOT_SUPPORTED ; + }if (common->phase_error) {DBG (common,"sending phase-error status\n" ); status =US_BULK_STAT_PHASE ; sd =SS_INVALID_COMMAND ; - }else if (sd !=SS_NO_SENSE ) { + }else if (sd !=NO_SENSE ) {DBG (common,"sending command-failure status\n" ); status =US_BULK_STAT_FAIL ;VDBG (common," sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" " info x%x\n" , -SK (sd),ASC (sd),ASCQ (sd), sdinfo); +usb_sense_key (sd),usb_sense_asc (sd), +usb_sense_ascq (sd), sdinfo); }/* Store and send the Bulk-only CSW */
@@ -1798,7 +1800,7 @@ static int check_command(struct fsg_common *common, int cmnd_size, curlun = common->curlun;if (curlun) {if (common->cmnd[0 ] !=REQUEST_SENSE ) { - curlun->sense_data =SS_NO_SENSE ; + curlun->sense_data =NO_SENSE ; curlun->sense_data_info =0 ; curlun->info_valid =0 ; }
@@ -1820,11 +1822,11 @@ static int check_command(struct fsg_common *common, int cmnd_size,* If a unit attention condition exists, only INQUIRY and * REQUEST SENSE commands are allowed; anything else must fail. */ -if (curlun && curlun->unit_attention_data !=SS_NO_SENSE && +if (curlun && curlun->unit_attention_data !=NO_SENSE && common->cmnd[0 ] !=INQUIRY && common->cmnd[0 ] !=REQUEST_SENSE ) { curlun->sense_data = curlun->unit_attention_data; - curlun->unit_attention_data =SS_NO_SENSE ; + curlun->unit_attention_data =NO_SENSE ;return -EINVAL ; }
@@ -2501,8 +2503,8 @@ static void handle_exception(struct fsg_common *common)if (!curlun)continue ; curlun->prevent_medium_removal =0 ; - curlun->sense_data =SS_NO_SENSE ; - curlun->unit_attention_data =SS_NO_SENSE ; + curlun->sense_data =NO_SENSE ; + curlun->unit_attention_data =NO_SENSE ; curlun->sense_data_info =0 ; curlun->info_valid =0 ; }
drivers/usb/gadget/function/storage_common.h +53 -18
77 lines not on this page · raw message
drivers/usb/storage/transport.c +3 -2
@@ -803,7 +803,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) temp_result);usb_stor_dbg (us,"-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n" , sshdr.response_code, sshdr.sense_key, - sshdr.asc, sshdr.ascq); +scsi_sense_asc (&sshdr),scsi_sense_ascq (&sshdr));#ifdef CONFIG_USB_STORAGE_DEBUG usb_stor_show_sense (us, &sshdr);#endif
@@ -820,7 +820,8 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)* everything worked or that there was an unspecified * problem. We have to decide which. */ -if (sshdr.sense_key ==0 && sshdr.asc ==0 && sshdr.ascq ==0 && +if (sshdr.sense_key ==NO_SENSE && + sshdr.sense_code ==NO_ADDITIONAL_SENSE_INFORMATION && fm_ili ==0 ) {/* * If things are really okay, then let's show that.
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 35/40] usb: storage: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
Refactor the USB mass storage driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=35
Re: [PATCH v2 35/40] usb: storage: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 5 lines · Damien Le Moal
Refactor the USB mass storage driver to replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 9 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/usb/gadget/function/f_mass_storage.c | 34 +++++----- drivers/usb/gadget/function/storage_common.h | 71 +++++++++++++++----- drivers/usb/storage/transport.c | 5 +- 3 files changed, 74 insertions(+), 36 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 36/40 cdrom: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor the cdrom driver to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/cdrom/cdrom.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/cdrom/cdrom.c +4 -6
@@ -345,9 +345,8 @@ int cdrom_dummy_generic_packet(struct cdrom_device_info *cdi, struct packet_command *cgc) {if (cgc->sshdr) { - cgc->sshdr->sense_key =0x05 ; - cgc->sshdr->asc =0x20 ; - cgc->sshdr->ascq =0x00 ; + cgc->sshdr->sense_key =ILLEGAL_REQUEST ; + cgc->sshdr->sense_code =INVALID_COMMAND_OP_CODE ; } cgc->stat = -EIO ;
@@ -2979,9 +2978,8 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi, cgc->sshdr = &sshdr; cgc->data_direction =CGC_DATA_READ ; ret =cdrom_read_block (cdi, cgc, lba,1 , format, blocksize); -if (ret && sshdr.sense_key ==0x05 && - sshdr.asc ==0x20 && - sshdr.ascq ==0x00 ) { +if (ret && sshdr.sense_key ==ILLEGAL_REQUEST && + sshdr.sense_code ==INVALID_COMMAND_OP_CODE ) {/* * SCSI-II devices are not required to support * READ_CD, so let's try switching block size
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 36/40] cdrom: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor the cdrom driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=36
Re: [PATCH v2 36/40] cdrom: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Refactor the cdrom driver to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/cdrom/cdrom.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 37/40 ata: libata: use 16-bits defined sense codes
In reply to Damien Le MoalRefactor libata core code to use the 16-bits sense_code field of struct scsi_sense_hdr and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/ata/libata-eh.c | 13 +- drivers/ata/libata-sata.c | 20 +-- drivers/ata/libata-scsi.c | 346 +++++++++++++++++++++++--------------- drivers/ata/libata.h | 5 +- 4 files changed, 229 insertions(+), 155 deletions(-)
drivers/ata/libata-eh.c +8 -5
@@ -1516,11 +1516,13 @@ static bool ata_eh_request_sense(struct ata_queued_cmd *qc) err_mask =ata_exec_internal (dev, &tf,NULL ,DMA_NONE ,NULL ,0 ,0 );/* Ignore err_mask; ATA_ERR might be set */ if (tf.status &ATA_SENSE ) { -if (ata_scsi_sense_is_valid (tf.lbah, tf.lbam, tf.lbal)) { +u16 sense_code =scsi_sense_code (tf.lbam, tf.lbal); + +if (ata_scsi_sense_is_valid (tf.lbah, sense_code)) {/* Set sense without also setting scsicmd->result */ -scsi_build_sense_buffer (dev->flags &ATA_DFLAG_D_SENSE , - cmd->sense_buffer, tf.lbah, - tf.lbam, tf.lbal); +scsi_set_sense_buffer (dev->flags &ATA_DFLAG_D_SENSE , + cmd->sense_buffer, tf.lbah, + sense_code); qc->flags |=ATA_QCFLAG_SENSE_VALID ;return true; }
@@ -2094,7 +2096,8 @@ static void ata_eh_get_success_sense(struct ata_link *link)continue ;/* This success command had sense data, but we failed to get. */ -ata_scsi_set_sense (dev, qc->scsicmd,ABORTED_COMMAND ,0 ,0 ); +ata_scsi_set_sense (dev, qc->scsicmd,ABORTED_COMMAND , +NO_ADDITIONAL_SENSE_INFORMATION ); qc->flags |=ATA_QCFLAG_SENSE_VALID ; }ata_eh_done (link, dev,ATA_EH_GET_SUCCESS_SENSE );
drivers/ata/libata-sata.c +10 -10
@@ -1588,7 +1588,7 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link) asc = sense[1 ]; ascq = sense[2 ]; -if (!ata_scsi_sense_is_valid (sk, asc, ascq)) { +if (!ata_scsi_sense_is_valid (sk,scsi_sense_code (asc, ascq))) { ret = -EIO ;continue ; }
@@ -1605,9 +1605,9 @@ int ata_eh_get_ncq_success_sense(struct ata_link *link) qc->result_tf.auxiliary =get_unaligned_le32 (&sense[16 ]);/* Set sense without also setting scsicmd->result */ -scsi_build_sense_buffer (dev->flags &ATA_DFLAG_D_SENSE , - qc->scsicmd->sense_buffer, sk, - asc, ascq); +scsi_set_sense_buffer (dev->flags &ATA_DFLAG_D_SENSE , + qc->scsicmd->sense_buffer, sk, +scsi_sense_code (asc, ascq)); qc->flags |=ATA_QCFLAG_SENSE_VALID ;/*
@@ -1684,14 +1684,14 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)* stored the sense data in qc->result_tf.auxiliary. */ if (qc->result_tf.auxiliary) { -char sense_key, asc, ascq; +u16 sense_code; +u8 sense_key; sense_key = (qc->result_tf.auxiliary >>16 ) &0xff ; - asc = (qc->result_tf.auxiliary >>8 ) &0xff ; - ascq = qc->result_tf.auxiliary &0xff ; -if (ata_scsi_sense_is_valid (sense_key, asc, ascq)) { -ata_scsi_set_sense (dev, qc->scsicmd, sense_key, asc, - ascq); + sense_code = qc->result_tf.auxiliary &0xffff ; +if (ata_scsi_sense_is_valid (sense_key, sense_code)) { +ata_scsi_set_sense (dev, qc->scsicmd, sense_key, + sense_code); qc->flags |=ATA_QCFLAG_SENSE_VALID ; } }
drivers/ata/libata-scsi.c +208 -138
576 lines not on this page · raw message
drivers/ata/libata.h +3 -2
@@ -164,9 +164,10 @@ extern int ata_scsi_add_hosts(struct ata_host *host, const struct scsi_host_template *sht);extern void ata_scsi_scan_host (struct ata_port *ap,int sync);extern bool ata_scsi_offline_dev (struct ata_device *dev); -extern bool ata_scsi_sense_is_valid (u8 sk,u8 asc,u8 ascq); +extern bool ata_scsi_sense_is_valid (u8 sense_key,u16 sense_code);extern void ata_scsi_set_sense (struct ata_device *dev, -struct scsi_cmnd *cmd,u8 sk,u8 asc,u8 ascq); +struct scsi_cmnd *cmd,u8 sense_key, +u16 sense_code);extern void ata_scsi_media_change_notify (struct ata_device *dev);extern void ata_scsi_hotplug (struct work_struct *work);extern void ata_scsi_dev_rescan (struct work_struct *work);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 37/40] ata: libata: use 16-bits defined sense codes
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
Refactor libata core code to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=37
Re: [PATCH v2 37/40] ata: libata: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 9 lines · Damien Le Moal
Refactor libata core code to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>
Re: [PATCH v2 37/40] ata: libata: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 8 lines · Damien Le Moal
Refactor libata core code to use the 16-bits
sense_codefield of structscsi_sense_hdrand replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined ininclude/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.No functional change intended.
Quoted 8 lines
Signed-off-by Damien Le Moal <[email protected]>--- drivers/ata/libata-eh.c | 13 +- drivers/ata/libata-sata.c | 20 +-- drivers/ata/libata-scsi.c | 346 +++++++++++++++++++++++--------------- drivers/ata/libata.h | 5 +- 4 files changed, 229 insertions(+), 155 deletions(-)
Finally :-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 38/40 s390: scsi: use 16-bits defined sense codes
In reply to Damien Le MoalUse the 16-bits sense codes and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
No functional change intended.
--- drivers/s390/scsi/zfcp_scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/s390/scsi/zfcp_scsi.c +2 -1
@@ -856,7 +856,8 @@ void zfcp_scsi_set_prot(struct zfcp_adapter *adapter)*/ void zfcp_scsi_dif_sense_error (struct scsi_cmnd *scmd,int ascq) { -scsi_build_sense (scmd,1 ,ILLEGAL_REQUEST ,0x10 , ascq); +scsi_set_sense (scmd,1 ,ILLEGAL_REQUEST , +scsi_sense_code (ASC_ID_CRC_OR_ECC_ERROR , ascq));set_host_byte (scmd,DID_SOFT_ERROR ); }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 38/40] s390: scsi: use 16-bits defined sense codes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Incomplete refactoring leaves hard-coded ASCQ values in `zfcp_fsf.c`, contradicting the commit…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incomplete refactoring leaves hard-coded ASCQ values in zfcp_fsf.c, contradicting the commit message. --
commit a120aaf764276a0a8205d59d479d4eea2ff29d24
Author: Damien Le Moal <[email protected]>
s390: scsi: use 16-bits defined sense codes
Use the 16-bits sense codes and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
drivers/s390/scsi/zfcp_scsi.c void zfcp_scsi_set_prot(struct zfcp_adapter *adapter) · line 860
Quoted 11 lines
drivers/s390/scsi/zfcp_scsi.c +2
-1@@ -856,7 +856,8 @@ void zfcp_scsi_set_prot(struct zfcp_adapter *adapter)*/ void zfcp_scsi_dif_sense_error (struct scsi_cmnd *scmd,int ascq) { -scsi_build_sense (scmd,1 ,ILLEGAL_REQUEST ,0x10 , ascq); +scsi_set_sense (scmd,1 ,ILLEGAL_REQUEST , +scsi_sense_code (ASC_ID_CRC_OR_ECC_ERROR , ascq));
[Severity: Medium]
Does leaving the ascq parameter as an integer leave hard-coded additional sense code qualifiers in the codebase, contradicting the commit message?
Looking at drivers/s390/scsi/zfcp_fsf.c:zfcp_fsf_fcp_cmnd_handler():
case FSF_BLOCK_GUARD_CHECK_FAILURE: zfcp_scsi_dif_sense_error(scpnt, 0x1); goto skip_fsfstatus; case FSF_APP_TAG_CHECK_FAILURE: zfcp_scsi_dif_sense_error(scpnt, 0x2);
It appears the hard-coded literals (0x1, 0x2) are still being used here instead of the new 16-bit enum values.
Could the function signature and callers be updated to use the full 16-bit enums (e.g., LOGICAL_BLOCK_GUARD_CHECK_FAILED) to completely remove these hard-coded values?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=38
Re: [PATCH v2 38/40] s390: scsi: use 16-bits defined sense codes
In reply to Damien Le MoalQuoted 5 lines · Damien Le Moal
Use the 16-bits sense codes and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>--- drivers/s390/scsi/zfcp_scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerRe: [PATCH v2 38/40] s390: scsi: use 16-bits defined sense codes
Quoted 6 lines · Hannes Reinecke
Quoted 5 lines · Damien Le Moal
Use the 16-bits sense codes and replace all hard-coded additional sense codes and additional sense code qualifiers with the enum values defined in
include/scsi/scsi_sense.h. This helps with code clarity as the sense codes being processed are easier to test and self-documented.
Quoted 8 lines
Quoted 7 lines
No functional change intended.
Signed-off-by Damien Le Moal <[email protected]>---
drivers/s390/scsi/zfcp_scsi.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Hannes Reinecke <[email protected]>
Hannes,
Thanks a lot for the review. But I posted a v5 of the series yesterday... There are a few minor tweaks in v3, v4 and v5 compared to v2, mostly to address sashiko review comments. If that is OK with you, I will carry your review tags to v6 (need one more correction), unless you want to review that version.
Signature · 2 lines
Damien Le Moal Western Digital Research
Damien Le Moal
maintainerPATCH v2 39/40 scsi: cleanup scsi_proto.h
In reply to Damien Le MoalNow that all users of SCSI sense codes have been modified to use macro definitions and the 16-bits sense code instead of separate 8-bits ASC and ASCQ, remove the now unused asc and ascq fields of struct scsi_failure and struct scsi_sense_hdr, and the old (and incomplete) definitions of SCSI additional sense codes and sense code qualifiers in scsi_proto.h.
--- include/scsi/scsi_common.h | 13 +--------- include/scsi/scsi_device.h | 13 +--------- include/scsi/scsi_proto.h | 51 -------------------------------------- 3 files changed, 2 insertions(+), 75 deletions(-)
include/scsi/scsi_common.h +1 -12
@@ -71,18 +71,7 @@ extern u64 scsilun_to_int(struct scsi_lun *);struct scsi_sense_hdr {/* See SPC-3 section 4.5 */ u8 response_code;/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ u8 sense_key; -union { -struct { -#if defined(__BIG_ENDIAN) -u8 asc; -u8 ascq; -#elif defined(__LITTLE_ENDIAN) -u8 ascq; -u8 asc; -#endif - }; -u16 sense_code; - }; +u16 sense_code;u8 byte4;u8 byte5;u8 byte6;
include/scsi/scsi_device.h +1 -12
@@ -527,18 +527,7 @@ extern void scsi_sanitize_inquiry_string(unsigned char *s, int len);struct scsi_failure {int result;u8 sense_key; -union { -struct { -#if defined(__BIG_ENDIAN) -u8 asc; -u8 ascq; -#elif defined(__LITTLE_ENDIAN) -u8 ascq; -u8 asc; -#endif - }; -u16 sense_code; - }; +u16 sense_code;/* * Number of times scsi_execute_cmd will retry the failure. It does * not count for the total_allowed.
include/scsi/scsi_proto.h +0 -51
57 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 39/40] scsi: cleanup scsi_proto.h
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
Now that all users of SCSI sense codes have been modified to use macro definitions and the 16-bits sense code instead of separate 8-bits ASC and ASCQ, remove the now unused asc and ascq fields of struct
scsi_failureand structscsi_sense_hdr, and the old (and incomplete) definitions of SCSI additional sense codes and sense code qualifiers inscsi_proto.h.Signed-off-by Damien Le Moal <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=39
Re: [PATCH v2 39/40] scsi: cleanup scsi_proto.h
In reply to Damien Le MoalQuoted 6 lines · Damien Le Moal
Now that all users of SCSI sense codes have been modified to use macro definitions and the 16-bits sense code instead of separate 8-bits ASC and ASCQ, remove the now unused asc and ascq fields of struct
scsi_failureand structscsi_sense_hdr, and the old (and incomplete) definitions of SCSI additional sense codes and sense code qualifiers inscsi_proto.h.
Quoted 7 lines
Signed-off-by Damien Le Moal <[email protected]>--- include/scsi/scsi_common.h | 13 +--------- include/scsi/scsi_device.h | 13 +--------- include/scsi/scsi_proto.h | 51 -------------------------------------- 3 files changed, 2 insertions(+), 75 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Damien Le Moal
maintainerPATCH v2 40/40 scsi: remove scsi_build_sense() and scsi_build_sense_buffer()
In reply to Damien Le MoalNow that all code has been converted to use 16-bits sense codes and to initialize sense with scsi_set_sense() and scsi_set_sense_buffer(), remove the inline definitions of these new functions, change scsi_build_sense() and scsi_build_sense_buffer() to use a single 16-bits sense code as argument (instead of separate arguments for the ASC and ASCQ), and rename them to scsi_set_sense() and scsi_set_sense_buffer().
--- drivers/scsi/scsi_common.c | 12 +++++++----- drivers/scsi/scsi_lib.c | 8 ++++---- include/scsi/scsi_cmnd.h | 10 +--------- include/scsi/scsi_common.h | 8 +------- 4 files changed, 13 insertions(+), 25 deletions(-)
drivers/scsi/scsi_common.c +7 -5
@@ -276,17 +276,19 @@ const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len,EXPORT_SYMBOL (scsi_sense_desc_find);/** -* scsi_build_sense_buffer - build sense data in a buffer +* scsi_set_sense_buffer - build sense data in a buffer * @desc: Sense format (non-zero == descriptor format, * 0 == fixed format) * @buf: Where to build sense data * @key: Sense key -* @asc: Additional sense code -* @ascq: Additional sense code qualifier +* @code: Additional sense code and its code qualifier * **/ -void scsi_build_sense_buffer (int desc,u8 *buf,u8 key,u8 asc,u8 ascq) +void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code) { +u8 asc =scsi_sense_code_asc (code); +u8 ascq =scsi_sense_code_ascq (code); +if (desc) { buf[0 ] =0x72 ;/* descriptor, current */ buf[1 ] = key;
@@ -301,7 +303,7 @@ void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq) buf[13 ] = ascq; } } -EXPORT_SYMBOL (scsi_build_sense_buffer); +EXPORT_SYMBOL (scsi_set_sense_buffer);/** * scsi_set_sense_information - set the information field in a
drivers/scsi/scsi_lib.c +4 -4
@@ -3585,7 +3585,7 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id)EXPORT_SYMBOL (scsi_vpd_tpg_id);/** -* scsi_build_sense - build sense data for a command +* scsi_set_sense - build sense data for a command * @scmd: scsi command for which the sense should be formatted * @desc: Sense format (non-zero == descriptor format, * 0 == fixed format)
@@ -3594,12 +3594,12 @@ EXPORT_SYMBOL(scsi_vpd_tpg_id);* @ascq: Additional sense code qualifier * **/ -void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq) +void scsi_set_sense (struct scsi_cmnd *scmd,int desc,u8 key,u16 code) { -scsi_build_sense_buffer (desc, scmd->sense_buffer, key, asc, ascq); +scsi_set_sense_buffer (desc, scmd->sense_buffer, key, code); scmd->result =SAM_STAT_CHECK_CONDITION ; } -EXPORT_SYMBOL_GPL (scsi_build_sense); +EXPORT_SYMBOL_GPL (scsi_set_sense);#ifdef CONFIG_SCSI_LIB_KUNIT_TEST #include "scsi_lib_test.c"
include/scsi/scsi_cmnd.h +1 -9
@@ -391,15 +391,7 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)return xfer_len; } -extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc, -u8 key,u8 asc,u8 ascq); - -static inline void scsi_set_sense (struct scsi_cmnd *scmd,int desc, -u8 key,u16 code) -{ -scsi_build_sense (scmd, desc, key,scsi_sense_code_asc (code), -scsi_sense_code_ascq (code)); -} +void scsi_set_sense (struct scsi_cmnd *scmd,int desc,u8 key,u16 code);struct request *scsi_alloc_request (struct request_queue *q,blk_opf_t opf,blk_mq_req_flags_t flags);
include/scsi/scsi_common.h +1 -7
@@ -99,13 +99,7 @@ static inline u8 scsi_sense_ascq(const struct scsi_sense_hdr *sshdr)extern bool scsi_normalize_sense (const u8 *sense_buffer,int sb_len,struct scsi_sense_hdr *sshdr); -extern void scsi_build_sense_buffer (int desc,u8 *buf,u8 key,u8 asc,u8 ascq); - -static inline void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code) -{ -scsi_build_sense_buffer (desc, buf, key,scsi_sense_code_asc (code), -scsi_sense_code_ascq (code)); -} +void scsi_set_sense_buffer (int desc,u8 *buf,u8 key,u16 code);int scsi_set_sense_information (u8 *buf,int buf_len,u64 info);int scsi_set_sense_field_pointer (u8 *buf,int buf_len,u16 fp,u8 bp,bool cd);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH v2 40/40] scsi: remove scsi_build_sense() and scsi_build_sense_buffer()
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The kernel-doc block for scsi_set_sense() is outdated, documenting removed parameters instead of…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The kernel-doc block for scsi_set_sense() is outdated, documenting removed parameters instead of the new parameter. --
commit 346248be55e45fce39f6b6a510b7c29fbb538f5c
Author: Damien Le Moal <[email protected]>
scsi: remove scsi_build_sense() and scsi_build_sense_buffer()
This commit converts the SCSI sense building functions to use a single 16-bit sense code parameter and renames them to scsi_set_sense() and scsi_set_sense_buffer().
Quoted 4 lines
drivers/scsi/scsi_lib.c +0
-0
[ ... ]
Quoted 10 lines
drivers/scsi/scsi_lib.c +1
-1@@ -3585,7 +3585,7 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id)EXPORT_SYMBOL (scsi_vpd_tpg_id);/** -* scsi_build_sense - build sense data for a command +* scsi_set_sense - build sense data for a command * @scmd: scsi command for which the sense should be formatted * @desc: Sense format (non-zero == descriptor format, * 0 == fixed format)
drivers/scsi/scsi_lib.c EXPORT_SYMBOL(scsi_vpd_tpg_id); · line 3597
Quoted 5 lines
drivers/scsi/scsi_lib.c +1
-1@@ -3594,12 +3594,12 @@ EXPORT_SYMBOL(scsi_vpd_tpg_id);* @ascq: Additional sense code qualifier * **/ -void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq) +void scsi_set_sense (struct scsi_cmnd *scmd,int desc,u8 key,u16 code)
[Severity: Low]
Does this kernel-doc block need updating for the new parameter?
It looks like the documentation for scsi_set_sense() still lists the removed @asc and @ascq parameters, but is missing the new @code parameter. This will likely cause warnings during documentation builds.
Quoted 5 lines
drivers/scsi/scsi_lib.c +1
-1{ -scsi_build_sense_buffer (desc, scmd->sense_buffer, key, asc, ascq); +scsi_set_sense_buffer (desc, scmd->sense_buffer, key, code); scmd->result =SAM_STAT_CHECK_CONDITION ; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=40
Re: [PATCH v2 40/40] scsi: remove scsi_build_sense() and scsi_build_sense_buffer()
In reply to Damien Le MoalQuoted 8 lines · Damien Le Moal
Now that all code has been converted to use 16-bits sense codes and to initialize sense with
scsi_set_sense()andscsi_set_sense_buffer(), remove the inline definitions of these new functions, changescsi_build_sense()andscsi_build_sense_buffer()to use a single 16-bits sense code as argument (instead of separate arguments for the ASC and ASCQ), and rename them toscsi_set_sense()andscsi_set_sense_buffer().Signed-off-by Damien Le Moal <[email protected]>
With the trivial kdoc nit for scsi_set_sense() pointed out by Sashiko fixed:
Re: [PATCH v2 40/40] scsi: remove scsi_build_sense() and scsi_build_sense_buffer()
In reply to Damien Le MoalQuoted 7 lines · Damien Le Moal
Now that all code has been converted to use 16-bits sense codes and to initialize sense with
scsi_set_sense()andscsi_set_sense_buffer(), remove the inline definitions of these new functions, changescsi_build_sense()andscsi_build_sense_buffer()to use a single 16-bits sense code as argument (instead of separate arguments for the ASC and ASCQ), and rename them toscsi_set_sense()andscsi_set_sense_buffer().
Quoted 8 lines
Signed-off-by Damien Le Moal <[email protected]>--- drivers/scsi/scsi_common.c | 12 +++++++----- drivers/scsi/scsi_lib.c | 8 ++++---- include/scsi/scsi_cmnd.h | 10 +--------- include/scsi/scsi_common.h | 8 +------- 4 files changed, 13 insertions(+), 25 deletions(-)
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich