Skip to content

Commit d362be9

Browse files
committed
scsi: st: Skip buffer flush for information ioctls
JIRA: https://issues.redhat.com/browse/RHEL-115965 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git With commit 9604eea ("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> (cherry picked from commit d27418a) Signed-off-by: John Meneghini <jmeneghi@redhat.com>
1 parent b52564e commit d362be9

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

drivers/scsi/st.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,30 +3542,34 @@ static long st_common_ioctl(struct scsi_tape *STp, struct st_modedef *STm,
35423542
goto out;
35433543
}
35443544

3545-
if ((i = flush_buffer(STp, 0)) < 0) {
3546-
retval = i;
3547-
goto out;
3548-
} else { /* flush_buffer succeeds */
3549-
if (STp->can_partitions) {
3550-
i = switch_partition(STp);
3551-
if (i < 0) {
3552-
retval = i;
3553-
goto out;
3554-
}
3555-
}
3556-
}
3557-
mutex_unlock(&STp->lock);
3558-
35593545
switch (cmd_in) {
3546+
case SCSI_IOCTL_GET_IDLUN:
3547+
case SCSI_IOCTL_GET_BUS_NUMBER:
3548+
case SCSI_IOCTL_GET_PCI:
3549+
break;
35603550
case SG_IO:
35613551
case SCSI_IOCTL_SEND_COMMAND:
35623552
case CDROM_SEND_PACKET:
3563-
if (!capable(CAP_SYS_RAWIO))
3564-
return -EPERM;
3565-
break;
3553+
if (!capable(CAP_SYS_RAWIO)) {
3554+
retval = -EPERM;
3555+
goto out;
3556+
}
3557+
fallthrough;
35663558
default:
3567-
break;
3559+
if ((i = flush_buffer(STp, 0)) < 0) {
3560+
retval = i;
3561+
goto out;
3562+
} else { /* flush_buffer succeeds */
3563+
if (STp->can_partitions) {
3564+
i = switch_partition(STp);
3565+
if (i < 0) {
3566+
retval = i;
3567+
goto out;
3568+
}
3569+
}
3570+
}
35683571
}
3572+
mutex_unlock(&STp->lock);
35693573

35703574
retval = scsi_ioctl(STp->device, file->f_mode & FMODE_WRITE,
35713575
cmd_in, (void __user *)arg);

0 commit comments

Comments
 (0)