freebsd-dev/sys/cam
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 Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
cam_ccb.h Add a mechanism to send a non-tagged transaction even if a device is 1998-10-15 23:17:35 +00:00
cam_conf.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_debug.h Add a new CAM debugging mode, CAM_DEBUG_CDB. This causes the kernel to 1998-10-02 21:00:58 +00:00
cam_extend.c CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_extend.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_periph.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
cam_periph.h Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
cam_queue.c CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_queue.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_sim.c CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_sim.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_xpt_periph.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_xpt_sim.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam_xpt.c Fix a problem with the way we handled device invalidation when attaching 1998-10-22 22:16:56 +00:00
cam_xpt.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00
cam.c cam.c: 1998-09-22 04:53:23 +00:00
cam.h CAM Transport Layer (XPT). 1998-09-15 06:33:23 +00:00