From: Laurence Oberman <loberman@redhat.com>
To: linux-scsi@vger.kernel.org
Cc: jmeneghi@redhat.com, emilne@redhat.com, bgurney@redhat.com
Subject: [PATCH 0/2] scsi: st: Fix drive settings and position after reset recovery with MTLOAD/MTRETEN
Date: Sun, 27 Sep 2026 09:10:17 -0400 [thread overview]
Message-ID: <20260927131019.4188777-1-loberman@redhat.com> (raw)
After a device reset st blocks tape access until one of MTREW, MTOFFL,
MTLOAD, MTRETEN, MTERASE, MTSEEK or MTEOM clears the reset condition.
Testing the reset handling on scsi_debug and on IBM LTO drives found two
problems when the condition is cleared with MTLOAD or MTRETEN.
1. Changed block size and density are silently lost
A reset returns the drive's block size and density to their defaults.
Commit 7081dc75df79 ("scsi: st: Restore some drive settings after
reset") re-applies the values set by the user, but only for MTREW,
MTSEEK and MTEOM. Because check_tape() reads the drive's block size
with MODE SENSE on every open, the driver follows the drive back to
its default after the reset. An application that set fixed-block
mode with MTSETBLK and recovers with MTLOAD or MTRETEN keeps writing
without any error, but in variable-length blocks.
Patch 1 restores the changed settings for MTLOAD and MTRETEN as well.
Both may make the drive report a new medium, and the new session
started by check_tape() clears the "changed" flags and applies the
mode defaults. The values are therefore saved before the operation
and re-applied after check_tape() has run. scsi_debug reports a new
medium after MTRETEN and MTLOAD; the IBM drives do not. The series
was tested against both behaviours.
2. MTIOCGET reports file/block -1 at BOT after reset + MTLOAD
Commit 0b120edb37dc ("scsi: st: Add MTIOCGET and MTLOAD to ioctls
allowed after device reset") allows MTLOAD because the tape location
is known after it, but the position is not recorded:
reset_state() sets -1/-1, and do_load_unload() leaves it there unless
check_tape() starts a new session. With drives that do not report a
new medium for an already loaded cartridge (IBM LTO), MTIOCGET keeps
reporting -1/-1 and no BOT.
Patch 2 records file/block 0 after a successful load when the current
partition is 0.
MTOFFL is deliberately not changed: the medium is unloaded, and a
different one may be loaded next, for which the mode defaults should
apply.
Immediate mode: with MT_ST_NOWAIT, MTRETEN returns before the
retension completes, so patch 1 does not restore the settings there
rather than waiting for the drive.
Testing (v7.3-rc2, scsi_debug and IBM LTO drives on FC):
R03.load R04.load R04.retension R04.offline
(pos. after (MTSETBLK (MTSETBLK (MTSETBLK
reset+LOAD) after LOAD) after RETEN) after OFFL)
unpatched:
scsi_debug ok (0:0) discarded discarded discarded
IBM ULTRIUM-TD5 (LTO-5) -1:-1 discarded discarded discarded
IBM ULT3580-TDA -1:-1 discarded discarded discarded
patched:
scsi_debug (2 hosts) ok restored restored discarded (*)
IBM ULTRIUM-TD5 (LTO-5) ok restored restored discarded (*)
IBM ULT3580-TDA ok restored restored discarded (*)
(*) unchanged by design, see above.
For the position test, "ok" on patched kernels means that MTIOCPOS
returns 0 and the first block read without repositioning is block 0 of
file 0; it is not based on MTIOCGET alone. The restore after
MTREW/MTSEEK/MTEOM from 7081dc75df79 is unaffected on all devices.
Every test ends with a byte-exact read-back of the whole tape.
The tests are part of a tape validation harness (reset detection, the
blocked-operation matrix, recovery operations, interrupted I/O, SCSI EH
via scsi_debug error injection):
https://gitlab.com/loberman/tapetest (developed with AI assistance)
Laurence Oberman (2):
scsi: st: Restore changed drive settings after reset also for MTLOAD and MTRETEN
scsi: st: Record the tape position after a successful MTLOAD
drivers/scsi/st.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
next 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 Laurence Oberman [this message]
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 ` [PATCH 2/2] scsi: st: Record the tape position after a successful MTLOAD Laurence Oberman
2026-09-27 13:23 ` 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-1-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