From: Laurence Oberman <loberman@redhat.com>
To: "\"Kai Mäkisara (Kolumbus)\"" <kai.makisara@kolumbus.fi>
Cc: linux-scsi@vger.kernel.org,
"Martin K . Petersen" <mkp@kernel.org>,
"James E . J . Bottomley"
<James.Bottomley@HansenPartnership.com>,
John Meneghini <jmeneghi@redhat.com>,
emilne@redhat.com, bgurney@redhat.com
Subject: Re: [PATCH v2 2/2] scsi: st: Record the tape position after a successful MTLOAD
Date: Tue, 29 Sep 2026 09:30:52 -0400 [thread overview]
Message-ID: <6997757cf93d863719622971c11e997e78063927.camel@redhat.com> (raw)
In-Reply-To: <DACF75C2-73E1-4906-AAAA-A0C21CC0B859@kolumbus.fi>
On Tue, 2026-09-29 at 15:39 +0300, Kai Mäkisara (Kolumbus) wrote:
>
> > On 28. Sep 2026, at 16.25, Laurence Oberman <loberman@redhat.com>
> > wrote:
> >
> > 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, and reset
> > the
> > EOF state as MTREW does; otherwise a read after loading at EOD
> > fails
> > with EIO.
> >
> > 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 | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> > index 0a4263bef9cb..f4393a8e8fb1 100644
> > --- a/drivers/scsi/st.c
> > +++ b/drivers/scsi/st.c
> > @@ -2686,6 +2686,20 @@ 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 and the EOF state would
> > + * be left as before the load. Set them as MTREW does.
> > + */
>
> Should the following be done for all values of STp->partition?
> And the code should set STp->partition = STp->new_partition = 0
> to match the LOAD behaviour. (Usually
> STp->partition == STp-> new_partition
> and the partition would not be changed even if STp->partition
> is not correct. But if later the partition is changed to the wrong
> value,
> the change does not occur.)
>
> > + if (retval == CHKRES_READY && STp->partition == 0) {
> > + STps = &(STp->ps[0]);
> > + STps->drv_file = STps->drv_block = 0;
> > + STps->eof = ST_NOEOF;
> > + STps->at_sm = 0;
> > + STps->last_block_valid = 0;
> > + }
> > if (retval > 0)
> > retval = 0;
> > }
> > --
> > 2.55.0
> >
>
> Thanks, Kai
>
Hello Kai, thank you very much for the review. Let me look into
these points and make necessary changes and send a V3.
Regards
Laurence
next prev parent reply other threads:[~2026-09-29 13:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 13:25 [PATCH v2 0/2] scsi: st: Fix drive settings and position after reset recovery with MTLOAD/MTRETEN Laurence Oberman
2026-09-28 13:25 ` [PATCH v2 1/2] scsi: st: Restore changed drive settings after reset also for MTLOAD and MTRETEN Laurence Oberman
2026-09-29 14:15 ` "Kai Mäkisara (Kolumbus)"
2026-09-29 17:17 ` Laurence Oberman
2026-09-28 13:25 ` [PATCH v2 2/2] scsi: st: Record the tape position after a successful MTLOAD Laurence Oberman
2026-09-29 12:39 ` "Kai Mäkisara (Kolumbus)"
2026-09-29 13:30 ` Laurence Oberman [this message]
2026-09-29 17:18 ` Laurence Oberman
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=6997757cf93d863719622971c11e997e78063927.camel@redhat.com \
--to=loberman@redhat.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=bgurney@redhat.com \
--cc=emilne@redhat.com \
--cc=jmeneghi@redhat.com \
--cc=kai.makisara@kolumbus.fi \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@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