Go to file
scottr 10640f1bfc Fix a problem uncovered when we started to use the pool allocator to manage
scsipi_xfer structures.

When scsipi_execute_xs() calls the driver's scsi_cmd function, it assumes
that it can still dereference a pointer to the scsipi_xfer struct.  Since
scsipi_done() has already been called, which in turn has called
scsipi_free_xs(), the struct has already been returned to the pool!  In
other words, xs->flags has been compromised, but we are still testing it.

These changes resolve the problem by doing the following:

- In scsipi_execute_xs(), if the lower-level driver's scsi_cmd function
  returns SUCCESSFULLY_QUEUED and SCSI_NOSLEEP is set in xs->flags, set a
  new flag (SCSI_ASYNCREQ).  This indicates that scsipi_done() should free
  the scsipi_xfer struct.

  If the lower-level driver's scsi_cmd function returns SUCCESSFULLY_QUEUED
  but SCSI_NOSLEEP is not set, we wait (via tsleep()) for the request to
  complete, then fall through to the COMPLETE case.

  If the lower-level driver's scsi_cmd function returns COMPLETE, we now
  simply return any actual errors, or 0 if none occurred.  (Previously,
  we may have returned EJUSTRETURN, of which the sole effect was to
  avoid freeing the scsipi_xfer struct in our caller.  No code seems
  to depend on this behavior, however.)

- In scsipi_done(), only free the scsipi_xfer struct for async requests.
  The contents of the struct will otherwise remain valid until the
  function that initiated the transfer frees it.

With this change, responsibility for freeing the struct now lies in two
places, depending on the type of the request:

- For synchronous requests, the routine calling scsipi_execute_xs()
  must clean up.

- For asynchronous requests, scsipi_done() cleans up (as it always has).

[Note:  this change also corrects a problem with sddump():  scsipi_done()
was attempting to return a static scsipi_xfer struct to the pool!  Since
dumps are performed synchronously, we now handle this correctly.]

This solution was provided by Jason Thorpe, after I got him to look at
some related (but insufficient) attempts of my own.
1998-09-14 05:49:20 +00:00
bin We don't generate .o's anymore for helper programs, so don't CLEANFILES them. 1998-09-12 18:58:41 +00:00
distrib Switch i386 to egcs 1.1. 1998-09-14 00:29:28 +00:00
etc remove the sortlist line preferring nasa's nameservers. Sorry jason :-) 1998-09-14 05:05:44 +00:00
games remove x bit from save files (PR#6077) 1998-09-13 15:41:34 +00:00
gnu Rethink the origins of LDSTATIC. Instead, use an option NOLINKLIB, which 1998-09-13 23:25:18 +00:00
include __LIBCxx_SOURCE__ refers to the library major number, not the NetBSD release 1998-09-13 04:11:51 +00:00
lib New files specific to the NetBSD libbz2. 1998-09-14 03:18:12 +00:00
libexec At least make the comments accurate. 1998-09-13 05:53:34 +00:00
regress Make this cross-compile right. 1998-09-12 20:17:43 +00:00
sbin Document noasync and nosync. 1998-09-14 03:48:30 +00:00
share Switch i386 to egcs 1.1. 1998-09-14 00:29:28 +00:00
sys Fix a problem uncovered when we started to use the pool allocator to manage 1998-09-14 05:49:20 +00:00
usr.bin Fix MLINKS. Define LDADD and DPADD. 1998-09-14 05:34:41 +00:00
usr.sbin Rethink the origins of LDSTATIC. Instead, use an option NOLINKLIB, which 1998-09-13 23:25:18 +00:00
Makefile No need to shield alpha from gcc 2.7 libgcc any longer. Default is egcs. 1998-08-27 14:11:45 +00:00