Skip to content

Commit 602279b

Browse files
committed
scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset
jira LE-2742 Rebuild_History Non-Buildable kernel-5.14.0-503.33.1.el9_5 commit-author Kai Mäkisara <[email protected]> commit 0b120ed Most drives rewind the tape when the device is reset. Reading and writing are not allowed until something is done to make the tape position match the user's expectation (e.g., rewind the tape). Add MTIOCGET and MTLOAD to operations allowed after reset. MTIOCGET is modified to not touch the tape if pos_unknown is non-zero. The tape location is known after MTLOAD. Signed-off-by: Kai Mäkisara <[email protected]> Link: https://bugzilla.kernel.org/show_bug.cgi?id=219419#c14 Link: https://lore.kernel.org/r/[email protected] Reviewed-by: John Meneghini <[email protected]> Tested-by: John Meneghini <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> (cherry picked from commit 0b120ed) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 6cd2059 commit 602279b

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

drivers/scsi/st.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,6 +3506,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
35063506
int i, cmd_nr, cmd_type, bt;
35073507
int retval = 0;
35083508
unsigned int blk;
3509+
bool cmd_mtiocget;
35093510
struct scsi_tape *STp = file->private_data;
35103511
struct st_modedef *STm;
35113512
struct st_partstat *STps;
@@ -3619,6 +3620,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
36193620
*/
36203621
if (mtc.mt_op != MTREW &&
36213622
mtc.mt_op != MTOFFL &&
3623+
mtc.mt_op != MTLOAD &&
36223624
mtc.mt_op != MTRETEN &&
36233625
mtc.mt_op != MTERASE &&
36243626
mtc.mt_op != MTSEEK &&
@@ -3732,17 +3734,28 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
37323734
goto out;
37333735
}
37343736

3737+
cmd_mtiocget = cmd_type == _IOC_TYPE(MTIOCGET) && cmd_nr == _IOC_NR(MTIOCGET);
3738+
37353739
if ((i = flush_buffer(STp, 0)) < 0) {
3736-
retval = i;
3737-
goto out;
3738-
}
3739-
if (STp->can_partitions &&
3740-
(i = switch_partition(STp)) < 0) {
3741-
retval = i;
3742-
goto out;
3740+
if (cmd_mtiocget && STp->pos_unknown) {
3741+
/* flush fails -> modify status accordingly */
3742+
reset_state(STp);
3743+
STp->pos_unknown = 1;
3744+
} else { /* return error */
3745+
retval = i;
3746+
goto out;
3747+
}
3748+
} else { /* flush_buffer succeeds */
3749+
if (STp->can_partitions) {
3750+
i = switch_partition(STp);
3751+
if (i < 0) {
3752+
retval = i;
3753+
goto out;
3754+
}
3755+
}
37433756
}
37443757

3745-
if (cmd_type == _IOC_TYPE(MTIOCGET) && cmd_nr == _IOC_NR(MTIOCGET)) {
3758+
if (cmd_mtiocget) {
37463759
struct mtget mt_status;
37473760

37483761
if (_IOC_SIZE(cmd_in) != sizeof(struct mtget)) {

0 commit comments

Comments
 (0)