From patchwork Wed Aug 2 20:10:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 9877625 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 64FF960360 for ; Wed, 2 Aug 2017 20:22:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57121286BB for ; Wed, 2 Aug 2017 20:22:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BF39287C2; Wed, 2 Aug 2017 20:22:10 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 F0968286BB for ; Wed, 2 Aug 2017 20:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753238AbdHBUSC (ORCPT ); Wed, 2 Aug 2017 16:18:02 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:36970 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753012AbdHBUMZ (ORCPT ); Wed, 2 Aug 2017 16:12:25 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id czzId52ym3vhKczzIdxf1g; Wed, 02 Aug 2017 13:11:24 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1dczzI-0005HL-2b; Wed, 02 Aug 2017 13:11:24 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Cc: Long Li Subject: [[PATCH v1] 17/37] [CIFS] SMBD: Track status for transport Date: Wed, 2 Aug 2017 13:10:28 -0700 Message-Id: <1501704648-20159-18-git-send-email-longli@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com> References: <1501704648-20159-1-git-send-email-longli@exchange.microsoft.com> X-CMAE-Envelope: MS4wfLp8aWyXiEZEB+XrQLNGMc13SHHAONMn/Mg9o7Xh5e2l46XQQMqGiGiQ2d29zGcPxiQFxZnNhEhdynQsvyPKF38Jcj32z8Yrs+IgoRjtXr81ant5oBqE pMkyBOVwOj+coYZtH3OM985kJvsFz+WuNse7q9FUQnkIrGLtjBLu3AiNComz0zUjG4DyJPgz4sl9Z2K853g123BtLJiFSODcC+L09sOqk+APfQtiB4tYJ6Uv 4UPH3T86GxkeVYO0+sRyFrU2zDs6ghdQGX/WPK9xPPytykMJypEFVSrqqJ7TVLoRKL6hF39B8gR7XFhVgVGRUtLwdxoXScUd2uLDIgId+0g= Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Long Li Introduce status for tracking the status of SMBD transport. They are used in transport reconnect and shutdown. Signed-off-by: Long Li --- fs/cifs/cifsrdma.c | 25 +++++++++++++++++++++++++ fs/cifs/cifsrdma.h | 11 +++++++++++ 2 files changed, 36 insertions(+) diff --git a/fs/cifs/cifsrdma.c b/fs/cifs/cifsrdma.c index cf71bb1..ef21f1c 100644 --- a/fs/cifs/cifsrdma.c +++ b/fs/cifs/cifsrdma.c @@ -173,9 +173,12 @@ static int cifs_rdma_conn_upcall( case RDMA_CM_EVENT_DEVICE_REMOVAL: log_rdma_event("connected event=%d\n", event->event); info->connect_state = event->event; + info->transport_status = CIFS_RDMA_CONNECTED; + wake_up_all(&info->conn_wait); break; case RDMA_CM_EVENT_DISCONNECTED: + info->transport_status = CIFS_RDMA_DISCONNECTED; break; default: @@ -581,6 +584,12 @@ static int cifs_rdma_post_send_page(struct cifs_rdma_info *info, struct page *pa int rc = -ENOMEM; int i; + // disconnected? + if (info->transport_status != CIFS_RDMA_CONNECTED) { + log_outgoing("disconnected not sending\n"); + return -ENOENT; + } + request = mempool_alloc(info->request_mempool, GFP_KERNEL); if (!request) return rc; @@ -686,6 +695,12 @@ static int cifs_rdma_post_send_empty(struct cifs_rdma_info *info) int rc; u16 credits_granted, flags=0; + // disconnected? + if (info->transport_status != CIFS_RDMA_CONNECTED) { + log_outgoing("disconnected not sending\n"); + return -ENOENT; + } + request = mempool_alloc(info->request_mempool, GFP_KERNEL); if (!request) { log_rdma_send("failed to get send buffer for empty packet\n"); @@ -785,6 +800,12 @@ static int cifs_rdma_post_send_data( int rc = -ENOMEM, i; u32 data_length; + // disconnected? + if (info->transport_status != CIFS_RDMA_CONNECTED) { + log_outgoing("disconnected not sending\n"); + return -ENOENT; + } + request = mempool_alloc(info->request_mempool, GFP_KERNEL); if (!request) return rc; @@ -1056,6 +1077,7 @@ struct cifs_rdma_info* cifs_create_rdma_session( return NULL; info->server_info = server; + info->transport_status = CIFS_RDMA_CONNECTING; rc = cifs_rdma_ia_open(info, dstaddr); if (rc) { @@ -1122,12 +1144,15 @@ struct cifs_rdma_info* cifs_create_rdma_session( conn_param.retry_count = 6; conn_param.rnr_retry_count = 6; conn_param.flow_control = 0; + init_waitqueue_head(&info->conn_wait); rc = rdma_connect(info->id, &conn_param); if (rc) { log_rdma_event("rdma_connect() failed with %i\n", rc); goto out2; } + wait_event_interruptible( + info->conn_wait, info->transport_status == CIFS_RDMA_CONNECTED); if (info->connect_state != RDMA_CM_EVENT_ESTABLISHED) goto out2; diff --git a/fs/cifs/cifsrdma.h b/fs/cifs/cifsrdma.h index 4a4c191..9618e0b 100644 --- a/fs/cifs/cifsrdma.h +++ b/fs/cifs/cifsrdma.h @@ -25,6 +25,15 @@ #include #include +enum cifs_rdma_transport_status { + CIFS_RDMA_CREATED, + CIFS_RDMA_CONNECTING, + CIFS_RDMA_CONNECTED, + CIFS_RDMA_DISCONNECTING, + CIFS_RDMA_DISCONNECTED, + CIFS_RDMA_DESTROYED +}; + /* * The context for the SMBDirect transport * Everything related to the transport is here. It has several logical parts @@ -35,6 +44,7 @@ */ struct cifs_rdma_info { struct TCP_Server_Info *server_info; + enum cifs_rdma_transport_status transport_status; // RDMA related struct rdma_cm_id *id; @@ -45,6 +55,7 @@ struct cifs_rdma_info { int connect_state; int ri_rc; struct completion ri_done; + wait_queue_head_t conn_wait; struct completion negotiate_completion; bool negotiate_done;