Subject: Re: Long rewind time on atapi tape drive
To: Paul Goyette <paul@whooppee.com>
From: Bill Stouder-Studenmund <wrstuden@netbsd.org>
List: current-users
Date: 10/10/2007 10:34:34
--vGgW1X5XWziG23Ko
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Oct 09, 2007 at 08:57:23AM -0700, Paul Goyette wrote:
> I've got a Travan-20 tape drive that frequently takes longer than one=20
> minute (sometimes as much as two full minutes) to rewind the tape,=20
> resulting in a lost interrupt:
>=20
> 	viaide0:0:0: lost interrupt
> 	        type: atapi tc_bcount: 0 tc_skip: 0
>=20
> If this is done as part of a "mt rewoff" (rewind and offline) command,=20
> the offline part never happens and the tape is not unloaded.
>=20
> I've narrowed this down to the following code in sys/dev/scsipi/st.c
>=20
> /*
>  *  Rewind the device
>  */
> static int
> st_rewind(struct st_softc *st, u_int immediate, int flags)
> {
> 	struct scsi_rewind cmd;
> 	int error;
> 	int nmarks;
>=20
> 	...
>=20
> 	/*
> 	 * ATAPI tapes always need immediate to be set
> 	 */
> 	if (scsipi_periph_bustype(st->sc_periph) =3D=3D SCSIPI_BUSTYPE_ATAPI)
> 		immediate =3D SR_IMMED;
>=20
> 	memset(&cmd, 0, sizeof(cmd));
> 	cmd.opcode =3D REWIND;
> 	cmd.byte2 =3D immediate;
>=20
> 	error =3D scsipi_command(st->sc_periph, (void *)&cmd, sizeof(cmd), 0,=20
> 	0,
> 	    ST_RETRIES, immediate ? ST_CTL_TIME: ST_SPC_TIME, NULL, flags);
> 	...
>=20
> ST_SPC_TIME is a fairly long (4 hours!) delay which might be rather=20
> excessive to wait, but ST_CTL_TIME is only 30 seconds which is=20
> definitely not enough time for the tape to rewind.
>=20
> Is this really the right thing to do?  If so, is it unreasonable to=20
> increase the value of ST_CTL_TIME to something closer to the typical=20
> reality of two minutes?

I think the thing to do is dig back and see where ST_CTL_TIME vs=20
ST_SPC_TIME came from. ST_CTL_TIME may make sense when immediate is set.

I expect though that the thing to do is figure out the timeout based on=20
what was passed in for immediate, _then_ have atapi set immediate.

I agree that the bus being atapi shouldn't mean we always do a 30 second=20
time out. I'm just not sure if there aren't times we will still actually=20
want that 30 second time out. Maybe there aren't but we should understand=
=20
that explicitly. :-)

Take care,

Bill

--vGgW1X5XWziG23Ko
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)

iD8DBQFHDQ0qWz+3JHUci9cRApS7AJ47/mKIOCWzPYuu8l0G+3jbGbSHQgCfWPX3
emOBvf2vzgSYAICAqx+dO88=
=jyxd
-----END PGP SIGNATURE-----

--vGgW1X5XWziG23Ko--