From patchwork Tue Nov 7 08:55:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 835188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yWNgl32mjz9s74 for ; Tue, 7 Nov 2017 20:00:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbdKGI5K (ORCPT ); Tue, 7 Nov 2017 03:57:10 -0500 Received: from a2nlsmtp01-02.prod.iad2.secureserver.net ([198.71.225.36]:34054 "EHLO a2nlsmtp01-02.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752195AbdKGI5G (ORCPT ); Tue, 7 Nov 2017 03:57:06 -0500 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id BzfqebZ9POdJ4BzfqeYoom; Tue, 07 Nov 2017 01:56:05 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1eBzfq-0003L7-Co; Tue, 07 Nov 2017 01:55:58 -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 v7 09/22] CIFS: SMBD: Implement function to reconnect to a SMB Direct transport Date: Tue, 7 Nov 2017 01:55:01 -0700 Message-Id: <20171107085514.12693-10-longli@exchange.microsoft.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171107085514.12693-1-longli@exchange.microsoft.com> References: <20171107085514.12693-1-longli@exchange.microsoft.com> X-CMAE-Envelope: MS4wfKipmAxzaSlp55LBvBksFMnxPMQdG6tce0Ixn5uJyuzfMTeqNVvXxCp76VOOd7eUlpiUEA0woNYacwMxi8UhcZzEATfMY43kHUw8iyMsctgWtqI6K7bt iIXbOSrad7KDTHKphDTODRcliR07nw9D+TGCMF7LwZIEtHkjwuy1t/xsHDfV1tPlolIN80WaeLWiCk1PrmHJWGw/IQzrDCCfVGJsl6VtpakehnKuv8BbOaW1 NtcNO2LnpTqOBYfmiNNvGRKHl0zyG+TVgFccUOWLYM8wArjceKBCB7n7P4h0aFEyLZ+P6NapJe5ZItVCMaDOquxX0DBtJ39UTOG22QvtMsw+Hvivm4CVYbrj zsVvIaQyhPV6C7XQF0AjtgDSU6st5ube6geb3ucMM688OVLC6H3+Zy81D7p3UkebyR+kT74MqbxrDt/h0naYRpVVem+FEzvaqe7UBmf8GR/1eNu5xi8sfA7W gWtlj310c04I6ulsLLMJOhK9di1fq+X1sEVbog== Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index 1db39a34..9f23330 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -1392,6 +1392,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);