From patchwork Wed Aug 2 20:10:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 9877535 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 91EC760360 for ; Wed, 2 Aug 2017 20:16:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83AED286BB for ; Wed, 2 Aug 2017 20:16:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 789F4287FF; Wed, 2 Aug 2017 20:16:19 +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 2DBBF286BB for ; Wed, 2 Aug 2017 20:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753162AbdHBUOW (ORCPT ); Wed, 2 Aug 2017 16:14:22 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:36994 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753044AbdHBUM0 (ORCPT ); Wed, 2 Aug 2017 16:12:26 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id czzJd530H3vhKczzJdxf37; 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 1dczzJ-0005I7-6J; Wed, 02 Aug 2017 13:11:25 -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] 25/37] [CIFS] SMBD: Support SMBD idle connection timer Date: Wed, 2 Aug 2017 13:10:36 -0700 Message-Id: <1501704648-20159-26-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: MS4wfA9N3MVBsZl+UBAuku3tCjA+6Py/zudTvgWW8HiwUdS9iHnsGJflZNIv9ofL/lXkhDMYjm3W6yJIY00pxHYXhzRad6vvS5sAjYbMBMHxpc/D87Zs07ME VLI++9ENrsB9+xh5t4aTFChouwea/H0qfcV3kZph3qCFdhA3GlyFxyoo19P9jqV75Dtqa2TJ6ILaBaEovJw4IVzT0dSuIVIfzCCSsDJcdBdpTQQFL8a/wUdN 8JYdYFHJD7qJ80yJ01kDU8w71bBiiSFy9zHqnFqXpTNDbH/rS4+d7x0OfzppdugunPBPSITMZhg6z9e+2mZO0Ml6nDERnejQq3vbOY3x4oU= 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 This is part of the keep alive protocol. Each peer maintains a timer, and will send a message to peer when it expires. Signed-off-by: Long Li --- fs/cifs/cifsrdma.c | 25 +++++++++++++++++++++++++ fs/cifs/cifsrdma.h | 6 ++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsrdma.c b/fs/cifs/cifsrdma.c index e275834..523c80f 100644 --- a/fs/cifs/cifsrdma.c +++ b/fs/cifs/cifsrdma.c @@ -89,6 +89,7 @@ static int send_credit_target = 512; static int max_send_size = 8192; static int max_fragmented_recv_size = 1024*1024; static int max_receive_size = 8192; +static int keep_alive_interval = 120; // maximum number of SGEs in a RDMA I/O static int max_send_sge = 16; @@ -1200,6 +1201,25 @@ static void destroy_receive_buffers(struct cifs_rdma_info *info) mempool_free(response, info->response_mempool); } +// Implement idle connection timer [MS-SMBD] 3.1.6.2 +static void idle_connection_timer(struct work_struct *work) +{ + struct cifs_rdma_info *info = container_of( + work, struct cifs_rdma_info, + idle_timer_work.work); + + if (info->keep_alive_requested != KEEP_ALIVE_NONE) + log_keep_alive("error status info->keep_alive_requested=%d\n", + info->keep_alive_requested); + + log_keep_alive("about to send an empty idle message\n"); + cifs_rdma_post_send_empty(info); + + // setup the next idle timeout work + schedule_delayed_work(&info->idle_timer_work, + info->keep_alive_interval*HZ); +} + int cifs_reconnect_rdma_session(struct TCP_Server_Info *server) { log_rdma_event("reconnecting rdma session\n"); @@ -1262,6 +1282,7 @@ struct cifs_rdma_info* cifs_create_rdma_session( info->max_send_size = max_send_size; info->max_fragmented_recv_size = max_fragmented_recv_size; info->max_receive_size = max_receive_size; + info->keep_alive_interval = keep_alive_interval; max_send_sge = min_t(int, max_send_sge, info->id->device->attrs.max_sge); @@ -1348,6 +1369,10 @@ struct cifs_rdma_info* cifs_create_rdma_session( init_waitqueue_head(&info->wait_send_queue); init_waitqueue_head(&info->wait_reassembly_queue); + INIT_DELAYED_WORK(&info->idle_timer_work, idle_connection_timer); + schedule_delayed_work(&info->idle_timer_work, + info->keep_alive_interval*HZ); + init_waitqueue_head(&info->wait_send_pending); atomic_set(&info->send_pending, 0); diff --git a/fs/cifs/cifsrdma.h b/fs/cifs/cifsrdma.h index 62d0bb8..dd497ce 100644 --- a/fs/cifs/cifsrdma.h +++ b/fs/cifs/cifsrdma.h @@ -73,6 +73,7 @@ struct cifs_rdma_info { int max_fragmented_recv_size; int max_fragmented_send_size; int max_receive_size; + int keep_alive_interval; int max_readwrite_size; enum keep_alive_status keep_alive_requested; int protocol; @@ -101,12 +102,13 @@ struct cifs_rdma_info { wait_queue_head_t wait_send_queue; + bool full_packet_received; + struct delayed_work idle_timer_work;; + // request pool for RDMA send struct kmem_cache *request_cache; mempool_t *request_mempool; - bool full_packet_received; - // response pool for RDMA receive struct kmem_cache *response_cache; mempool_t *response_mempool;