RDMA/cma: Replace global lock in rdma_destroy_id() with id-specific one
authorSean Hefty <sean.hefty@intel.com>
Wed, 23 Feb 2011 17:05:39 +0000 (09:05 -0800)
committerRoland Dreier <roland@purestorage.com>
Tue, 15 Mar 2011 17:57:34 +0000 (10:57 -0700)
commita396d43a35fb91f2d4920a4700d25ecc5ec92404
tree5658f67fe3b18c51c51340b777cbb0fd803376ba
parent8d8ac86564b616bc17054cbb6e727588da64c86b
RDMA/cma: Replace global lock in rdma_destroy_id() with id-specific one

rdma_destroy_id currently uses the global rdma cm 'lock' to test if an
rdma_cm_id has been bound to a device.  This prevents an active
address resolution callback handler from assigning a device to the
rdma_cm_id after rdma_destroy_id checks for one.

Instead, we can replace the use of the global lock around the check to
the rdma_cm_id device pointer by setting the id state to destroying,
then flushing all active callbacks.  The latter is accomplished by
acquiring and releasing the handler_mutex.  Any active handler will
complete first, and any newly scheduled handlers will find the
rdma_cm_id in an invalid state.

In addition to optimizing the current locking scheme, the use of the
rdma_cm_id mutex is a more intuitive synchronization mechanism than
that of the global lock.  These changes are based on feedback from
Doug Ledford <dledford@redhat.com> while he was trying to debug a
crash in the rdma cm destroy path.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/core/cma.c