Subject: Re: Long rewind time on atapi tape drive
To: Martin J. Laubach <mjl@NetBSD.org>
From: Paul Goyette <paul@whooppee.com>
List: current-users
Date: 10/10/2007 18:08:20
On Wed, 10 Oct 2007, Martin J. Laubach wrote:

> |  +	if (immediate)
> |  +		timeout = ST_CTL_TIME;
> |  +	else
> |  +		timeout = ST_SPC_TIME;
> |  +
> |  -	    ST_RETRIES, immediate ? ST_CTL_TIME: ST_SPC_TIME, NULL, flags);
> |  +	    ST_RETRIES, timeout, NULL, flags);
>
>  Er, am I just dense or doesn't that not change anything wrt
> behaviour?

It definitely does change things!  Here's a bit more context to see the 
real effect:

+ 	/* If requestor asked for immediate response, set a short timeout */
+ 	if (immediate)
+ 		timeout = ST_CTL_TIME;
+ 	else
+ 		timeout = ST_SPC_TIME;
+
 	/*
 	 * 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_RETRIES, timeout, NULL, flags);

The patch I've proposed moves selection of the timeout interval to a 
point before which the "ATAPI tapes always need immediate" stuff 
happens.  This results in timeout interval depending on the caller's 
specification of immediate, not the ATAPI requirement.

----------------------------------------------------------------------
|   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 |
----------------------------------------------------------------------