From patchwork Thu Nov 23 00:38:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 10072139 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 1B71260595 for ; Thu, 23 Nov 2017 00:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CC2D29DBF for ; Thu, 23 Nov 2017 00:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01C2B29DC8; Thu, 23 Nov 2017 00:41:02 +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=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 A0C3629DBF for ; Thu, 23 Nov 2017 00:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752854AbdKWAkT (ORCPT ); Wed, 22 Nov 2017 19:40:19 -0500 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:37644 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752836AbdKWAkR (ORCPT ); Wed, 22 Nov 2017 19:40:17 -0500 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id HfXbe5G79ZHUgHfXbe8HOX; Wed, 22 Nov 2017 17:39:15 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1eHfXb-0004Sk-2r; Wed, 22 Nov 2017 17:38:55 -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 , Stephen Hemminger Cc: Long Li Subject: [Patch v8 02/16] CIFS: SMBD: Implement function to reconnect to a SMB Direct transport Date: Wed, 22 Nov 2017 17:38:35 -0700 Message-Id: <20171123003849.17093-3-longli@exchange.microsoft.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171123003849.17093-1-longli@exchange.microsoft.com> References: <20171123003849.17093-1-longli@exchange.microsoft.com> X-CMAE-Envelope: MS4wfPF3FfXcRss02iuIIPD/Cl2sMQH7uivAVwNt8xr4jYwJoc2Liv75ilshXnJANLjUwIlsigD2pjgc5siYRVer5h8qmQ7QM6+LIMmw1x9zIxt0IXoviDYN GWphHxcqAhtMyufICwVR36YA2yWVWBR6Xw72ZZfPzdhQ++LJTB6tabDvb/KgTC+2Pwdxsk0Eft5v1tUs+6+fWd0A6tqz5gZeuAxKibMZbmQaHfF3059zWJGj R4dJUY8eBMHsDLPwz4KKNhXSH+t9V3v73RIc1vwj0qRC6BQvt4B7ms4pfJBv4G5JC5lWEnPHPM6aBDo+pqUIBwdZcDeTelZFpBplJLASpahrXD9j5QBUYWER lBSHMVmERrDf/0245RHDZ/F/mZXRaSxS9WG5exuaoDdnssZ8A4zkhXcNLqKy8KIszMYAHpLkzYR0QV+Ko+iOvsmJsNZY1s4rRi67r8JBRpoTF88hFDSgb07v YpEXLbgp7wEUGT89G+MB/sEhYbIYQiAkpS7tCA== 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 SMB Direct. 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 | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index 862cdf9..a96058a 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -1387,6 +1387,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 25b3782..8948f06 100644 --- a/fs/cifs/smbdirect.h +++ b/fs/cifs/smbdirect.h @@ -247,11 +247,15 @@ 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); + #else #define cifs_rdma_enabled(server) 0 struct smbd_connection {}; static inline void *smbd_get_connection( struct TCP_Server_Info *server, struct sockaddr *dstaddr) {return NULL;} +static inline int smbd_reconnect(struct TCP_Server_Info *server) {return -1;} #endif #endif