1
0

scsi: st: Skip buffer flush for information ioctls

With commit 9604eea5bd ("scsi: st: Add third party poweron reset
handling") some customer tape applications fail from being unable to
complete ioctls to verify ID information for the device when there has
been any type of reset event to their tape devices.

The st driver currently will fail all standard SCSI ioctls if a call to
flush_buffer() fails in st_ioctl(). This causes ioctls which otherwise
have no effect on tape state to succeed or fail based on events
unrelated to the requested ioctl.

This makes SCSI information ioctls unreliable after a reset even if no
buffering is in use. With a reset setting the pos_unknown field,
flush_buffer() will report failure and fail all ioctls. So any
application expecting to use ioctls to check the identify the device
will be unable to do so in such a state.

For SCSI information ioctls, avoid the need for a buffer flush and allow
the ioctls to execute regardless of buffer state.

Signed-off-by: David Jeffery <djeffery@redhat.com>
Tested-by: Laurence Oberman <loberman@redhat.com>
Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Tested-by: John Meneghini <jmeneghi@redhat.com>
Link: https://patch.msgid.link/20251104154709.6436-2-djeffery@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
David Jeffery
2025-11-04 10:46:23 -05:00
committed by Martin K. Petersen
parent b37d70c0df
commit d27418aaf8

View File

@@ -3542,31 +3542,35 @@ static long st_common_ioctl(struct scsi_tape *STp, struct st_modedef *STm,
goto out; goto out;
} }
if ((i = flush_buffer(STp, 0)) < 0) { switch (cmd_in) {
retval = i; case SCSI_IOCTL_GET_IDLUN:
goto out; case SCSI_IOCTL_GET_BUS_NUMBER:
} else { /* flush_buffer succeeds */ case SCSI_IOCTL_GET_PCI:
if (STp->can_partitions) { break;
i = switch_partition(STp); case SG_IO:
if (i < 0) { case SCSI_IOCTL_SEND_COMMAND:
retval = i; case CDROM_SEND_PACKET:
goto out; if (!capable(CAP_SYS_RAWIO)) {
retval = -EPERM;
goto out;
}
fallthrough;
default:
if ((i = flush_buffer(STp, 0)) < 0) {
retval = i;
goto out;
} else { /* flush_buffer succeeds */
if (STp->can_partitions) {
i = switch_partition(STp);
if (i < 0) {
retval = i;
goto out;
}
} }
} }
} }
mutex_unlock(&STp->lock); mutex_unlock(&STp->lock);
switch (cmd_in) {
case SG_IO:
case SCSI_IOCTL_SEND_COMMAND:
case CDROM_SEND_PACKET:
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
break;
default:
break;
}
retval = scsi_ioctl(STp->device, file->f_mode & FMODE_WRITE, retval = scsi_ioctl(STp->device, file->f_mode & FMODE_WRITE,
cmd_in, (void __user *)arg); cmd_in, (void __user *)arg);
if (!retval && cmd_in == SCSI_IOCTL_STOP_UNIT) { if (!retval && cmd_in == SCSI_IOCTL_STOP_UNIT) {