From ca9004962d338db4bfa8090fe8fcd6ffc83a7424 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 6 Jan 2010 20:11:24 +0000 Subject: [PATCH] Changes: - 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: http://svn.code.sf.net/p/scst/svn/trunk@1432 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 1a7ba7189..5e0dbb6d0 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -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; } /**