]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/commit
MFC: 230000, 230544
authorken <ken@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 31 Jan 2012 23:04:58 +0000 (23:04 +0000)
committerken <ken@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 31 Jan 2012 23:04:58 +0000 (23:04 +0000)
commit506986d052be88f8a6a57e1c7390e04cd5a2426b
treefb27dc3158b732bb4de629e86886dbc19afca307
parent0ee9e63b8f25a8e1d4a61c7dd11b37129046020b
MFC: 230000, 230544

Fix a race condition in CAM peripheral free handling, locking
in the CAM XPT bus traversal code, and a number of other periph level
issues.

  r230544 | ken | 2012-01-25 10:58:47 -0700 (Wed, 25 Jan 2012) | 9 lines

  Fix a bug introduced in r230000.  We were eliminating all LUNs on a target
  in response to CAM_DEV_NOT_THERE, instead of just the LUN in question.

  This will now just eliminate the specified LUN in response to
  CAM_DEV_NOT_THERE.

  Reported by: Richard Todd <rmtodd@servalan.servalan.com>

  r230000 | ken | 2012-01-11 17:41:48 -0700 (Wed, 11 Jan 2012) | 72 lines

  Fix a race condition in CAM peripheral free handling, locking
  in the CAM XPT bus traversal code, and a number of other periph level
  issues.

  cam_periph.h,
  cam_periph.c: Modify cam_periph_acquire() to test the CAM_PERIPH_INVALID
   flag prior to allowing a reference count to be gained
   on a peripheral.  Callers of this function will receive
   CAM_REQ_CMP_ERR status in the situation of attempting to
   reference an invalidated periph.  This guarantees that
   a peripheral scheduled for a deferred free will not
   be accessed during its wait for destruction.

   Panic during attempts to drop a reference count on
   a peripheral that already has a zero reference count.

   In cam_periph_list(), use a local sbuf with SBUF_FIXEDLEN
   set so that mallocs do not occur while the xpt topology
   lock is held, regardless of the allocation policy of the
   passed in sbuf.

   Add a new routine, cam_periph_release_locked_buses(),
   that can be called when the caller already holds
   the CAM topology lock.

   Add some extra debugging for duplicate peripheral
   allocations in cam_periph_alloc().

   Treat CAM_DEV_NOT_THERE much the same as a selection
   timeout (AC_LOST_DEVICE is emitted), but forgo retries.

  cam_xpt.c: Revamp the way the EDT traversal code does locking
   and reference counting.  This was broken, since it
   assumed that the EDT would not change during
   traversal, but that assumption is no longer valid.

   So, to prevent devices from going away while we
   traverse the EDT, make sure we properly lock
   everything and hold references on devices that
   we are using.

   The two peripheral driver traversal routines should
   be examined.  xptpdperiphtraverse() holds the
   topology lock for the entire time it runs.
   xptperiphtraverse() is now locked properly, but
   only holds the topology lock while it is traversing
   the list, and not while the traversal function is
   running.

   The bus locking code in xptbustraverse() should
   also be revisited at a later time, since it is
   complex and should probably be simplified.

  scsi_da.c: Pay attention to the return value from cam_periph_acquire().

   Return 0 always from daclose() even if the disk is now gone.

   Add some rudimentary error injection support.

  scsi_sg.c: Fix reference counting in the sg(4) driver.

   The sg driver was calling cam_periph_release() on close,
   but never called cam_periph_acquire() (which increments
   the reference count) on open.

   The periph code correctly complained that the sg(4)
   driver was trying to decrement the refcount when it
   was already 0.

  Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/9@230849 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/cam/cam_periph.c
sys/cam/cam_periph.h
sys/cam/cam_xpt.c
sys/cam/scsi/scsi_da.c
sys/cam/scsi/scsi_sg.c