Subject: Long rewind time on atapi tape drive
To: None <current-users@netbsd.org>
From: Paul Goyette <paul@whooppee.com>
List: current-users
Date: 10/09/2007 08:57:23
I've got a Travan-20 tape drive that frequently takes longer than one 
minute (sometimes as much as two full minutes) to rewind the tape, 
resulting in a lost interrupt:

 	viaide0:0:0: lost interrupt
 	        type: atapi tc_bcount: 0 tc_skip: 0

If this is done as part of a "mt rewoff" (rewind and offline) command, 
the offline part never happens and the tape is not unloaded.

I've narrowed this down to the following code in sys/dev/scsipi/st.c

/*
  *  Rewind the device
  */
static int
st_rewind(struct st_softc *st, u_int immediate, int flags)
{
 	struct scsi_rewind cmd;
 	int error;
 	int nmarks;

 	...

 	/*
 	 * ATAPI tapes always need immediate to be set
 	 */
 	if (scsipi_periph_bustype(st->sc_periph) == SCSIPI_BUSTYPE_ATAPI)
 		immediate = SR_IMMED;

 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode = REWIND;
 	cmd.byte2 = immediate;

 	error = scsipi_command(st->sc_periph, (void *)&cmd, sizeof(cmd), 0, 0,
 	    ST_RETRIES, immediate ? ST_CTL_TIME: ST_SPC_TIME, NULL, flags);
 	...

ST_SPC_TIME is a fairly long (4 hours!) delay which might be rather 
excessive to wait, but ST_CTL_TIME is only 30 seconds which is 
definitely not enough time for the tape to rewind.

Is this really the right thing to do?  If so, is it unreasonable to 
increase the value of ST_CTL_TIME to something closer to the typical 
reality of two minutes?

----------------------------------------------------------------------
|   Paul Goyette   | PGP DSS Key fingerprint: |  E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 |  paul@whooppee.com   |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette@juniper.net |
----------------------------------------------------------------------