• Raju Rangoju's avatar
    IB/isert: Properly release resources on DEVICE_REMOVAL · 63b268d2
    Raju Rangoju authored
    When the low level driver exercises the hot unplug they would call
    rdma_cm cma_remove_one which would fire DEVICE_REMOVAL event to all cma
    consumers. Now, if consumer doesn't make sure they destroy all IB
    objects created on that IB device instance prior to finalizing all
    processing of DEVICE_REMOVAL callback, rdma_cm will let the lld to
    de-register with IB core and destroy the IB device instance. And if the
    consumer calls (say) ib_dereg_mr(), it will crash since that dev object
    is NULL.
    
    In the current implementation, iser-target just initiates the cleanup
    and returns from DEVICE_REMOVAL callback. This deferred work creates a
    race between iser-target cleaning IB objects(say MR) and lld destroying
    IB device instance.
    
    This patch includes the following fixes
      -> make sure that consumer frees all IB objects associated with device
         instance
      -> return non-zero from the callback to destroy the rdma_cm id
    Signed-off-by: default avatarRaju Rangoju <rajur@chelsio.com>
    Acked-by: default avatarSagi Grimberg <sagi@grimberg.me>
    Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
    63b268d2
ib_isert.c 71 KB