• Sean Hefty's avatar
    RDMA/cma: Replace global lock in rdma_destroy_id() with id-specific one · a396d43a
    Sean Hefty authored
    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: default avatarSean Hefty <sean.hefty@intel.com>
    Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
    a396d43a
cma.c 82.3 KB