Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Jun 1995 02:10:01 -0700
From:      mpp@legarto.minn.net
To:        freebsd-bugs
Subject:   kern/572: Booting w/scsi tape in drive causes first use to fail
Message-ID:  <199506280910.CAA29844@freefall.cdrom.com>
In-Reply-To: Your message of Wed, 28 Jun 1995 04:02:28 -0500 <199506280902.EAA01269@mpp.com>

next in thread | previous in thread | raw e-mail | index | archive | help

>Number:         572
>Category:       kern
>Synopsis:       Booting w/scsi tape in drive causes first use to fail
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 28 02:10:00 1995
>Originator:     Mike Pritchard
>Organization:
>Release:        FreeBSD 2.0.5-BUILT-19950624 i386
>Environment:

Freebsd-current, Archive Viper 2150S SCSI tape drive

>Description:

Booting with a tape in a SCSI tape drive will cause the first
use of the tape to fail with the following message:

st0: bad request, must be between 0 and 0.

At boot time, scsi_mode_sense() is called to obtain information
about the drive.  However, anytime this routine is called,
the SDEV_MEDIA_LOADED flag is set.  This causes the scsi_rd_blk_lim()
routine to not query the drive to determine the block limits
for the device when it is called by st_mount, thus leaving the 
blkmin/max values set to zero.

It looks like the SDEV_MEDIA_LOADED flag has been overloaded
in order to help support the ST_Q_SNS_HLP quirk (needs help
getting a mode sense from a freshly loaded drive).  I also
don't see how these drives ever worked in the first place,
since the quirk code would cause the MEDIA_LOADED flag to be set 
before st_rd_blk_lim() was ever called, and the blkmin/max sizes
would never be set, thus the drive would always return the
"must be between 0 and 0" error.

>How-To-Repeat:

Reboot with a tape in a SCSI tape drive.  The first time you attempt
to access the tape (e.g. tar cvf /dev/rst0 ...) will fail with
the message:

st0: bad request, must be between 0 and 0.

>Fix:
	
The following fix changes the code that supports the ST_S_SNS_HLP
quirk to use a new flag, instead of overloading the SDEV_MEDIA_LOADED
flag.  St_mode_sense() no longer sets SDEV_MEDIA_LOADED, and leaves
that job to st_mount_tape() & friends instead.  This causes 
SDEV_MEDIA_LOADED to track ST_MOUNT, just like it does everywhere 
else in the driver.

St_mode_sense() now sets ST_SENSE_READ when it reads good sense 
information.  The quirk code checks this flag instead of the
MEDIA_LOADED flag.  

This all works fine on my Archive 2150S tape drive, but someone
who has access to a drive with the mode sense quirk should
test this out.  It looks like the Archive Viper 2525 is one
of these drives.  It probably wouldn't hurt to try it out on
something a little more modern, like a DAT drive.


*** orig/st.c	Wed Jun 21 17:09:04 1995
--- st.c	Wed Jun 28 03:58:51 1995
***************
*** 278,283 ****
--- 278,284 ----
  #define	ST_BLANK_READ	0x800	/* BLANK CHECK encountered already */
  #define	ST_2FM_AT_EOD	0x1000	/* write 2 file marks at EOD */
  #define	ST_MOUNTED	0x2000	/* Device is presently mounted */
+ #define	ST_SENSE_READ	0x4000	/* mode sense read from drive */
  
  #define	ST_PER_ACTION	(ST_AT_FILEMARK | ST_EIO_PENDING | ST_BLANK_READ)
  #define	ST_PER_MOUNT	(ST_INFO_VALID | ST_BLOCK_SET | ST_WRITTEN | \
***************
*** 724,730 ****
  	scsi_prevent(sc_link, PR_PREVENT, 0);	/* who cares if it fails? */
  	st->flags &= ~ST_NEW_MOUNT;
  	st->flags |= ST_MOUNTED;
! 	sc_link->flags |= SDEV_MEDIA_LOADED;	/* move earlier? */
  
  	return 0;
  }
--- 725,731 ----
  	scsi_prevent(sc_link, PR_PREVENT, 0);	/* who cares if it fails? */
  	st->flags &= ~ST_NEW_MOUNT;
  	st->flags |= ST_MOUNTED;
! 	sc_link->flags |= SDEV_MEDIA_LOADED;
  
  	return 0;
  }
***************
*** 1017,1023 ****
  		st->buf_queue = bp->b_actf;
  
  		/*
! 		 * if the device has been unmounted byt the user
  		 * then throw away all requests until done
  		 */
  		if ((!(st->flags & ST_MOUNTED))
--- 1018,1024 ----
  		st->buf_queue = bp->b_actf;
  
  		/*
! 		 * if the device has been unmounted by the user
  		 * then throw away all requests until done
  		 */
  		if ((!(st->flags & ST_MOUNTED))
***************
*** 1427,1432 ****
--- 1428,1434 ----
  	struct scsi_link *sc_link = SCSI_LINK(&st_switch, unit);
  	struct scsi_data *st = sc_link->sd;
  
+ 	st->flags &= ~ST_SENSE_READ;
  	/*
  	 * Check if we need to use a default page..
  	 */
***************
*** 1481,1487 ****
  	if (page) {
  		bcopy(&dat.page, page, pagelen);
  	}
! 	sc_link->flags |= SDEV_MEDIA_LOADED;
  	return 0;
  }
  
--- 1483,1489 ----
  	if (page) {
  		bcopy(&dat.page, page, pagelen);
  	}
! 	st->flags |= ST_SENSE_READ;
  	return 0;
  }
  
***************
*** 1938,1944 ****
  			 	 * information.
  			 	 */
  				if ((st->quirks & ST_Q_SNS_HLP) &&
! 			    	!(sc_link->flags & SDEV_MEDIA_LOADED)) {
  					st->blksiz -= 512;
  				}
  			}
--- 1940,1946 ----
  			 	 * information.
  			 	 */
  				if ((st->quirks & ST_Q_SNS_HLP) &&
! 				    !(st->flags & ST_SENSE_READ)) {
  					st->blksiz -= 512;
  				}
  			}
***************
*** 1994,2000 ****
  		 * MODE SENSE information.
  		 */
  		if ((st->quirks & ST_Q_SNS_HLP) &&
! 		    !(sc_link->flags & SDEV_MEDIA_LOADED)) {
  			/* still starting */
  			st->blksiz -= 512;
  		} else if (!(st->flags & (ST_2FM_AT_EOD | ST_BLANK_READ))) {
--- 1996,2002 ----
  		 * MODE SENSE information.
  		 */
  		if ((st->quirks & ST_Q_SNS_HLP) &&
! 		    !(st->flags & ST_SENSE_READ)) {
  			/* still starting */
  			st->blksiz -= 512;
  		} else if (!(st->flags & (ST_2FM_AT_EOD | ST_BLANK_READ))) {
>Audit-Trail:
>Unformatted:





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199506280910.CAA29844>