From patchwork Fri Jun 24 04:39:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 9196587 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 5205960871 for ; Fri, 24 Jun 2016 04:40:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42B3D2845B for ; Fri, 24 Jun 2016 04:40:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 345652848E; Fri, 24 Jun 2016 04:40:04 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 906252845B for ; Fri, 24 Jun 2016 04:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750853AbcFXEkC (ORCPT ); Fri, 24 Jun 2016 00:40:02 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34538 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750831AbcFXEkB (ORCPT ); Fri, 24 Jun 2016 00:40:01 -0400 Received: by mail-oi0-f65.google.com with SMTP id s17so16186333oih.1; Thu, 23 Jun 2016 21:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=As6MvP5GFrxB9erbcWQskqBqWaVxXaZwk8nZ9EfBFUY=; b=MHbFdodBBVK5GKKeMt/mkYi1ojNhnqtYGhdRxrXhtq6J3yl47ycz7Qt1kH/7HK2147 1z6aJrKymA99J8QL/rdRwVyN/NbXJpQefD/XxlO/hXZk82h+phgkljwo8Td0tEGeEG57 Orl/lKHHOcchGsz49X0uAalHDb/PreWWF/kdiTPPOQP6LJeUmB02zUBDHEpMpasxwghZ 4RzUWeBUQyx0VID5+9jCaVEcY4rUNG2A8Sudj7iGAXokzNPP7APfBVvUxrYTolvb3X4H 7nQi6bVjd6dWJJei/Rte+0vJ2wjZ1vMekQFoGAzbtXuM5ag6ePL6Z7LWYcKVbiP7t6Z7 Wodw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=As6MvP5GFrxB9erbcWQskqBqWaVxXaZwk8nZ9EfBFUY=; b=cGc5jrkVocNvLyAN5wqFN2aHSfTHnkj3vRhY9HO7DFyHjFDMMPIaUPUNiaRAsaCfqT mevabBhovRgtvTnLjB9eXT/++kmXcuVSpnjbvhLfphnZPmSCOoA9h3qk0s87/zOY3TIy fB0i9xFPW/F9qKvnvu01XiYifMxcG4k9xhhKZ7a9Z3sBJx0XsmgW2DkWeGD7Jb7QXAAU Epk++XaS+aR2Ak5kFmRXvdeWEdMoCJdzNaZe4VCRs4B9acO7F9a2bn1V87ayzbtBr4HG z/fEeA9E9lzReB7LUYxNHHj0N6ECHnU7tjO2cAqE9xXF3RVylNrw/rJF/zEv6oilbK2A 2hyw== X-Gm-Message-State: ALyK8tIS+JyTz21YE750wuEY++oFlGExPz7fmF6m0ovOS0yMWDzulLAnf1bMLMr6tZBwng== X-Received: by 10.202.171.10 with SMTP id u10mr1364739oie.27.1466743200302; Thu, 23 Jun 2016 21:40:00 -0700 (PDT) Received: from localhost.localdomain (50-204-144-114-static.hfc.comcastbusiness.net. [50.204.144.114]) by smtp.gmail.com with ESMTPSA id s105sm1975092ota.28.2016.06.23.21.39.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jun 2016 21:39:59 -0700 (PDT) From: Steve French To: linux-cifs@vger.kernel.org Cc: Steve French , Stable , Steve French Subject: [PATCH v2] [SMB3] Fix reconnect to not defer smb3 session reconnect long after socket reconnect Date: Thu, 23 Jun 2016 23:39:25 -0500 Message-Id: <1466743165-9952-1-git-send-email-smfrench@gmail.com> X-Mailer: git-send-email 1.9.1 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 Azure server blocks clients that open a socket and don't do anything on it. In our reconnect scenarios, we can reconnect the tcp session and detect the socket is available but we defer the negprot and SMB3 session setup and tree connect reconnection until the next i/o is requested, but this looks suspicous to some servers who expect SMB3 negprog and session setup soon after a socket is created. In the echo thread, reconnect SMB3 sessions and tree connections that are disconnected. A later patch will replay persistent (and resilient) handle opens. CC: Stable Signed-off-by: Steve French --- fs/cifs/connect.c | 4 +++- fs/cifs/smb2pdu.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 66736f5..7d2b15c 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -428,7 +428,9 @@ cifs_echo_request(struct work_struct *work) * server->ops->need_neg() == true. Also, no need to ping if * we got a response recently. */ - if (!server->ops->need_neg || server->ops->need_neg(server) || + + if (server->tcpStatus == CifsNeedReconnect || + server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew || (server->ops->can_echo && !server->ops->can_echo(server)) || time_before(jiffies, server->lstrp + echo_interval - HZ)) goto requeue_echo; diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 8f38e33..f2cbb28 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1818,6 +1818,33 @@ SMB2_echo(struct TCP_Server_Info *server) cifs_dbg(FYI, "In echo request\n"); + if (server->tcpStatus == CifsNeedNegotiate) { + struct list_head *tmp, *tmp2; + struct cifs_ses *ses; + struct cifs_tcon *tcon; + + cifs_dbg(FYI, "Need negotiate, reconnecting tcons\n"); + spin_lock(&cifs_tcp_ses_lock); + list_for_each(tmp, &server->smb_ses_list) { + ses = list_entry(tmp, struct cifs_ses, smb_ses_list); + list_for_each(tmp2, &ses->tcon_list) { + tcon = list_entry(tmp2, struct cifs_tcon, + tcon_list); + /* add check for persistent handle reconnect */ + if (tcon && tcon->need_reconnect) { + spin_unlock(&cifs_tcp_ses_lock); + rc = smb2_reconnect(SMB2_ECHO, tcon); + spin_lock(&cifs_tcp_ses_lock); + } + } + } + spin_unlock(&cifs_tcp_ses_lock); + } + + /* if no session, renegotiate failed above */ + if (server->tcpStatus == CifsNeedNegotiate) + return -EIO; + rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req); if (rc) return rc;