Fix multiple bugs in CAM related devices which go away unexpectedly. This
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 18 Jul 2008 00:07:23 +0000 (00:07 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 18 Jul 2008 00:07:23 +0000 (00:07 +0000)
commit2d19cdd30afbac9e1f9ef20fc261c9a41dfd36c5
tree43a6c723d86503a5ac1cb42ab2fb519aa6e41354
parent78a9b77f0d085818da065a0b5837f5244dc11d5b
Fix multiple bugs in CAM related devices which go away unexpectedly.  This
fixes numerous panics when pulling a USB mass media device in the midst of
heavy I/O.

* The SIM lock was being unlocked via the periph->sim path after periph
  was unheld.  periph can become free and blow up the unlock, so get
  the sim into a local variable first, then release periph.

* The code which waits for CCB completion needs to be a while loop, not
  an if.  It worked anyway, but wasn't very robust.

* Add CAM_SIM_DEREGISTERED to flag when a sim is undergoing deregistration.

* Beef up cam_dead_sim so it works more like a real sim.

* Properly install &cam_dead_sim in the device and periph structures
  related to a SCSI bus, when deregistering the bus.

* Disallow the addition of new devices when deregistering a bus.

* NULL out periph->softc when freeing it.
sys/bus/cam/cam_periph.c
sys/bus/cam/cam_periph.h
sys/bus/cam/cam_sim.c
sys/bus/cam/cam_sim.h
sys/bus/cam/cam_xpt.c
sys/bus/cam/scsi/scsi_cd.c
sys/bus/cam/scsi/scsi_ch.c
sys/bus/cam/scsi/scsi_da.c
sys/bus/cam/scsi/scsi_sa.c
sys/bus/cam/scsi/scsi_target.c