From edward@edcom.com  Mon Apr 10 00:45:55 1995
Received: from edcom.com (edcom.com [140.174.173.185])
          by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id AAA00609
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 10 Apr 1995 00:45:54 -0700
Received: (from edward@localhost) by edcom.com (8.6.11/8.6.9) id AAA01711; Mon, 10 Apr 1995 00:45:50 -0700
Message-Id: <199504100745.AAA01711@edcom.com>
Date: Mon, 10 Apr 1995 00:45:50 -0700
From: edward@edcom.com
Reply-To: edward@edcom.com
To: FreeBSD-gnats-submit@freebsd.org
Cc: edward@edcom.com
Subject: SCSI tape short-read failure
X-Send-Pr-Version: 3.2

>Number:         331
>Category:       kern
>Synopsis:       a read that returns short on a SCSI tape fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 10 00:50:00 1995
>Closed-Date:    Tue Apr 11 12:09:47 PDT 1995
>Last-Modified:
>Originator:     Edward Wang
>Release:        FreeBSD 2.1.0-Development i386
>Organization:
feh!
>Environment:

	2.0-950322-SNAP

>Description:

	On a SCSI tape (and really other devices with similar
	characteristics), a read of a record smaller than
	the request size always fails.

>How-To-Repeat:

	find a SCSI tape drive
	put a tape in
	do
		dd if=/dev/zero of=/dev/rst0 bs=1b count=1
		dd if=/dev/rst0 of=/dev/null bs=1k count=1
	the read fails when it should return 512 bytes

>Fix:
	
*** scsi_base.c.dist	Tue Mar 21 03:21:01 1995
--- scsi_base.c	Sun Apr  9 22:56:52 1995
***************
*** 593,604 ****
  				xs->flags &= ~ITSDONE;
  				goto retry;
  			}
  		}
- 		retval = EIO;	/* Too many retries */
  
  		if (bp) {
  			bp->b_error = 0;
- 			bp->b_resid = 0;
  			if (retval) {
  				bp->b_flags |= B_ERROR;
  				bp->b_error = retval;
--- 593,603 ----
  				xs->flags &= ~ITSDONE;
  				goto retry;
  			}
+ 			retval = EIO;	/* Too many retries */
  		}
  
  		if (bp) {
  			bp->b_error = 0;
  			if (retval) {
  				bp->b_flags |= B_ERROR;
  				bp->b_error = retval;


The first change (position of retval = EIO) is the bug.
The second change is to return the correct b_resid.
The second problem seems to be in the 1.1.5.1 code as well.
It's less used so possibly nobody noticed.  I can't be sure
it doesn't affect something else -- something that doesn't
set b_resid correctly and relies on this to clear it.
However, I'm running this on a machine with SCSI disks and tapes.
They seem to work.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ache 
State-Changed-When: Tue Apr 11 12:09:47 PDT 1995 
State-Changed-Why:  
Fix applied. 
>Unformatted:



