diff mbox series

[v2,3/3] scsi: st: New session only when Unit Attention for new tape

Message ID 20241106095723.63254-4-Kai.Makisara@kolumbus.fi (mailing list archive)
State Superseded
Headers show
Series scsi: st: Device reset patches | expand

Commit Message

Kai Mäkisara Nov. 6, 2024, 9:57 a.m. UTC
Currently the code starts new tape session when any Unit Attention
(UA) is seen when opening the device. This leads to incorrectly
clearing pos_unknown when the UA is for reset. Set new session only
when the UA is for a new tape.
---
 drivers/scsi/st.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index c9038284bc89..e8ef27d7ef61 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -991,7 +991,10 @@  static int test_ready(struct scsi_tape *STp, int do_wait)
 			scode = cmdstatp->sense_hdr.sense_key;
 
 			if (scode == UNIT_ATTENTION) { /* New media? */
-				new_session = 1;
+				if (cmdstatp->sense_hdr.asc == 0x28) { /* New media */
+					new_session = 1;
+					DEBC_printk(STp, "New tape session.");
+				}
 				if (attentions < MAX_ATTENTIONS) {
 					attentions++;
 					continue;