From patchwork Fri Jun 24 04:30:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 9196583 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 DCB126075F for ; Fri, 24 Jun 2016 04:31:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D24A82848B for ; Fri, 24 Jun 2016 04:31:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6E0F2848E; Fri, 24 Jun 2016 04:31:35 +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 A0DF52848D for ; Fri, 24 Jun 2016 04:31:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369AbcFXEbb (ORCPT ); Fri, 24 Jun 2016 00:31:31 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36761 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751229AbcFXEb3 (ORCPT ); Fri, 24 Jun 2016 00:31:29 -0400 Received: by mail-oi0-f65.google.com with SMTP id x6so16143616oif.3 for ; Thu, 23 Jun 2016 21:31:29 -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=Gs49wSOpquWQWPmeiZLBsAen2KjqHW2nNhkgd/JT2RE=; b=Ndx2M8FeejGDYX9P3NxG75m/dQIJJk4CGxcVrdwPkx3elfJCK7kZO3QtY9oqW1xXET aEX/jBJ0u9TGUQbKqDOAP6c67wABfFb1HxrmEeFUqjaT2zWlGX2D3S3Jbi/J0LndTLXX G0znSaEOp55Vy6xW1xsVrC7cM3/gxz2jEuKA3iZE+vw+5LUtYSP+6DTwCRChxKPbdUXN IOoXCug1CtpUXoPSy5I32fRrwsyKAZnE11BwPwX63FXeTpODOjlH7rEUSwYGnyQ0Hbyg DPUuryFLTS3z239mBp8IEQVZ3wC2YSz44aS7bf/1cDPxgcHsT9l8MWTzC5sbIuUzgLKm uMDw== 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=Gs49wSOpquWQWPmeiZLBsAen2KjqHW2nNhkgd/JT2RE=; b=K/byd89NqTQEgIp225Um7wctROxvbkOy9D29yMzhKKkusrfYnH3v4wigXFYH4Womvr eNDjbsugv9cmhSjdwNTNsYw9KV3JFE11b02gYweqTYJ4mWl6po4fJtF/1LoxTdb7AJH7 pgN2V7HI+9ffsVzYa7wc6+PmWnBJAkk9t6V2XN8c10dKYwFi/77urCXfCRwJrvojV/rh mUmreauIPUGlEb9SeLgzDNzunu4DEY2M6kNE2i94vrfi64jXFy2Ni5l5z6zhojNicctT XK96BKpKrQYu7cGuChfeda7XkegYfNio6LqIDdda9zZYseFECmcVOuEvoh5R7AnLC08X j+2w== X-Gm-Message-State: ALyK8tLW6AuLGn8LvJG1zlcUJ7PHKO4k2XHWYZ3SVhQifRYRQP+qSE8jxnn/sORYMtShIQ== X-Received: by 10.202.4.66 with SMTP id 63mr1328247oie.101.1466742688396; Thu, 23 Jun 2016 21:31:28 -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 v64sm1986157oie.5.2016.06.23.21.31.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jun 2016 21:31:27 -0700 (PDT) From: Steve French To: linux-cifs@vger.kernel.org Cc: Steve French , Steve French Subject: [PATCH 1/2] [SMB3] Fix reconnect to not defer smb3 session reconnect long after socket reconnect Date: Thu, 23 Jun 2016 23:30:46 -0500 Message-Id: <1466742647-9805-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. Signed-off-by: Steve French --- fs/cifs/connect.c | 4 +++- fs/cifs/smb2pdu.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 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..4030cbd 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1818,6 +1818,30 @@ 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) + rc = smb2_reconnect(SMB2_ECHO, tcon); + } + } + 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;