From f022a827baf57aab8d381d89837c5f38d221f4d9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 10 Apr 2012 15:02:13 +0000 Subject: [PATCH] ib_srpt: Close active sessions when disabling a target git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4202 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 898f3f5ef..d020a4642 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2190,6 +2190,8 @@ static bool __srpt_close_ch(struct srpt_rdma_ch *ch) enum rdma_ch_state prev_state; bool was_live; + BUG_ON(!ch->cm_id); + sdev = ch->sport->sdev; was_live = false; @@ -2272,6 +2274,17 @@ static int srpt_enable_target(struct scst_tgt *scst_tgt, bool enable) spin_lock_irq(&sdev->spinlock); sdev->enabled = enable; + if (!enable) { + struct srpt_rdma_ch *ch; + + list_for_each_entry(ch, &sdev->rch_list, list) { + PRINT_INFO("Closing channel %s (cm_id %p)" + " because target %s has been disabled", + ch->sess_name, ch->cm_id, + sdev->device->name); + __srpt_close_ch(ch); + } + } spin_unlock_irq(&sdev->spinlock); return 0;