From patchwork Wed Aug 2 20:10:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 9877527 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 28A0A60360 for ; Wed, 2 Aug 2017 20:16:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A94C286BB for ; Wed, 2 Aug 2017 20:16:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F6A5287FF; Wed, 2 Aug 2017 20:16:07 +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=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 B2DCC286BB for ; Wed, 2 Aug 2017 20:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753374AbdHBUOY (ORCPT ); Wed, 2 Aug 2017 16:14:24 -0400 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:50890 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753022AbdHBUM0 (ORCPT ); Wed, 2 Aug 2017 16:12:26 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id czzJdALbMP2LIczzJdEdwq; Wed, 02 Aug 2017 13:11:25 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1dczzI-0005Hv-U6; 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] 23/37] [CIFS] SMBD: Implement API for upper layer to reconnect transport Date: Wed, 2 Aug 2017 13:10:34 -0700 Message-Id: <1501704648-20159-24-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: MS4wfPxUGI0NULX+YDZpy2Qx4s4+yRLBxTjiUg++fpWS4xa7YTDZmH6LZ6OE2Y+nWYvuiyKVFCjxbj3ACzo8hHCHbqU0Zgi9Qr4DcqvDVym6IDGWfW2ceGHh IpGjnuaaufZm3eqZbuPSyiy6TmDOk5eTRZgFP77s4HHPJisKfBfM8JBcevyGXr4YH7J/2dSNJDeYEvHRuDAqpxB8H67+FLI7iZZp6wf700grYX2jMQK2TocC gfQ8jv2baashuiYNuLnzLVBSECJXicVoMhuR4qhBeyiLjHeQaJ0yh8+iF9XvXHW1k+SPrHSpVikmi+Xc/ZQSA5b6md+NEg6CTJavntmnxXY= 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 Upper layer may request to reconnect to server for multiple reason. Disconnect can happen at SMB layer or at SMBD layer. Add function to support reconnect when transport is disconnected. Signed-off-by: Long Li --- fs/cifs/cifsrdma.c | 24 ++++++++++++++++++++++++ fs/cifs/cifsrdma.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/fs/cifs/cifsrdma.c b/fs/cifs/cifsrdma.c index 67a11d9..4681cda 100644 --- a/fs/cifs/cifsrdma.c +++ b/fs/cifs/cifsrdma.c @@ -1170,6 +1170,30 @@ static void destroy_receive_buffers(struct cifs_rdma_info *info) mempool_free(response, info->response_mempool); } +int cifs_reconnect_rdma_session(struct TCP_Server_Info *server) +{ + log_rdma_event("reconnecting rdma session\n"); + + // why reconnect while it is still connected? + if (server->rdma_ses->transport_status == CIFS_RDMA_CONNECTED) { + log_rdma_event("still connected, not reconnecting\n"); + return -EINVAL; + } + + // wait until the transport is destroyed + while (server->rdma_ses->transport_status != CIFS_RDMA_DESTROYED) + msleep(1); + + if (server->rdma_ses) + kfree(server->rdma_ses); + + log_rdma_event("creating rdma session\n"); + server->rdma_ses = cifs_create_rdma_session( + server, (struct sockaddr *) &server->dstaddr); + + return server->rdma_ses ? 0 : -ENOENT; +} + struct cifs_rdma_info* cifs_create_rdma_session( struct TCP_Server_Info *server, struct sockaddr *dstaddr) { diff --git a/fs/cifs/cifsrdma.h b/fs/cifs/cifsrdma.h index 36f3e4c..c27db6f 100644 --- a/fs/cifs/cifsrdma.h +++ b/fs/cifs/cifsrdma.h @@ -212,6 +212,9 @@ struct cifs_rdma_response { struct cifs_rdma_info* cifs_create_rdma_session( struct TCP_Server_Info *server, struct sockaddr *dstaddr); +// Reconnect SMBDirect session +int cifs_reconnect_rdma_session(struct TCP_Server_Info *server); + // SMBDirect interface for carrying upper layer CIFS I/O int cifs_rdma_read( struct cifs_rdma_info *rdma, char *buf, unsigned int to_read);