Subject: CVS commit: src/sys/dev/scsipi
To: None <source-changes@NetBSD.org>
From: Manuel Bouyer <bouyer@netbsd.org>
List: source-changes
Date: 08/27/2004 20:37:29
Module Name:	src
Committed By:	bouyer
Date:		Fri Aug 27 20:37:29 UTC 2004

Modified Files:
	src/sys/dev/scsipi: atapi_base.c cd.c cdvar.h scsi_base.c scsipi_base.c
	    sd.c sdvar.h ss.c ss_mustek.c ss_scanjet.c ssvar.h st.c stvar.h

Log Message:
Improve handling of memory shortage, to fix problems like:
sd3(mpt0:0:1:0): unable to allocate scsipi_xfer
sd3: not queued, error 12
Havard Eidnes's analysis of this problem is that the scsipi_xfer pool is
competing for resources with other pools, including the the inode and vnode
pools which can grow quite large.

*_scsipi_cmd(): don't biodone the buffer if scsipi_make_xs() fails, let the
   caller deal with the problem
start function of block devices drivers: dequeue the buffer after the
   scsipi_command() call. If scsipi_command() fails with ENOMEM don't dequeue
   the buffer, and schedule a callout to call the start function after
   some delay.
scsipi_init(): prime the scsipi_xfer_pool with one page. This ensure that
   there is always some scsipi_xfer to play with. If scsipi_command() fails
   because of pool_get(), we're sure there will be resources available later,
   when the pending commands have completed.

Reviewed by Jason Thorpe and Havard Eidnes.
Todo: remove the "unable to allocate scsipi_xfer" and "not queued, error %d"
printfs, but I choose to keep them for now, to help make sure the code does
what it should.


To generate a diff of this commit:
cvs rdiff -r1.20 -r1.21 src/sys/dev/scsipi/atapi_base.c \
    src/sys/dev/scsipi/cdvar.h
cvs rdiff -r1.202 -r1.203 src/sys/dev/scsipi/cd.c
cvs rdiff -r1.79 -r1.80 src/sys/dev/scsipi/scsi_base.c
cvs rdiff -r1.109 -r1.110 src/sys/dev/scsipi/scsipi_base.c
cvs rdiff -r1.220 -r1.221 src/sys/dev/scsipi/sd.c
cvs rdiff -r1.21 -r1.22 src/sys/dev/scsipi/sdvar.h
cvs rdiff -r1.52 -r1.53 src/sys/dev/scsipi/ss.c
cvs rdiff -r1.19 -r1.20 src/sys/dev/scsipi/ss_mustek.c
cvs rdiff -r1.30 -r1.31 src/sys/dev/scsipi/ss_scanjet.c
cvs rdiff -r1.11 -r1.12 src/sys/dev/scsipi/ssvar.h
cvs rdiff -r1.164 -r1.165 src/sys/dev/scsipi/st.c
cvs rdiff -r1.8 -r1.9 src/sys/dev/scsipi/stvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.