From: Laurence Oberman <loberman@redhat.com>
To: linux-scsi@vger.kernel.org
Cc: jmeneghi@redhat.com, emilne@redhat.com, bgurney@redhat.com
Subject: [PATCH 2/2] scsi: st: Record the tape position after a successful MTLOAD
Date: Sun, 27 Sep 2026 09:10:19 -0400 [thread overview]
Message-ID: <20260927131019.4188777-3-loberman@redhat.com> (raw)
In-Reply-To: <20260927131019.4188777-1-loberman@redhat.com>
Commit 0b120edb37dc ("scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed
after device reset") allows MTLOAD to clear the reset condition because
the tape location is known after MTLOAD. But the driver does not record
it: reset_state() sets the file and block numbers to -1, and
do_load_unload() leaves them there. check_tape() sets them to 0 only for
a new session, which requires a new-medium unit attention. Drives that
do not report one when the medium was already loaded (seen with IBM LTO
drives) keep reporting file/block -1 in MTIOCGET and no BOT, although the
tape is at the beginning.
Set the file and block numbers to 0 after a successful load when the
current partition is 0, where LOAD positions the medium.
Fixes: 0b120edb37dc ("scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset")
Assisted-by: Claude sashiko
Signed-off-by: Laurence Oberman <loberman@redhat.com>
---
drivers/scsi/st.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 0a4263bef9cb..8889714122c7 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -2686,6 +2686,14 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
else {
STp->rew_at_close = STp->autorew_dev;
retval = check_tape(STp, filp);
+ /*
+ * LOAD leaves the medium at the beginning of partition
+ * 0. check_tape() records that only for a new session;
+ * without a new-medium unit attention (the medium was
+ * already loaded) the position would stay unknown.
+ */
+ if (retval == CHKRES_READY && STp->partition == 0)
+ STp->ps[0].drv_file = STp->ps[0].drv_block = 0;
if (retval > 0)
retval = 0;
}
--
2.55.0
next prev parent reply other threads:[~2026-09-27 13:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 13:10 [PATCH 0/2] scsi: st: Fix drive settings and position after reset recovery with MTLOAD/MTRETEN Laurence Oberman
2026-09-27 13:10 ` [PATCH 1/2] scsi: st: Restore changed drive settings after reset also for MTLOAD and MTRETEN Laurence Oberman
2026-09-27 13:10 ` Laurence Oberman [this message]
2026-09-27 13:23 ` [PATCH 2/2] scsi: st: Record the tape position after a successful MTLOAD sashiko-bot
2026-09-28 13:26 ` [PATCH 0/2] scsi: st: Fix drive settings and position after reset recovery with MTLOAD/MTRETEN "Kai Mäkisara (Kolumbus)"
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=20260927131019.4188777-3-loberman@redhat.com \
--to=loberman@redhat.com \
--cc=bgurney@redhat.com \
--cc=emilne@redhat.com \
--cc=jmeneghi@redhat.com \
--cc=linux-scsi@vger.kernel.org \
/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