Subject: Re: kern/36690: KASSERT(delta > 0) in kern_physio
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: netbsd-bugs
Date: 10/01/2007 18:45:02
The following reply was made to PR kern/36690; it has been noted by GNATS.

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org, permezel@mac.com
Subject: Re: kern/36690: KASSERT(delta > 0) in kern_physio
Date: Mon, 1 Oct 2007 20:44:13 +0200

 --ew6BAiZeqk4r7MaW
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Sat, Sep 29, 2007 at 01:45:02PM +0000, Paul Ripke wrote:
 > The following reply was made to PR kern/36690; it has been noted by GNATS.
 > 
 > From: Paul Ripke <stix@stix.id.au>
 > To: NetBSD gnats-bugs <gnats-bugs@NetBSD.org>
 > Cc: 
 > Subject: Re: kern/36690: KASSERT(delta > 0) in kern_physio
 > Date: Sat, 29 Sep 2007 23:42:39 +1000
 > 
 >  This appears to be due to instances like the following:
 >  
 >  st0: 65536-byte tape record too big for 32768-byte user buffer
 >  st0(ahc0:0:6:0):  Check Condition on CDB: 0x08 00 00 80 00 00
 >      SENSE KEY:  No Additional Sense
 >                  Incorrect Length Indicator Set
 >     INFO FIELD:  -32768
 >       ASC/ASCQ:  No Additional Sense Information
 >  panic: kernel diagnostic assertion "delta > 0" failed: file "/l/netbsd/netbsd-4/src/sys/kern/kern_physio.c", line 441
 >  
 >  100% reproducible on head of netbsd-4 branch.
 
 Should be fixed in st.c 1.200. Can you please try the attached patch ?
 
 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --
 
 --ew6BAiZeqk4r7MaW
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=diff
 
 Index: st.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/scsipi/st.c,v
 retrieving revision 1.198
 retrieving revision 1.200
 diff -u -p -u -r1.198 -r1.200
 --- st.c	29 Jul 2007 12:50:23 -0000	1.198
 +++ st.c	1 Oct 2007 18:43:30 -0000	1.200
 @@ -1,4 +1,4 @@
 -/*	$NetBSD: st.c,v 1.198 2007/07/29 12:50:23 ad Exp $ */
 +/*	$NetBSD: st.c,v 1.200 2007/10/01 18:43:30 bouyer Exp $ */
  
  /*-
   * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
 @@ -57,7 +57,7 @@
   */
  
  #include <sys/cdefs.h>
 -__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.198 2007/07/29 12:50:23 ad Exp $");
 +__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.200 2007/10/01 18:43:30 bouyer Exp $");
  
  #include "opt_scsi.h"
  
 @@ -1219,6 +1219,7 @@ ststart(struct scsipi_periph *periph)
  					if (st_space(st, 0, SP_FILEMARKS, 0)) {
  						BUFQ_GET(st->buf_queue);
  						bp->b_error = EIO;
 +						bp->b_resid = bp->b_bcount;
  						biodone(bp);
  						continue;
  					}
 @@ -2234,8 +2235,16 @@ st_interpret_sense(struct scsipi_xfer *x
  				}
  			}
  		}
 -		if (bp)
 +		if (bp) {
  			bp->b_resid = info;
 +			/*
 +			 * buggy device ? A SDLT320 can report an info
 +			 * field of 0x3de8000 on a Media Error/Write Error
 +			 * for this CBD: 0x0a 00 00 80 00 00
 +			 */
 +			if (bp->b_resid > bp->b_bcount || bp->b_resid < 0)
 +				bp->b_resid = bp->b_bcount;
 +		}
  	}
  
  #ifndef SCSIPI_DEBUG
 
 --ew6BAiZeqk4r7MaW--