freebsd-skq/sys/cam/scsi
Kenneth D. Merry 86d45c7f3b Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4)
drivers.

The bug occurrs when a userland process has the driver instance
open and the underlying device goes away.  We get the devfs
callback that the device node has been destroyed, but not all of
the closes necessary to fully decrement the reference count on the
CAM peripheral.

The reason is that once devfs calls back and says the device has
been destroyed, it is moved off to deadfs, and devfs guarantees
that there will be no more open or close calls.  So the solution
is to keep track of how many outstanding open calls there are on
the device, and just release that many references when we get the
callback from devfs.

scsi_pass.c,
scsi_enc.c,
scsi_enc_internal.h:	Add an open count to the softc in these
			drivers.  Increment it on open and
			decrement it on close.

			When we get a devfs callback to say that
			the device node has gone away, decrement
			the peripheral reference count by the
			number of still outstanding opens.

			Make sure we don't access the peripheral
			with cam_periph_unlock() after what might
			be the final call to
			cam_periph_release_locked().  The
			peripheral might have been freed, and we
			will be dereferencing freed memory.

scsi_ch.c,
scsi_sg.c:		For the ch(4) and sg(4) drivers, add the
			same changes described above, and in
			addition, fix another bug that was
			previously fixed in the pass(4) and enc(4)
			drivers.

			These drivers were calling destroy_dev()
			from their cleanup routine, but that could
			cause a deadlock because the cleanup
			routine could be indirectly called from
			the driver's close routine.  This would
			cause a deadlock, because the device node
			is being held open by the active close
			call, and can't be destroyed.

Sponsored by:	Spectra Logic Corporation
MFC after:	1 week
2012-12-08 04:03:04 +00:00
..
scsi_all.c Fix some typos in r238595. 2012-07-18 12:41:09 +00:00
scsi_all.h Add missing VERIFY_10 definition. 2012-08-12 16:58:38 +00:00
scsi_cd.c There are SCSI conditions that are not an errors. In those cases cderror() 2012-10-10 19:32:40 +00:00
scsi_cd.h
scsi_ch.c Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4) 2012-12-08 04:03:04 +00:00
scsi_ch.h - fix duplicate "a a" in some comments 2011-11-13 17:06:33 +00:00
scsi_da.c Fix locking problem in disk_resize(); previously it would run without 2012-10-29 17:52:43 +00:00
scsi_da.h Change 'camcontrol defects' to first probe a drive to find out how much 2012-06-22 18:57:06 +00:00
scsi_dvcfg.h
scsi_enc_internal.h Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4) 2012-12-08 04:03:04 +00:00
scsi_enc_safte.c 1. Remove SEN support. I doubt there are any working examples 2012-08-12 17:01:07 +00:00
scsi_enc_ses.c Use information about suported diagnostic pages to avoid reading optional 2012-11-07 23:12:53 +00:00
scsi_enc.c Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4) 2012-12-08 04:03:04 +00:00
scsi_enc.h MFprojects/zfsd: 2012-05-24 14:07:44 +00:00
scsi_iu.h
scsi_low.c Remove some more NetBSD compat shims and other unused bits from these 2012-09-10 18:49:49 +00:00
scsi_low.h Remove some more NetBSD compat shims and other unused bits from these 2012-09-10 18:49:49 +00:00
scsi_message.h
scsi_pass.c Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4) 2012-12-08 04:03:04 +00:00
scsi_pass.h
scsi_pt.c Remove two more 'periph == NULL' checks missed in r241404. 2012-10-23 16:03:00 +00:00
scsi_pt.h
scsi_sa.c Remove 'periph == NULL' check from bunch of periph drivers. 2012-10-10 18:10:11 +00:00
scsi_sa.h
scsi_ses.h Fix off by one error in ses_enc_desc_last_byte(). 2012-07-24 13:32:49 +00:00
scsi_sg.c Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4) 2012-12-08 04:03:04 +00:00
scsi_sg.h
scsi_targ_bh.c Add the CAM Target Layer (CTL). 2012-01-12 00:34:33 +00:00
scsi_target.c To make CAM debugging easier, compile in some debug flags (CAM_DEBUG_INFO, 2012-06-07 10:05:51 +00:00
scsi_targetio.h
scsi_xpt.c Don't duplicate path/ccb allocation code, use existing functions. 2012-10-11 19:57:11 +00:00
smp_all.c Add Serial Management Protocol (SMP) passthrough support to CAM. 2010-11-30 22:39:46 +00:00
smp_all.h Add Serial Management Protocol (SMP) passthrough support to CAM. 2010-11-30 22:39:46 +00:00