From d8c5e561a889d09ebc586d2d466df55ab62ba416 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 18 Sep 2011 13:03:01 +0000 Subject: [PATCH] ib_srpt: Reenable session unregistration if thread != 1 git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.1.0.x@3873 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 0acf01f21..2239786c1 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -316,6 +316,18 @@ static void srpt_srq_event(struct ib_event *event, void *ctx) PRINT_INFO("SRQ event %d", event->event); } +static void srpt_release_channel(struct srpt_rdma_ch *ch) +{ + TRACE_ENTRY(); + + if (srpt_test_and_set_channel_state(ch, CH_DRAINING, CH_RELEASING) && + thread != MODE_IB_COMPLETION_IN_THREAD) { + scst_unregister_session(ch->scst_sess, false, srpt_free_ch); + } + + TRACE_EXIT(); +} + /** * srpt_qp_event() - QP event callback function. */ @@ -339,7 +351,7 @@ static void srpt_qp_event(struct ib_event *event, struct srpt_rdma_ch *ch) TRACE_DBG("%s, state %d: received Last WQE event.", ch->sess_name, atomic_read(&ch->state)); ch->last_wqe_received = true; - srpt_test_and_set_channel_state(ch, CH_DRAINING, CH_RELEASING); + srpt_release_channel(ch); break; default: PRINT_ERROR("received unrecognized IB QP event %d", @@ -2226,8 +2238,7 @@ static void srpt_drain_channel(struct ib_cm_id *cm_id) PRINT_ERROR("Setting queue pair in error state" " failed: %d", ret); if (ch->last_wqe_received) - srpt_test_and_set_channel_state(ch, CH_DRAINING, - CH_RELEASING); + srpt_release_channel(ch); } } @@ -2249,10 +2260,11 @@ static void srpt_free_ch(struct scst_session *sess) WARN_ON(atomic_read(&ch->state) != CH_RELEASING); - BUG_ON(!ch->thread); - BUG_ON(ch->thread == current); - kthread_stop(ch->thread); - ch->thread = NULL; + if (ch->thread) { + BUG_ON(ch->thread == current); + kthread_stop(ch->thread); + ch->thread = NULL; + } srpt_destroy_ch_ib(ch);