@@ -143,7 +143,15 @@ class ScsiRequestSenseResponse private constructor() {
143143 MEDIUM_ERROR -> handleMediumError()
144144 HARDWARE_ERROR -> throw HardwareError (this )
145145 ILLEGAL_REQUEST -> throw IllegalCommand (this )
146- UNIT_ATTENTION -> throw UnitAttention (this )
146+ UNIT_ATTENTION -> {
147+ // Non-exhaustively handle recoverable unit attention conditions
148+ if (additionalSenseCode.toInt() == RESET_OCCURRED ||
149+ additionalSenseCode.toInt() == COMMANDS_CLEARED ) {
150+ throw NotReadyTryAgain (this )
151+ } else {
152+ throw UnitAttention (this )
153+ }
154+ }
147155 DATA_PROTECT -> throw DataProtect (this )
148156 BLANK_CHECK -> throw BlankCheck (this )
149157 COPY_ABORTED -> throw CopyAborted (this )
@@ -229,5 +237,33 @@ class ScsiRequestSenseResponse private constructor() {
229237 const val VOLUME_OVERFLOW = 13
230238 const val MISCOMPARE = 14
231239 const val COMPLETED = 15
240+
241+ /* *
242+ * Unit attention condition additional sense code for general device reset conditions.
243+ * It should be safe to handle these conditions with a retry.
244+ *
245+ * ASCQs indicate:
246+ * - 0x00: Power on, reset, or bus device reset occurred
247+ * - 0x01: Power on occurred
248+ * - 0x02: SCSI bus reset occurred
249+ * - 0x03: Bus device reset function occurred
250+ * - 0x04: Device internal reset
251+ * - 0x05: Transceiver mode changed to single-ended
252+ * - 0x06: Transceiver mode changed to LVD
253+ * - 0x07: I_T nexus loss occurred
254+ */
255+ const val RESET_OCCURRED = 0x29
256+
257+ /* *
258+ * Unit attention condition additional sense code for command queue clear conditions.
259+ * It should be safe to handle these conditions with a retry.
260+ *
261+ * ASCQs indicate:
262+ * - 0x00: Commands cleared by another initiator
263+ * - 0x01: Commands cleared by power loss notification
264+ * - 0x02: Commands cleared by device server
265+ * - 0x03: Some commands cleaered by queuing layer event
266+ */
267+ const val COMMANDS_CLEARED = 0x2F
232268 }
233269}
0 commit comments