Skip to content

Commit 769a4af

Browse files
committed
scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset
jira LE-2289 Rebuild_History Non-Buildable kernel-4.18.0-553.36.1.el8_10 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 f76c508 commit 769a4af

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
@@ -3504,6 +3504,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
35043504
int i, cmd_nr, cmd_type, bt;
35053505
int retval = 0;
35063506
unsigned int blk;
3507+
bool cmd_mtiocget;
35073508
struct scsi_tape *STp = file->private_data;
35083509
struct st_modedef *STm;
35093510
struct st_partstat *STps;
@@ -3618,6 +3619,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
36183619
*/
36193620
if (mtc.mt_op != MTREW &&
36203621
mtc.mt_op != MTOFFL &&
3622+
mtc.mt_op != MTLOAD &&
36213623
mtc.mt_op != MTRETEN &&
36223624
mtc.mt_op != MTERASE &&
36233625
mtc.mt_op != MTSEEK &&
@@ -3731,17 +3733,28 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
37313733
goto out;
37323734
}
37333735

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

3744-
if (cmd_type == _IOC_TYPE(MTIOCGET) && cmd_nr == _IOC_NR(MTIOCGET)) {
3757+
if (cmd_mtiocget) {
37453758
struct mtget mt_status;
37463759

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

0 commit comments

Comments
 (0)