From 907bc8222d6036787a891dc4bf0da6534fe520b4 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 23 May 2012 07:32:02 +0000 Subject: [PATCH] ib_srpt: Make sure that a DREP is sent to the initiator if a DREQ is received while a session is being closed git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4313 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 27 +++++++++++---------------- srpt/src/ib_srpt.h | 6 ++++-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index cdbc38a23..8f83d26f4 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -2076,6 +2076,14 @@ static int srpt_compl_thread(void *arg) list_del(&ch->list); spin_unlock_irq(&sdev->spinlock); + if (ch->dreq_received) { + if (ib_send_cm_drep(ch->cm_id, NULL, 0) >= 0) + PRINT_INFO("Received DREQ and sent DREP for session %s", + ch->sess_name); + else + PRINT_ERROR("Sending DREP failed"); + } + /* * If the connection is still established, ib_destroy_cm_id() will * send a DREQ. @@ -2728,23 +2736,10 @@ static void srpt_cm_rep_error(struct ib_cm_id *cm_id) */ static void srpt_cm_dreq_recv(struct ib_cm_id *cm_id) { - struct srpt_rdma_ch *ch; + struct srpt_rdma_ch *ch = cm_id->context; - ch = cm_id->context; - - switch (srpt_set_ch_state_to_disc(ch)) { - case CH_CONNECTING: - case CH_LIVE: - if (ib_send_cm_drep(ch->cm_id, NULL, 0) >= 0) - PRINT_INFO("Received DREQ and sent DREP for session %s", - ch->sess_name); - else - PRINT_ERROR("Sending DREP failed"); - break; - default: - WARN_ON(true); - break; - } + ch->dreq_received = true; + srpt_set_ch_state_to_disc(ch); } /** diff --git a/srpt/src/ib_srpt.h b/srpt/src/ib_srpt.h index 9fff97cfe..28a6221a8 100644 --- a/srpt/src/ib_srpt.h +++ b/srpt/src/ib_srpt.h @@ -306,8 +306,9 @@ enum rdma_ch_state { * @ioctx_ring: Send I/O context ring. * @wc: Work completion array. * @state: channel state. See also enum rdma_ch_state. - * @rtu_received: Whether IB CM RTU event has been received and the requests - * received before that event have been processed. + * @dreq_received: Whether an IB CM DREQ event has been received. + * @rtu_received: Whether an IB CM RTU event has been received and the + * requests received before that event have been processed. * @list: node for insertion in the srpt_device.rch_list list. * @cmd_wait_list: list of SCST commands that arrived before the RTU event. This * list contains struct srpt_ioctx elements and is protected @@ -340,6 +341,7 @@ struct srpt_rdma_ch { struct list_head list; struct list_head cmd_wait_list; bool rtu_received; + bool dreq_received; bool last_wqe_received; struct scst_session *scst_sess;