From patchwork Mon Oct 2 02:30:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 9980161 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 F18D860365 for ; Mon, 2 Oct 2017 02:35:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBCFC289B3 for ; Mon, 2 Oct 2017 02:35:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0B31289B6; Mon, 2 Oct 2017 02:35:38 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 7D510289B3 for ; Mon, 2 Oct 2017 02:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672AbdJBCfh (ORCPT ); Sun, 1 Oct 2017 22:35:37 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:56470 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751749AbdJBCbz (ORCPT ); Sun, 1 Oct 2017 22:31:55 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id yqVHdUmzqirtSyqVHddSmz; Sun, 01 Oct 2017 19:30:53 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1dyqVH-0000x8-FE; Sun, 01 Oct 2017 19:30:43 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Christoph Hellwig , Tom Talpey , Matthew Wilcox Cc: Long Li Subject: [Patch v4 07/22] CIFS: SMBD: Implement function to reconnect to a SMBDirect transport Date: Sun, 1 Oct 2017 19:30:15 -0700 Message-Id: <20171002023030.3582-8-longli@exchange.microsoft.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171002023030.3582-1-longli@exchange.microsoft.com> References: <20171002023030.3582-1-longli@exchange.microsoft.com> X-CMAE-Envelope: MS4wfOCh6/L6LjJ58E+Hs6Nz4jBgaXYG70FYgn0xmtQX8hKrywxqOb1choxSDSaRHzHFS2CiWVGEXU4FnultTSyTpslOo1WVAngFOCpV5GoED7BSxvtP5Qx8 36t0/SSl7isbie6qRkeA3u6on2ac6Sd4Fg/tWcr0Ja5UFEUHZSr0u6OHWUzzReoD2Db/WdNtkExuMbSz066BF1cgmunrC/STCSJFqlnOwvJQb7YiHvXL0UXj 70Y/7zlNwLW5rm4VN73Xv6OG++H9Na1v1IouWN1wA51WZTwX5qgeoEAFFqdFPkaA3p8o/BaGi1HRxHwksulH+n8NIe7gKqNL/Ze/qeT483GySKMFhKao+Sb/ UfCk+CVFGgVBWqEMeD9CqbMxbVsIsHX9EVu6+M2m6XS80ofZPdm15Vp0/HalU9OYA2DNyNhQr6Fm65ZOLlIoJ0ZmfcFs/dIrcFxVhivCPzxjU/Ru73IyxzII cwu6lvSWLggxnNnP 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 Add function to implement a reconnect to SMBDirect. This involves tearing down the current connection and establishing/negotiating a new connection. Signed-off-by: Long Li --- fs/cifs/smbdirect.c | 36 ++++++++++++++++++++++++++++++++++++ fs/cifs/smbdirect.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index 34f73e2..1f0f33c 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -1416,6 +1416,42 @@ static void idle_connection_timer(struct work_struct *work) info->keep_alive_interval*HZ); } +/* + * Reconnect this SMBD connection, called from upper layer + * return value: 0 on success, or actual error code + */ +int smbd_reconnect(struct TCP_Server_Info *server) +{ + log_rdma_event(INFO, "reconnecting rdma session\n"); + + if (!server->smbd_conn) { + log_rdma_event(ERR, "rdma session already destroyed\n"); + return -EINVAL; + } + + /* + * This is possible if transport is disconnected and we haven't received + * notification from RDMA, but upper layer has detected timeout + */ + if (server->smbd_conn->transport_status == SMBD_CONNECTED) { + log_rdma_event(INFO, "disconnecting transport\n"); + smbd_disconnect_rdma_connection(server->smbd_conn); + } + + /* wait until the transport is destroyed */ + wait_event(server->smbd_conn->wait_destroy, + server->smbd_conn->transport_status == SMBD_DESTROYED); + + destroy_workqueue(server->smbd_conn->workqueue); + kfree(server->smbd_conn); + + log_rdma_event(INFO, "creating rdma session\n"); + server->smbd_conn = smbd_get_connection( + server, (struct sockaddr *) &server->dstaddr); + + return server->smbd_conn ? 0 : -ENOENT; +} + static void destroy_caches_and_workqueue(struct smbd_connection *info) { destroy_receive_buffers(info); diff --git a/fs/cifs/smbdirect.h b/fs/cifs/smbdirect.h index 42a9338..9818852 100644 --- a/fs/cifs/smbdirect.h +++ b/fs/cifs/smbdirect.h @@ -249,6 +249,9 @@ struct smbd_response { struct smbd_connection *smbd_get_connection( struct TCP_Server_Info *server, struct sockaddr *dstaddr); +/* Reconnect SMBDirect session */ +int smbd_reconnect(struct TCP_Server_Info *server); + void profiling_display_histogram( struct seq_file *m, unsigned long long array[]); #endif