Skip to content

Commit ca363c0

Browse files
kmakisaragregkh
authored andcommitted
scsi: st: Don't set pos_unknown just after device recognition
commit 98b3788 upstream. Commit 9604eea ("scsi: st: Add third party poweron reset handling") in v6.6 added new code to handle the Power On/Reset Unit Attention (POR UA) sense data. This was in addition to the existing method. When this Unit Attention is received, the driver blocks attempts to read, write and some other operations because the reset may have rewinded the tape. Because of the added code, also the initial POR UA resulted in blocking operations, including those that are used to set the driver options after the device is recognized. Also, reading and writing are refused, whereas they succeeded before this commit. Add code to not set pos_unknown to block operations if the POR UA is received from the first test_ready() call after the st device has been created. This restores the behavior before v6.6. Signed-off-by: Kai Mäkisara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 9604eea ("scsi: st: Add third party poweron reset handling") CC: [email protected] Closes: https://lore.kernel.org/linux-scsi/[email protected]/ Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eb1a24e commit ca363c0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/scsi/st.c

+6
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,11 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
10301030
retval = new_session ? CHKRES_NEW_SESSION : CHKRES_READY;
10311031
break;
10321032
}
1033+
if (STp->first_tur) {
1034+
/* Don't set pos_unknown right after device recognition */
1035+
STp->pos_unknown = 0;
1036+
STp->first_tur = 0;
1037+
}
10331038

10341039
if (SRpnt != NULL)
10351040
st_release_request(SRpnt);
@@ -4328,6 +4333,7 @@ static int st_probe(struct device *dev)
43284333
blk_queue_rq_timeout(tpnt->device->request_queue, ST_TIMEOUT);
43294334
tpnt->long_timeout = ST_LONG_TIMEOUT;
43304335
tpnt->try_dio = try_direct_io;
4336+
tpnt->first_tur = 1;
43314337

43324338
for (i = 0; i < ST_NBR_MODES; i++) {
43334339
STm = &(tpnt->modes[i]);

drivers/scsi/st.h

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ struct scsi_tape {
170170
unsigned char rew_at_close; /* rewind necessary at close */
171171
unsigned char inited;
172172
unsigned char cleaning_req; /* cleaning requested? */
173+
unsigned char first_tur; /* first TEST UNIT READY */
173174
int block_size;
174175
int min_block;
175176
int max_block;

0 commit comments

Comments
 (0)