From: David Jeffery <djeffery@redhat.com>
To: "Kai Mäkisara" <Kai.Makisara@kolumbus.fi>, linux-scsi@vger.kernel.org
Cc: David Jeffery <djeffery@redhat.com>,
Laurence Oberman <loberman@redhat.com>
Subject: [PATCH 2/2] st: skip buffer flush for information ioctls
Date: Tue, 4 Nov 2025 10:46:23 -0500 [thread overview]
Message-ID: <20251104154709.6436-2-djeffery@redhat.com> (raw)
In-Reply-To: <20251104154709.6436-1-djeffery@redhat.com>
With commit 9604eea5bd3a ("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>
---
drivers/scsi/st.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 87f0e303fdd6..d4d2c8e3f912 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3542,30 +3542,34 @@ static long st_common_ioctl(struct scsi_tape *STp, struct st_modedef *STm,
goto out;
}
- 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);
-
switch (cmd_in) {
+ case SCSI_IOCTL_GET_IDLUN:
+ case SCSI_IOCTL_GET_BUS_NUMBER:
+ case SCSI_IOCTL_GET_PCI:
+ break;
case SG_IO:
case SCSI_IOCTL_SEND_COMMAND:
case CDROM_SEND_PACKET:
- if (!capable(CAP_SYS_RAWIO))
- return -EPERM;
- break;
+ if (!capable(CAP_SYS_RAWIO)) {
+ retval = -EPERM;
+ goto out;
+ }
+ fallthrough;
default:
- break;
+ 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);
retval = scsi_ioctl(STp->device, file->f_mode & FMODE_WRITE,
cmd_in, (void __user *)arg);
--
2.51.0
next prev parent reply other threads:[~2025-11-04 15:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 15:46 [PATCH 1/2] st: separate st-unique ioctl handling from scsi common ioctl handling David Jeffery
2025-11-04 15:46 ` David Jeffery [this message]
2025-11-05 14:40 ` [PATCH 2/2] st: skip buffer flush for information ioctls "Kai Mäkisara (Kolumbus)"
2025-11-05 17:34 ` John Meneghini
2025-11-08 17:22 ` Martin K. Petersen
2025-11-05 14:38 ` [PATCH 1/2] st: separate st-unique ioctl handling from scsi common ioctl handling "Kai Mäkisara (Kolumbus)"
2025-11-05 14:43 ` Laurence Oberman
2025-11-05 15:56 ` John Meneghini
2025-11-08 17:22 ` Martin K. Petersen
2025-11-13 2:46 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251104154709.6436-2-djeffery@redhat.com \
--to=djeffery@redhat.com \
--cc=Kai.Makisara@kolumbus.fi \
--cc=linux-scsi@vger.kernel.org \
--cc=loberman@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox