From patchwork Wed Aug 2 20:10: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: 9877521 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 529A960360 for ; Wed, 2 Aug 2017 20:15:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44028286BB for ; Wed, 2 Aug 2017 20:15:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38D85287FF; Wed, 2 Aug 2017 20:15:55 +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 DA834286BB for ; Wed, 2 Aug 2017 20:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753047AbdHBUOZ (ORCPT ); Wed, 2 Aug 2017 16:14:25 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:47934 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753020AbdHBUM0 (ORCPT ); Wed, 2 Aug 2017 16:12:26 -0400 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id czzJd3WHH80gSczzJdCUmU; 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-0005I1-1z; 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] 24/37] [CIFS] SMBD: Support for SMBD keep alive protocol Date: Wed, 2 Aug 2017 13:10:35 -0700 Message-Id: <1501704648-20159-25-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: MS4wfJ1BTbgQAM+SNCJGSpQdbBP2ERSdXH1cP7h9WNH7aQN9Q+hox4yCFvRlORUnzQTRph1tnndlSVeUVZCQebOjXVuoRhof+Gx3g+L5AYbDLyuqL7zPoRr5 v1mqVO5Mxv96OI2TpZurVU1esfztdWrTZabLGXJR9Vzy0SKewdnDaQeJAtbcIFh2jwGj92BblPmItcb0qO7cYOaP8/4Rd71Li+5PWxjWCAoNYUvaaathLNqb QegeqBcqe/FgFbipx+dJHNAPn8PvSQEaSUUM4zh0tdYEUUoOZaiZQCO0HPtr1efsuaWFAqXyZ9VXaWsvRJntQ+olQX4aJPgkWoSkGTU45po= 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 SMBD uses a keep alive protocol to help peers detect if the remote is dead. When peer request keep alive, the transport needs to respond accordingly. Signed-off-by: Long Li --- fs/cifs/cifsrdma.c | 30 ++++++++++++++++++++++++++++++ fs/cifs/cifsrdma.h | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/fs/cifs/cifsrdma.c b/fs/cifs/cifsrdma.c index 4681cda..e275834 100644 --- a/fs/cifs/cifsrdma.c +++ b/fs/cifs/cifsrdma.c @@ -372,6 +372,12 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc) if (atomic_read(&info->send_credits)) wake_up(&info->wait_send_queue); + // send an emtpy response right away if requested + if (le16_to_cpu(data_transfer->flags) | + le16_to_cpu(SMB_DIRECT_RESPONSE_REQUESTED)) { + info->keep_alive_requested = KEEP_ALIVE_PENDING; + } + // process receive queue if (le32_to_cpu(data_transfer->data_length)) { if (info->full_packet_received) { @@ -627,6 +633,24 @@ static int manage_credits_prior_sending(struct cifs_rdma_info *info) } /* + * Check if we need to send a KEEP_ALIVE message + * The idle connection timer triggers a KEEP_ALIVE message when expires + * In this case, we need to set SMB_DIRECT_RESPONSE_REQUESTED in the message + * flag to have peer send back a KEEP_ALIVE + * return value: + * 1 if SMB_DIRECT_RESPONSE_REQUESTED needs to be set + * 0: otherwise + */ +static int manage_keep_alive_before_sending(struct cifs_rdma_info *info) +{ + if (info->keep_alive_requested == KEEP_ALIVE_PENDING) { + info->keep_alive_requested = KEEP_ALIVE_SENT; + return 1; + } + return 0; +} + +/* * Send a page * page: the page to send * offset: offset in the page to send @@ -662,6 +686,8 @@ static int cifs_rdma_post_send_page(struct cifs_rdma_info *info, struct page *pa packet->credits_granted = cpu_to_le16(manage_credits_prior_sending(info)); packet->flags = cpu_to_le16(0); + if (manage_keep_alive_before_sending(info)) + packet->flags |= cpu_to_le16(SMB_DIRECT_RESPONSE_REQUESTED); packet->reserved = cpu_to_le16(0); packet->data_offset = cpu_to_le32(24); @@ -773,6 +799,8 @@ static int cifs_rdma_post_send_empty(struct cifs_rdma_info *info) packet = (struct smbd_data_transfer_no_data *) request->packet; credits_granted = manage_credits_prior_sending(info); + if (manage_keep_alive_before_sending(info)) + flags = SMB_DIRECT_RESPONSE_REQUESTED; /* nothing to do? */ if (credits_granted==0 && flags==0) { @@ -885,6 +913,8 @@ static int cifs_rdma_post_send_data( packet->credits_requested = cpu_to_le16(info->send_credit_target); packet->credits_granted = cpu_to_le16(manage_credits_prior_sending(info)); packet->flags = cpu_to_le16(0); + if (manage_keep_alive_before_sending(info)) + packet->flags |= cpu_to_le16(SMB_DIRECT_RESPONSE_REQUESTED); packet->reserved = cpu_to_le16(0); packet->data_offset = cpu_to_le32(24); diff --git a/fs/cifs/cifsrdma.h b/fs/cifs/cifsrdma.h index c27db6f..62d0bb8 100644 --- a/fs/cifs/cifsrdma.h +++ b/fs/cifs/cifsrdma.h @@ -25,6 +25,12 @@ #include #include +enum keep_alive_status { + KEEP_ALIVE_NONE, + KEEP_ALIVE_PENDING, + KEEP_ALIVE_SENT, +}; + enum cifs_rdma_transport_status { CIFS_RDMA_CREATED, CIFS_RDMA_CONNECTING, @@ -68,6 +74,7 @@ struct cifs_rdma_info { int max_fragmented_send_size; int max_receive_size; int max_readwrite_size; + enum keep_alive_status keep_alive_requested; int protocol; atomic_t send_credits; atomic_t receive_credits;