Skip to content

Commit dad1edf

Browse files
kmakisarajfvogel
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 <Kai.Makisara@kolumbus.fi> Link: https://lore.kernel.org/r/20241216113755.30415-1-Kai.Makisara@kolumbus.fi Fixes: 9604eea ("scsi: st: Add third party poweron reset handling") CC: stable@vger.kernel.org Closes: https://lore.kernel.org/linux-scsi/2201CF73-4795-4D3B-9A79-6EE5215CF58D@kolumbus.fi/ Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 4367fb2a0841431e829db37551ae2650f7d16fdd) Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
1 parent f67ce83 commit dad1edf

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/scsi/st.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,11 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
10271027
retval = new_session ? CHKRES_NEW_SESSION : CHKRES_READY;
10281028
break;
10291029
}
1030+
if (STp->first_tur) {
1031+
/* Don't set pos_unknown right after device recognition */
1032+
STp->pos_unknown = 0;
1033+
STp->first_tur = 0;
1034+
}
10301035

10311036
if (SRpnt != NULL)
10321037
st_release_request(SRpnt);
@@ -4325,6 +4330,7 @@ static int st_probe(struct device *dev)
43254330
blk_queue_rq_timeout(tpnt->device->request_queue, ST_TIMEOUT);
43264331
tpnt->long_timeout = ST_LONG_TIMEOUT;
43274332
tpnt->try_dio = try_direct_io;
4333+
tpnt->first_tur = 1;
43284334

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

drivers/scsi/st.h

Lines changed: 1 addition & 0 deletions
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)