freebsd-dev/sys/cam/scsi
Kenneth D. Merry ee9c90c75c Fix a problem with the way we handled device invalidation when attaching
to a device failed.

In theory, the same steps that happen when we get an AC_LOST_DEVICE async
notification should have been taken when a driver fails to attach.  In
practice, that wasn't the case.

This only affected the da, cd and ch drivers, but the fix affects all
peripheral drivers.

There were several possible problems:
 - In the da driver, we didn't remove the peripheral's softc from the da
   driver's linked list of softcs.  Once the peripheral and softc got
   removed, we'd get a kernel panic the next time the timeout routine
   called dasendorderedtag().
 - In the da, cd and possibly ch drivers, we didn't remove the
   peripheral's devstat structure from the devstat queue.  Once the
   peripheral and softc were removed, this could cause a panic if anyone
   tried to access device statistics.  (one component of the linked list
   wouldn't exist anymore)
 - In the cd driver, we didn't take the peripheral off the changer run
   queue if it was scheduled to run.  In practice, it's highly unlikely,
   and maybe impossible that the peripheral would have been on the
   changer run queue at that stage of the probe process.

The fix is:
 - Add a new peripheral callback function (the "oninvalidate" function)
   that is called the first time cam_periph_invalidate() is called for a
   peripheral.

 - Create new foooninvalidate() routines for each peripheral driver.  This
   routine is always called at splsoftcam(), and contains all the stuff
   that used to be in the AC_LOST_DEVICE case of the async callback
   handler.

 - Move the devstat cleanup call to the destructor/cleanup routines, since
   some of the drivers do I/O in their close routines.

 - Make sure that when we're flushing the buffer queue, we traverse it at
   splbio().

 - Add a check for the invalid flag in the pt driver's open routine.

Reviewed by:	gibbs
1998-10-22 22:16:56 +00:00
..
scsi_all.c Fix several potential buffer overrun conditions. These changes have been 1998-10-15 19:08:58 +00:00
scsi_all.h Fix several potential buffer overrun conditions. These changes have been 1998-10-15 19:08:58 +00:00
scsi_cd.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
scsi_cd.h Some fixes to the CD driver that may fix PR kern/7996. The data direction 1998-09-20 22:48:15 +00:00
scsi_ch.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
scsi_ch.h SCSI Peripheral drivers for CAM: 1998-09-15 06:36:34 +00:00
scsi_da.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
scsi_da.h Fix the CAM code so that people can compile kernels with the CD driver but 1998-09-18 22:33:59 +00:00
scsi_message.h SCSI Peripheral drivers for CAM: 1998-09-15 06:36:34 +00:00
scsi_pass.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
scsi_pass.h SCSI Peripheral drivers for CAM: 1998-09-15 06:36:34 +00:00
scsi_pt.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
scsi_pt.h SCSI Peripheral drivers for CAM: 1998-09-15 06:36:34 +00:00
scsi_sa.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
scsi_sa.h SCSI Peripheral drivers for CAM: 1998-09-15 06:36:34 +00:00
scsi_target.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
scsi_targetio.h SCSI Peripheral drivers for CAM: 1998-09-15 06:36:34 +00:00