From patchwork Fri Nov 3 23:20:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10041365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDBBF602D8 for ; Fri, 3 Nov 2017 23:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D015E283AF for ; Fri, 3 Nov 2017 23:21:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C50B22920A; Fri, 3 Nov 2017 23:21:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A85328757 for ; Fri, 3 Nov 2017 23:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752425AbdKCXVG (ORCPT ); Fri, 3 Nov 2017 19:21:06 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:49360 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752114AbdKCXVB (ORCPT ); Fri, 3 Nov 2017 19:21:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1509751262; x=1541287262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=p91502IrrbfM659NSDgdqr2ihGCCpRP8nEmIQQ16qYI=; b=DAZ1mf8YbVBldY7o5EFPpQukBdbjpSR6T1xp5dPQ5+X/Bo/1u3pEDNQi 4OdzfR9dvD5+Ly97QF2isZyLUR64HX5IDdexl/nUtHAc9jRHioo7fob4F oJCKPk/9JcIv9jAeKqQ/DIZ5qO/1YXCDNh3/URHJazzjUgr+posn7vVWL 409uKLm/OyVNhOTlhuDcHmiW/ga3houzoVDLi6dVprr/hCn1ZSQ5uoa5e 7VECE8noWy//3l7V5TE/BPCGK0O+XngRhhHoxh/+mp1kyVN+3OsYdACkB G3Jcmd484hZ0WnLGxZYDVgKp01nG0IhnjD991yPivAy4tgVYbogyuUL/g w==; X-IronPort-AV: E=Sophos;i="5.44,339,1505750400"; d="scan'208";a="61365170" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Nov 2017 07:21:01 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 03 Nov 2017 16:19:02 -0700 Received: from unknown (HELO MILHUBIP04.sdcorp.global.sandisk.com) ([10.177.9.97]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Nov 2017 16:21:01 -0700 Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Fri, 3 Nov 2017 16:20:59 -0700 X-AuditID: 0ab1095a-d99e3980000146e4-bd-59fcf9dba24e Received: from thinkpad-bart.int.fusionio.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 28.33.18148.BD9FCF95; Fri, 3 Nov 2017 16:20:59 -0700 (PDT) From: Bart Van Assche To: Doug Ledford CC: , Mike Marciniszyn , Bart Van Assche Subject: [PATCH 3/5] IB/srpt: Introduce srpt_disconnect_ch_sync() Date: Fri, 3 Nov 2017 16:20:54 -0700 Message-ID: <20171103232056.30614-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171103232056.30614-1-bart.vanassche@wdc.com> References: <20171103232056.30614-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJMWRmVeSWpSXmKPExsXCtZGTTff2zz+RBs3vpCwu/fnCaPHy/AdW i2eHelksNvxvZHdg8Vi85yWTx/t9V9k8Pm+S82g/0M0UwBLFZZOSmpNZllqkb5fAlXG+v421 YIVwxe7Zp5kbGOcJdDFyckgImEhsbNjB0sXIxSEksJJR4vStA6wgCTYBPYlT8/YxgdgiAmoS m14tYgexmQWqJa7umc4IYgsLOEqcOfGFuYuRg4NFQFXi8e06kDCvgLXEjNaVzBDz5SXWvr3H CFLCKWAjcX6mOEhYCKhkyc0G1gmM3AsYGVYxiuVm5hTnpmcWGBrpFSfmpWQWZ+sl5+duYoT4 PmoH4/WJ5ocYmTg4pRoYJ2/nZmbtL9ldePBwUdUJVofF//gCStm7rq7xv9tWyCpw5vLzO43H 98mm7gtTiuKrko09d36HXGJ416Izh94zdG5gaRC94fTxr4qsazlD6P0TPDKn+bq6cySXivzx T3svLbG0YV3W90NMd06+W8f93LDytlh8fPyc04kfzeISnn5aHRL7/cBCJZbijERDLeai4kQA 8cWEnK0BAAA= MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Except for changing a BUG_ON() call into a WARN_ON_ONCE() call, this patch does not change any functionality. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srpt/ib_srpt.c | 51 ++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index a5f232e9b1f3..1aeb8d6ae6d9 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1787,6 +1787,40 @@ static int srpt_disconnect_ch(struct srpt_rdma_ch *ch) return ret; } +/* + * Send DREQ and wait for DREP. Return true if and only if this function + * changed the state of @ch. + */ +static bool srpt_disconnect_ch_sync(struct srpt_rdma_ch *ch) + __must_hold(&sdev->mutex) +{ + DECLARE_COMPLETION_ONSTACK(release_done); + struct srpt_device *sdev = ch->sport->sdev; + bool wait; + + lockdep_assert_held(&sdev->mutex); + + pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num, + ch->state); + + WARN_ON(ch->release_done); + ch->release_done = &release_done; + wait = !list_empty(&ch->list); + srpt_disconnect_ch(ch); + mutex_unlock(&sdev->mutex); + + if (!wait) + goto out; + + while (wait_for_completion_timeout(&release_done, 180 * HZ) == 0) + pr_info("%s(%s-%d state %d): still waiting ...\n", __func__, + ch->sess_name, ch->qp->qp_num, ch->state); + +out: + mutex_lock(&sdev->mutex); + return wait; +} + static void __srpt_close_all_ch(struct srpt_device *sdev) { struct srpt_rdma_ch *ch; @@ -2791,27 +2825,12 @@ static void srpt_release_cmd(struct se_cmd *se_cmd) */ static void srpt_close_session(struct se_session *se_sess) { - DECLARE_COMPLETION_ONSTACK(release_done); struct srpt_rdma_ch *ch = se_sess->fabric_sess_ptr; struct srpt_device *sdev = ch->sport->sdev; - bool wait; - - pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num, - ch->state); mutex_lock(&sdev->mutex); - BUG_ON(ch->release_done); - ch->release_done = &release_done; - wait = !list_empty(&ch->list); - srpt_disconnect_ch(ch); + srpt_disconnect_ch_sync(ch); mutex_unlock(&sdev->mutex); - - if (!wait) - return; - - while (wait_for_completion_timeout(&release_done, 180 * HZ) == 0) - pr_info("%s(%s-%d state %d): still waiting ...\n", __func__, - ch->sess_name, ch->qp->qp_num, ch->state); } /**