Changes:
authorbvassche <bvassche@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Wed, 6 Jan 2010 20:11:24 +0000 (20:11 +0000)
committerbvassche <bvassche@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Wed, 6 Jan 2010 20:11:24 +0000 (20:11 +0000)
- srpt_release_channel_by_cmid(): the sdev->spinlock and scst_mgmt_lock are
  no longer locked nested.
- srpt_find_channel(): does now return NULL when the channel is not found
  (which never happens).

git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1432 d57e44dd-8a1f-0410-8b47-8ef2f437770f

srpt/src/ib_srpt.c

index 1a7ba71..5e0dbb6 100644 (file)
@@ -1887,20 +1887,28 @@ static void srpt_release_channel_by_cmid(struct ib_cm_id *cm_id)
 {
        struct srpt_device *sdev;
        struct srpt_rdma_ch *ch;
+       bool found;
+
+       TRACE_ENTRY();
 
        sdev = cm_id->context;
        BUG_ON(!sdev);
+       found = false;
        spin_lock_irq(&sdev->spinlock);
        list_for_each_entry(ch, &sdev->rch_list, list) {
                if (ch->cm_id == cm_id) {
                        list_del(&ch->list);
                        atomic_set(&ch->state, RDMA_CHANNEL_DISCONNECTING);
-                       scst_unregister_session(ch->scst_sess, 0,
-                                               srpt_release_channel);
+                       found = true;
                        break;
                }
        }
        spin_unlock_irq(&sdev->spinlock);
+
+       if (found)
+               scst_unregister_session(ch->scst_sess, 0, srpt_release_channel);
+
+       TRACE_EXIT();
 }
 
 /**
@@ -1912,16 +1920,20 @@ static struct srpt_rdma_ch *srpt_find_channel(struct srpt_device *sdev,
                                              struct ib_cm_id *cm_id)
 {
        struct srpt_rdma_ch *ch;
+       bool found;
 
        BUG_ON(!sdev);
-       ch = NULL;
+       found = false;
        spin_lock_irq(&sdev->spinlock);
-       list_for_each_entry(ch, &sdev->rch_list, list)
-               if (ch->cm_id == cm_id)
+       list_for_each_entry(ch, &sdev->rch_list, list) {
+               if (ch->cm_id == cm_id) {
+                       found = true;
                        break;
+               }
+       }
        spin_unlock_irq(&sdev->spinlock);
 
-       return ch;
+       return found ? ch : NULL;
 }
 
 /**