Skip to content

Commit 3d882cc

Browse files
RafaARVmartinkpetersen
authored andcommitted
scsi: st: Fix input/output error on empty drive reset
A previous change was introduced to prevent data loss during a power-on reset when a tape is present inside the drive. This commit set the "pos_unknown" flag to true to avoid operations that could compromise data by performing actions from an untracked position. The relevant change is commit 9604eea ("scsi: st: Add third party poweron reset handling") As a consequence of this change, a new issue has surfaced: the driver now returns an "Input/output error" even for empty drives when the drive, host, or bus is reset. This issue stems from the "flush_buffer" function, which first checks whether the "pos_unknown" flag is set. If the flag is set, the user will encounter an "Input/output error" until the tape position is known again. This behavior differs from the previous implementation, where empty drives were not affected at system start up time, allowing tape software to send commands to the driver to retrieve the drive's status and other information. The current behavior prioritizes the "pos_unknown" flag over the "ST_NO_TAPE" status, leading to issues for software that detects drives during system startup. This software will receive an "Input/output error" until a tape is loaded and its position is known. To resolve this, the "ST_NO_TAPE" status should take priority when the drive is empty, allowing communication with the drive following a power-on reset. At the same time, the change should continue to protect data by maintaining the "pos_unknown" flag when the drive contains a tape and its position is unknown. Signed-off-by: Rafael Rocha <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 9604eea ("scsi: st: Add third party poweron reset handling") Acked-by: Kai Mäkisara <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent cff06a7 commit 3d882cc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/scsi/st.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,15 +834,16 @@ static int flush_buffer(struct scsi_tape *STp, int seek_next)
834834
int backspace, result;
835835
struct st_partstat *STps;
836836

837+
if (STp->ready != ST_READY)
838+
return 0;
839+
837840
/*
838841
* If there was a bus reset, block further access
839842
* to this device.
840843
*/
841844
if (STp->pos_unknown)
842845
return (-EIO);
843846

844-
if (STp->ready != ST_READY)
845-
return 0;
846847
STps = &(STp->ps[STp->partition]);
847848
if (STps->rw == ST_WRITING) /* Writing */
848849
return st_flush_write_buffer(STp);

0 commit comments

Comments
 (0)