From patchwork Fri Mar 10 15:32:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169438 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A33BC6FD1F for ; Fri, 10 Mar 2023 15:45:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232110AbjCJPpB (ORCPT ); Fri, 10 Mar 2023 10:45:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234457AbjCJPop (ORCPT ); Fri, 10 Mar 2023 10:44:45 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9115125DAD for ; Fri, 10 Mar 2023 07:32:50 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id qa18-20020a17090b4fd200b0023750b675f5so10211376pjb.3 for ; Fri, 10 Mar 2023 07:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462370; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gLhrp//XsD+C95FDg8T1gfm9S5ECm9FE3n839Gavxdk=; b=jpMzea76/WCNXSipgX5Z4PmSbmKuQg72V1pmeKM09ndEj0EmKnafyMdb2pXA1EbqYb DE+xzYnjcNl24krA7KlO7QDChObxbYIq8JPA0cxNmcM0cCFIKQD/gYegTrPoWzdZQiGx L0Dy6OtPNn66/Xz+mcAHsM/DZssbHVH/UhkRHLM6Jk/uxXNX9OFtsBdpVUwQGOR7vZkX RQfjL744Lw8gD8ny6BiFkP7xDPGRnQC3q0DV0qMu5FFTRNCrWdDz/qAIhJYZ8gqxOuZg g1j7xNPAY5sphRR4GzOOGnXak/ey0DeKxifTBvOpwvQFV2c+as0nyeG3IGBsKOSABEZq gEPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462370; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gLhrp//XsD+C95FDg8T1gfm9S5ECm9FE3n839Gavxdk=; b=Pz7OANd55Y2a77+8zxCPz5kgA+A0yG7boDdmFTMXjduk48uu+uHnNCm3LHZEUfZsbp IGHGK4xbHAqMN4peuUeEWCvRZD7caJa+14ZemnEoy0tjcJiP5fBrWXCOpkJn0Uf2qhgZ dCBDgY4xJ8y/+RD1ZNJ3ln1pGc0eN3uekg4xqSiuQ+bN7AaDXaSGOXLF8ddkRgp/VW0r WroobjJWofzXpn4P9KSHrjgW8u8wQ9lcs2GxjMi47JM9sFAQvmn+/7wqAeloZGMqByE2 Zk0sfMpBUXCxgFV8SNPunT3zWUBwN5TszJkaYbrO0QeBFQZCyJWsSehbX6laSh0FCB6I OsLg== X-Gm-Message-State: AO0yUKXTcoVGNci+ZSQVxqKtqyeFu5QO+Uqucv8qR7FTJINDcqddO03e 7hXpkTgHdF2dwFmuIUnKjXRSVF0apTQ7qvD5 X-Google-Smtp-Source: AK7set9H/eCEG0mvoUuQpcjgPJ7byVAtuQ5YkoWc5rILCMrXrjuHWghdpB4B0Oc9ZkIrmTATAPVPKA== X-Received: by 2002:a17:90a:e7c7:b0:237:7891:1ea4 with SMTP id kb7-20020a17090ae7c700b0023778911ea4mr26730454pjb.18.1678462369831; Fri, 10 Mar 2023 07:32:49 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:32:49 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 01/11] cifs: fix tcon status change after tree connect Date: Fri, 10 Mar 2023 15:32:00 +0000 Message-Id: <20230310153211.10982-1-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org After cifs_tree_connect, tcon status should not be set to TID_GOOD. There could still be files that need reopen. The status should instead be changed to TID_NEED_FILES_INVALIDATE. That way, after reopen of files, the status can be changed to TID_GOOD. Signed-off-by: Shyam Prasad N Reviewed-by: Paulo Alcantara (SUSE) --- fs/cifs/cifsglob.h | 2 +- fs/cifs/connect.c | 14 ++++++++++---- fs/cifs/dfs.c | 16 +++++++++++----- fs/cifs/file.c | 10 +++++----- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index a99883f16d94..8a37b1553dc6 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -137,7 +137,7 @@ enum tid_status_enum { TID_NEED_RECON, TID_NEED_TCON, TID_IN_TCON, - TID_NEED_FILES_INVALIDATE, /* currently unused */ + TID_NEED_FILES_INVALIDATE, TID_IN_FILES_INVALIDATE }; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 5233f14f0636..3d07729c91a1 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -4038,9 +4038,15 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru /* only send once per connect */ spin_lock(&tcon->tc_lock); - if (tcon->ses->ses_status != SES_GOOD || - (tcon->status != TID_NEW && - tcon->status != TID_NEED_TCON)) { + if (tcon->status != TID_GOOD && + tcon->status != TID_NEW && + tcon->status != TID_NEED_RECON) { + spin_unlock(&tcon->tc_lock); + return -EHOSTDOWN; + } + + if (tcon->status == TID_NEED_FILES_INVALIDATE || + tcon->status == TID_GOOD) { spin_unlock(&tcon->tc_lock); return 0; } @@ -4051,7 +4057,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru if (rc) { spin_lock(&tcon->tc_lock); if (tcon->status == TID_IN_TCON) - tcon->status = TID_NEED_TCON; + tcon->status = TID_NEED_RECON; spin_unlock(&tcon->tc_lock); } else { spin_lock(&tcon->tc_lock); diff --git a/fs/cifs/dfs.c b/fs/cifs/dfs.c index b64d20374b9c..d37af02902c5 100644 --- a/fs/cifs/dfs.c +++ b/fs/cifs/dfs.c @@ -479,9 +479,15 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru /* only send once per connect */ spin_lock(&tcon->tc_lock); - if (tcon->ses->ses_status != SES_GOOD || - (tcon->status != TID_NEW && - tcon->status != TID_NEED_TCON)) { + if (tcon->status != TID_GOOD && + tcon->status != TID_NEW && + tcon->status != TID_NEED_RECON) { + spin_unlock(&tcon->tc_lock); + return -EHOSTDOWN; + } + + if (tcon->status == TID_NEED_FILES_INVALIDATE || + tcon->status == TID_GOOD) { spin_unlock(&tcon->tc_lock); return 0; } @@ -529,12 +535,12 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru if (rc) { spin_lock(&tcon->tc_lock); if (tcon->status == TID_IN_TCON) - tcon->status = TID_NEED_TCON; + tcon->status = TID_NEED_RECON; spin_unlock(&tcon->tc_lock); } else { spin_lock(&tcon->tc_lock); if (tcon->status == TID_IN_TCON) - tcon->status = TID_GOOD; + tcon->status = TID_NEED_FILES_INVALIDATE; spin_unlock(&tcon->tc_lock); tcon->need_reconnect = false; } diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 4d4a2d82636d..96d865e108f4 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -174,13 +174,13 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon) struct list_head *tmp1; /* only send once per connect */ - spin_lock(&tcon->ses->ses_lock); - if ((tcon->ses->ses_status != SES_GOOD) || (tcon->status != TID_NEED_RECON)) { - spin_unlock(&tcon->ses->ses_lock); + spin_lock(&tcon->tc_lock); + if (tcon->status != TID_NEED_FILES_INVALIDATE) { + spin_unlock(&tcon->tc_lock); return; } tcon->status = TID_IN_FILES_INVALIDATE; - spin_unlock(&tcon->ses->ses_lock); + spin_unlock(&tcon->tc_lock); /* list all files open on tree connection and mark them invalid */ spin_lock(&tcon->open_file_lock); @@ -194,7 +194,7 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon) invalidate_all_cached_dirs(tcon); spin_lock(&tcon->tc_lock); if (tcon->status == TID_IN_FILES_INVALIDATE) - tcon->status = TID_NEED_TCON; + tcon->status = TID_GOOD; spin_unlock(&tcon->tc_lock); /* From patchwork Fri Mar 10 15:32:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B904DC6FA99 for ; Fri, 10 Mar 2023 15:45:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233589AbjCJPpE (ORCPT ); Fri, 10 Mar 2023 10:45:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234473AbjCJPor (ORCPT ); Fri, 10 Mar 2023 10:44:47 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E649A10402 for ; Fri, 10 Mar 2023 07:33:00 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id fr5-20020a17090ae2c500b0023af8a036d2so9410610pjb.5 for ; Fri, 10 Mar 2023 07:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/C3AmKiDkvvGubOr3K4XsqgrnjzuSUzEVK44KJ9VBKY=; b=o/azjl7Aslqk2a5zOKiG5jF/XrNcKQossZiQPa2EkAkfFUYvmssTQD5FAWLMxh12yB zxNWwdq3CMcSK3YnWCYzLflax6ZusoP/yV5CmEFDqpifGyP0y9riXxDeHoSMMdjji7BS IhTfOPyGMVV7g804xJ/JA8u72/EE/W7Yq2cSpxGKuAbrVzPm7i5olh6fmUltWHjlNTXI ekK0p2zxhQius2WpVR0DoLtdKDaCqyXX5gt8BQLHQAmCwN3V5SpBgCvxKdG+wWPRtaNE Hjk0KpLuWRP4+tUHHQxEUNvqIhzbZDuhGHbZl8PC3aDS+lRW7R0LsdbePaPXcPAlQSnh b7gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462380; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/C3AmKiDkvvGubOr3K4XsqgrnjzuSUzEVK44KJ9VBKY=; b=JvXG1AcC7eYnwyf/VFLNCPvrlbHNak6LcErjgiAHHHE5SSDxqIMiDjiR6sMFmxMgdb kvlgonkjD/EiReqoHIohKPMWN43263OTFhSFLXcQiZ4SxwcmVXCmZRVkF8hpR1ChNX5k 8FoatzGlTu2BkuR3Rj1qAiyHOFaoYd948PK5C547pFTZpd/waANdD+kzwF9u6bZv+1nE 7is2ustCEB/ZYW8Qyy3d0K/lXswDyFfhH+07+T8ZyEwaz56Y8qmdcJnwNd7aQVlTS5TL uI8QlKdWqVk783xDjhrC3oQtBbzP1DdNFPMBA3y5kaw2WWgfiRL5J4lUyj8JkZl8+vGj KmTg== X-Gm-Message-State: AO0yUKWFXsqKLpt7HXu+xCh0XLjfPfaXyQS0cesl+Rny0anil8ftSN/V EsRkYBQlcQ4NBPM91JTMuwY= X-Google-Smtp-Source: AK7set9oVc2qdyIPY6C1mZgaaBgczxnd7c8e3XpxJAGG4uaIRnJ2l99FoFlyUdYrOucMu/d5A5N0vA== X-Received: by 2002:a17:90b:3b49:b0:237:d59d:5f89 with SMTP id ot9-20020a17090b3b4900b00237d59d5f89mr28362657pjb.4.1678462379954; Fri, 10 Mar 2023 07:32:59 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:32:59 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 02/11] cifs: generate signkey for the channel that's reconnecting Date: Fri, 10 Mar 2023 15:32:01 +0000 Message-Id: <20230310153211.10982-2-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Before my changes to how multichannel reconnects work, the primary channel was always used to do a non-binding session setup. With my changes, that is not the case anymore. Missed this place where channel at index 0 was forcibly updated with the signing key. Signed-off-by: Shyam Prasad N --- fs/cifs/smb2transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 381babc1212c..d827b7547ffa 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -425,7 +425,7 @@ generate_smb3signingkey(struct cifs_ses *ses, /* safe to access primary channel, since it will never go away */ spin_lock(&ses->chan_lock); - memcpy(ses->chans[0].signkey, ses->smb3signingkey, + memcpy(ses->chans[chan_index].signkey, ses->smb3signingkey, SMB3_SIGN_KEY_SIZE); spin_unlock(&ses->chan_lock); From patchwork Fri Mar 10 15:32:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7616EC6FA99 for ; Fri, 10 Mar 2023 15:45:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234330AbjCJPpI (ORCPT ); Fri, 10 Mar 2023 10:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234501AbjCJPou (ORCPT ); Fri, 10 Mar 2023 10:44:50 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1CC612F0F for ; Fri, 10 Mar 2023 07:33:07 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id u5so5959491plq.7 for ; Fri, 10 Mar 2023 07:33:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YUwMxf1D4oTW/BJql9s4uQVb7EF+zHYfM1JkrTVpVS8=; b=Sz3h5XckA9TMYPnaCWJ6nCBs4fg6DKZLx6vpjg+4o7/wXm90EfS8mXJ2dL1E59/JVM XTdGLTImVp9tZ/e1kCsMdQvnjZ5vCDhDF8zLBLg9tShsI4GjeU51M0tkx4lahw6yQ+vi FI2tMtFsJOFJ4fz16j08hXnpsihGR/N27d3KIVTKwwEhYEFiBStlEwGrTp8hBWucFLFU sZH1GY8+On8a8yqO+E52LYp0nLKe1vFWsDa0ZUDW3AingiXe+DTwQ6OfEsHOBTbRmPll Xv9Qv9QKYVoGq40xjFFZBOOpPzVbr9hNEAnQeaSz2C+sQ/r9+MLKT7Kzia3FvWdiGAHQ araA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YUwMxf1D4oTW/BJql9s4uQVb7EF+zHYfM1JkrTVpVS8=; b=q+oXYQU0jENJxBXw1dMIv1F6kaInysBjQpb/+KfiVvgPiyR5mFDUgBG6pAOIZdSKkG Xc+oYbTTzR2wwcd5exB8nFjCcqxus0pQ+ld7FnKRtBr03zM5YGRLyp473e9x5+K7N9Qz YwDm0vK5+vI/PCQG444AdDxAkWg54oY4qBID4QrG7DNEtYDBN+e0eB2sE7mXmI84S/PK nSBHflcSgd8VOtCOyHX3FO5dRwcWPZS/487T1E8ZaOuhkT61QhcyCE2Sg+eTHxPvFrQq ivvSkqAVgCUuazKo2159xDr1GnrgwEafOX5cIHybMLRLFzJRM5oZ0mUm313p1sUdwVCC kzYg== X-Gm-Message-State: AO0yUKU2GHmQmTqp4wPBd7R92Uxn7ybeAACYQRa3LQ28SmvRdLUOZGL/ 5ht1QeJdAQ1+Pxhr4dL2xpg= X-Google-Smtp-Source: AK7set/z5eTZ8yWN5p+YzTH3UGiJxJQCU23Ew2Ror3ur2AdLE6jRTH3IscuO9tPDab5FOs1DB3dzdA== X-Received: by 2002:a17:90b:1d8f:b0:237:161e:3329 with SMTP id pf15-20020a17090b1d8f00b00237161e3329mr25955288pjb.40.1678462386695; Fri, 10 Mar 2023 07:33:06 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:06 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 03/11] cifs: avoid race conditions with parallel reconnects Date: Fri, 10 Mar 2023 15:32:02 +0000 Message-Id: <20230310153211.10982-3-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org When multiple processes/channels do reconnects in parallel we used to return success immediately negotiate/session-setup/tree-connect, causing race conditions between processes that enter the function in parallel. This caused several errors related to session not found to show up during parallel reconnects. Signed-off-by: Shyam Prasad N --- fs/cifs/cifs_debug.c | 5 ++ fs/cifs/cifsglob.h | 14 +++- fs/cifs/connect.c | 145 ++++++++++++++++++++++++++++++++++++---- fs/cifs/dfs.c | 33 +++++++++ fs/cifs/misc.c | 2 + fs/cifs/sess.c | 8 ++- fs/cifs/smb2pdu.c | 35 +++++----- fs/cifs/smb2transport.c | 17 ++++- 8 files changed, 225 insertions(+), 34 deletions(-) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 1911f7016fa1..4391c7aac3cb 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -406,6 +406,11 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) ses->capabilities, ses->ses_status); } + if (ses->chan_count > 1) + seq_printf(m, "\n\tChannel reconnect bitmaps: 0x%lx 0x%lx", + ses->chans_need_reconnect, + ses->chans_in_reconnect); + seq_printf(m, "\n\tSecurity type: %s ", get_security_type_str(server->ops->select_sectype(server, ses->sectype))); diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 8a37b1553dc6..81ff13e41f97 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -624,6 +624,7 @@ struct TCP_Server_Info { #ifdef CONFIG_NET_NS struct net *net; #endif + wait_queue_head_t reconnect_q; /* for handling parallel reconnects */ wait_queue_head_t response_q; wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ spinlock_t mid_lock; /* protect mid queue and it's entries */ @@ -1002,7 +1003,6 @@ iface_cmp(struct cifs_server_iface *a, struct cifs_server_iface *b) } struct cifs_chan { - unsigned int in_reconnect : 1; /* if session setup in progress for this channel */ struct TCP_Server_Info *server; struct cifs_server_iface *iface; /* interface in use */ __u8 signkey[SMB3_SIGN_KEY_SIZE]; @@ -1017,6 +1017,7 @@ struct cifs_ses { struct list_head tcon_list; struct cifs_tcon *tcon_ipc; spinlock_t ses_lock; /* protect anything here that is not protected */ + wait_queue_head_t reconnect_q; /* for handling parallel reconnects */ struct mutex session_mutex; struct TCP_Server_Info *server; /* pointer to server info */ int ses_count; /* reference counter */ @@ -1076,7 +1077,9 @@ struct cifs_ses { #define CIFS_CHAN_NEEDS_RECONNECT(ses, index) \ test_bit((index), &(ses)->chans_need_reconnect) #define CIFS_CHAN_IN_RECONNECT(ses, index) \ - ((ses)->chans[(index)].in_reconnect) + test_bit((index), &(ses)->chans_in_reconnect) +#define CIFS_ALL_CHANS_IN_RECONNECT(ses) \ + ((ses)->chans_in_reconnect == CIFS_ALL_CHANNELS_SET(ses)) struct cifs_chan chans[CIFS_MAX_CHANNELS]; size_t chan_count; @@ -1092,8 +1095,14 @@ struct cifs_ses { * channels are marked for needing reconnection. This will * enable the sessions on top to continue to live till any * of the channels below are active. + * + * chans_in_reconnect is a bitmap indicating which channels + * are in the process of reconnecting. This is needed + * to avoid race conditions between processes which + * do channel binding in parallel. */ unsigned long chans_need_reconnect; + unsigned long chans_in_reconnect; /* ========= end: protected by chan_lock ======== */ struct cifs_ses *dfs_root_ses; }; @@ -1145,6 +1154,7 @@ struct cifs_tcon { int tc_count; struct list_head rlist; /* reconnect list */ spinlock_t tc_lock; /* protect anything here that is not protected */ + wait_queue_head_t reconnect_q; /* for handling parallel reconnects */ atomic_t num_local_opens; /* num of all opens including disconnected */ atomic_t num_remote_opens; /* num of all network opens on server */ struct list_head openFileList; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 3d07729c91a1..7b103f69432e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -212,8 +212,10 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, cifs_chan_update_iface(ses, server); spin_lock(&ses->chan_lock); - if (!mark_smb_session && cifs_chan_needs_reconnect(ses, server)) - goto next_session; + if (!mark_smb_session && cifs_chan_needs_reconnect(ses, server)) { + spin_unlock(&ses->chan_lock); + continue; + } if (mark_smb_session) CIFS_SET_ALL_CHANS_NEED_RECONNECT(ses); @@ -221,22 +223,28 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, cifs_chan_set_need_reconnect(ses, server); /* If all channels need reconnect, then tcon needs reconnect */ - if (!mark_smb_session && !CIFS_ALL_CHANS_NEED_RECONNECT(ses)) - goto next_session; + if (!mark_smb_session && !CIFS_ALL_CHANS_NEED_RECONNECT(ses)) { + spin_unlock(&ses->chan_lock); + continue; + } + spin_unlock(&ses->chan_lock); + spin_lock(&ses->ses_lock); ses->ses_status = SES_NEED_RECON; + spin_unlock(&ses->ses_lock); list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { tcon->need_reconnect = true; + spin_lock(&tcon->tc_lock); tcon->status = TID_NEED_RECON; + spin_unlock(&tcon->tc_lock); } if (ses->tcon_ipc) { ses->tcon_ipc->need_reconnect = true; + spin_lock(&ses->tcon_ipc->tc_lock); ses->tcon_ipc->status = TID_NEED_RECON; + spin_unlock(&ses->tcon_ipc->tc_lock); } - -next_session: - spin_unlock(&ses->chan_lock); } spin_unlock(&cifs_tcp_ses_lock); } @@ -1596,6 +1604,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx, } init_waitqueue_head(&tcp_ses->response_q); init_waitqueue_head(&tcp_ses->request_q); + init_waitqueue_head(&tcp_ses->reconnect_q); INIT_LIST_HEAD(&tcp_ses->pending_mid_q); mutex_init(&tcp_ses->_srv_mutex); memcpy(tcp_ses->workstation_RFC1001_name, @@ -3648,17 +3657,55 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses, struct TCP_Server_Info *server) { int rc = 0; + int retries = server->nr_targets; if (!server->ops->need_neg || !server->ops->negotiate) return -ENOSYS; +check_again: /* only send once per connect */ spin_lock(&server->srv_lock); - if (!server->ops->need_neg(server) || + if (server->tcpStatus != CifsGood && + server->tcpStatus != CifsNew && server->tcpStatus != CifsNeedNegotiate) { + spin_unlock(&server->srv_lock); + return -EHOSTDOWN; + } + + if (!server->ops->need_neg(server) && + server->tcpStatus == CifsGood) { spin_unlock(&server->srv_lock); return 0; } + + /* another process is in the processs of negotiating */ + while (server->tcpStatus == CifsInNegotiate) { + spin_unlock(&server->srv_lock); + rc = wait_event_interruptible_timeout(server->reconnect_q, + (server->tcpStatus != CifsInNegotiate), + HZ); + if (rc < 0) { + cifs_dbg(FYI, "%s: aborting negotiate due to a received signal by the process\n", + __func__); + return -ERESTARTSYS; + } + spin_lock(&server->srv_lock); + + /* are we still waiting for others */ + if (server->tcpStatus != CifsInNegotiate) { + spin_unlock(&server->srv_lock); + goto check_again; + } + + if (retries && --retries) + continue; + + cifs_dbg(FYI, "gave up waiting on CifsInNegotiate\n"); + spin_unlock(&server->srv_lock); + return -EHOSTDOWN; + } + + /* now mark the server so that others don't reach here */ server->tcpStatus = CifsInNegotiate; spin_unlock(&server->srv_lock); @@ -3676,6 +3723,7 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses, server->tcpStatus = CifsNeedNegotiate; spin_unlock(&server->srv_lock); } + wake_up(&server->reconnect_q); return rc; } @@ -3690,25 +3738,63 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&pserver->dstaddr; struct sockaddr_in *addr = (struct sockaddr_in *)&pserver->dstaddr; bool is_binding = false; + int retries; + +check_again: + retries = 5; spin_lock(&ses->ses_lock); if (ses->ses_status != SES_GOOD && ses->ses_status != SES_NEW && ses->ses_status != SES_NEED_RECON) { spin_unlock(&ses->ses_lock); - return 0; + return -EHOSTDOWN; } /* only send once per connect */ spin_lock(&ses->chan_lock); - if (CIFS_ALL_CHANS_GOOD(ses) || - cifs_chan_in_reconnect(ses, server)) { + if (CIFS_ALL_CHANS_GOOD(ses)) { + if (ses->ses_status == SES_NEED_RECON) + ses->ses_status = SES_GOOD; spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); return 0; } - is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); + + /* another process is in the processs of sess setup */ + while (cifs_chan_in_reconnect(ses, server)) { + spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); + rc = wait_event_interruptible_timeout(ses->reconnect_q, + (!cifs_chan_in_reconnect(ses, server)), + HZ); + if (rc < 0) { + cifs_dbg(FYI, "%s: aborting sess setup due to a received signal by the process\n", + __func__); + return -ERESTARTSYS; + } + spin_lock(&ses->ses_lock); + spin_lock(&ses->chan_lock); + + /* are we still trying to reconnect? */ + if (!cifs_chan_in_reconnect(ses, server)) { + spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); + goto check_again; + } + + if (retries && --retries) + continue; + + cifs_dbg(FYI, "gave up waiting on cifs_chan_in_reconnect\n"); + spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); + return -EHOSTDOWN; + } + + /* now mark the session so that others don't reach here */ cifs_chan_set_in_reconnect(ses, server); + is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); spin_unlock(&ses->chan_lock); if (!is_binding) @@ -3762,6 +3848,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); } + wake_up(&ses->reconnect_q); return rc; } @@ -4035,6 +4122,10 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru { int rc; const struct smb_version_operations *ops = tcon->ses->server->ops; + int retries; + +check_again: + retries = 5; /* only send once per connect */ spin_lock(&tcon->tc_lock); @@ -4050,6 +4141,35 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru spin_unlock(&tcon->tc_lock); return 0; } + + /* another process is in the processs of negotiating */ + while (tcon->status == TID_IN_TCON) { + spin_unlock(&tcon->tc_lock); + rc = wait_event_interruptible_timeout(tcon->reconnect_q, + (tcon->status != TID_IN_TCON), + HZ); + if (rc < 0) { + cifs_dbg(FYI, "%s: aborting tree connect due to a received signal by the process\n", + __func__); + return -ERESTARTSYS; + } + spin_lock(&tcon->tc_lock); + + /* are we still trying to reconnect? */ + if (tcon->status != TID_IN_TCON) { + spin_unlock(&tcon->tc_lock); + goto check_again; + } + + if (retries && --retries) + continue; + + cifs_dbg(FYI, "gave up waiting on TID_IN_TCON\n"); + spin_unlock(&tcon->tc_lock); + return -EHOSTDOWN; + } + + /* now mark the tcon so that others don't reach here */ tcon->status = TID_IN_TCON; spin_unlock(&tcon->tc_lock); @@ -4066,6 +4186,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru tcon->need_reconnect = false; spin_unlock(&tcon->tc_lock); } + wake_up(&tcon->reconnect_q); return rc; } diff --git a/fs/cifs/dfs.c b/fs/cifs/dfs.c index d37af02902c5..013a399088c3 100644 --- a/fs/cifs/dfs.c +++ b/fs/cifs/dfs.c @@ -476,6 +476,10 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru struct dfs_cache_tgt_list tl = DFS_CACHE_TGT_LIST_INIT(tl); char *tree; struct dfs_info3_param ref = {0}; + int retries; + +check_again: + retries = 5; /* only send once per connect */ spin_lock(&tcon->tc_lock); @@ -491,6 +495,35 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru spin_unlock(&tcon->tc_lock); return 0; } + + /* another process is in the processs of negotiating */ + while (tcon->status == TID_IN_TCON) { + spin_unlock(&tcon->tc_lock); + rc = wait_event_interruptible_timeout(tcon->reconnect_q, + (tcon->status != TID_IN_TCON), + HZ); + if (rc < 0) { + cifs_dbg(FYI, "%s: aborting tree connect due to a received signal by the process\n", + __func__); + return -ERESTARTSYS; + } + spin_lock(&tcon->tc_lock); + + /* are we still trying to reconnect? */ + if (tcon->status != TID_IN_TCON) { + spin_unlock(&tcon->tc_lock); + goto check_again; + } + + if (retries && --retries) + continue; + + cifs_dbg(FYI, "gave up waiting on TID_IN_TCON\n"); + spin_unlock(&tcon->tc_lock); + return -EHOSTDOWN; + } + + /* now mark the tcon so that others don't reach here */ tcon->status = TID_IN_TCON; spin_unlock(&tcon->tc_lock); diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index a0d286ee723d..5a974689fde9 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -80,6 +80,7 @@ sesInfoAlloc(void) spin_lock_init(&ret_buf->iface_lock); INIT_LIST_HEAD(&ret_buf->iface_list); spin_lock_init(&ret_buf->chan_lock); + init_waitqueue_head(&ret_buf->reconnect_q); } return ret_buf; } @@ -134,6 +135,7 @@ tconInfoAlloc(void) spin_lock_init(&ret_buf->stat_lock); atomic_set(&ret_buf->num_local_opens, 0); atomic_set(&ret_buf->num_remote_opens, 0); + init_waitqueue_head(&ret_buf->reconnect_q); return ret_buf; } diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index d2cbae4b5d21..b8bfebe4498e 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -94,7 +94,9 @@ cifs_chan_set_in_reconnect(struct cifs_ses *ses, { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); - ses->chans[chan_index].in_reconnect = true; + set_bit(chan_index, &ses->chans_in_reconnect); + cifs_dbg(FYI, "Set in-reconnect bitmask for chan %u; now 0x%lx\n", + chan_index, ses->chans_in_reconnect); } void @@ -103,7 +105,9 @@ cifs_chan_clear_in_reconnect(struct cifs_ses *ses, { unsigned int chan_index = cifs_ses_get_chan_index(ses, server); - ses->chans[chan_index].in_reconnect = false; + clear_bit(chan_index, &ses->chans_in_reconnect); + cifs_dbg(FYI, "Cleared in-reconnect bitmask for chan %u; now 0x%lx\n", + chan_index, ses->chans_in_reconnect); } bool diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 0e53265e1462..52318a79c848 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -215,8 +215,9 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, return 0; } spin_unlock(&ses->chan_lock); - cifs_dbg(FYI, "sess reconnect mask: 0x%lx, tcon reconnect: %d", + cifs_dbg(FYI, "sess reconnect masks: 0x%lx 0x%lx, tcon reconnect: %d", tcon->ses->chans_need_reconnect, + tcon->ses->chans_in_reconnect, tcon->need_reconnect); nls_codepage = load_nls_default(); @@ -238,9 +239,12 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, * need to prevent multiple threads trying to simultaneously * reconnect the same SMB session */ + spin_lock(&ses->ses_lock); spin_lock(&ses->chan_lock); - if (!cifs_chan_needs_reconnect(ses, server)) { + if (!cifs_chan_needs_reconnect(ses, server) && + ses->ses_status == SES_GOOD) { spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); /* this means that we only need to tree connect */ if (tcon->need_reconnect) @@ -249,6 +253,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, goto out; } spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); mutex_lock(&ses->session_mutex); rc = cifs_negotiate_protocol(0, ses, server); @@ -284,7 +289,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon, cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc); if (rc) { /* If sess reconnected but tcon didn't, something strange ... */ - pr_warn_once("reconnect tcon failed rc = %d\n", rc); + cifs_dbg(VFS, "reconnect tcon failed rc = %d\n", rc); goto out; } @@ -1256,9 +1261,9 @@ SMB2_sess_alloc_buffer(struct SMB2_sess_data *sess_data) if (rc) return rc; - spin_lock(&ses->chan_lock); - is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); - spin_unlock(&ses->chan_lock); + spin_lock(&ses->ses_lock); + is_binding = (ses->ses_status == SES_GOOD); + spin_unlock(&ses->ses_lock); if (is_binding) { req->hdr.SessionId = cpu_to_le64(ses->Suid); @@ -1416,9 +1421,9 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data) goto out_put_spnego_key; } - spin_lock(&ses->chan_lock); - is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); - spin_unlock(&ses->chan_lock); + spin_lock(&ses->ses_lock); + is_binding = (ses->ses_status == SES_GOOD); + spin_unlock(&ses->ses_lock); /* keep session key if binding */ if (!is_binding) { @@ -1542,9 +1547,9 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data) cifs_dbg(FYI, "rawntlmssp session setup challenge phase\n"); - spin_lock(&ses->chan_lock); - is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); - spin_unlock(&ses->chan_lock); + spin_lock(&ses->ses_lock); + is_binding = (ses->ses_status == SES_GOOD); + spin_unlock(&ses->ses_lock); /* keep existing ses id and flags if binding */ if (!is_binding) { @@ -1610,9 +1615,9 @@ SMB2_sess_auth_rawntlmssp_authenticate(struct SMB2_sess_data *sess_data) rsp = (struct smb2_sess_setup_rsp *)sess_data->iov[0].iov_base; - spin_lock(&ses->chan_lock); - is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); - spin_unlock(&ses->chan_lock); + spin_lock(&ses->ses_lock); + is_binding = (ses->ses_status == SES_GOOD); + spin_unlock(&ses->ses_lock); /* keep existing ses id and flags if binding */ if (!is_binding) { diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index d827b7547ffa..790acf65a092 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -81,6 +81,7 @@ int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key) struct cifs_ses *ses = NULL; int i; int rc = 0; + bool is_binding = false; spin_lock(&cifs_tcp_ses_lock); @@ -97,9 +98,12 @@ int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key) goto out; found: + spin_lock(&ses->ses_lock); spin_lock(&ses->chan_lock); - if (cifs_chan_needs_reconnect(ses, server) && - !CIFS_ALL_CHANS_NEED_RECONNECT(ses)) { + + is_binding = (cifs_chan_needs_reconnect(ses, server) && + ses->ses_status == SES_GOOD); + if (is_binding) { /* * If we are in the process of binding a new channel * to an existing session, use the master connection @@ -107,6 +111,7 @@ int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key) */ memcpy(key, ses->smb3signingkey, SMB3_SIGN_KEY_SIZE); spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); goto out; } @@ -119,10 +124,12 @@ int smb2_get_sign_key(__u64 ses_id, struct TCP_Server_Info *server, u8 *key) if (chan->server == server) { memcpy(key, chan->signkey, SMB3_SIGN_KEY_SIZE); spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); goto out; } } spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); cifs_dbg(VFS, "%s: Could not find channel signing key for session 0x%llx\n", @@ -392,11 +399,15 @@ generate_smb3signingkey(struct cifs_ses *ses, bool is_binding = false; int chan_index = 0; + spin_lock(&ses->ses_lock); spin_lock(&ses->chan_lock); - is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT(ses); + is_binding = (cifs_chan_needs_reconnect(ses, server) && + ses->ses_status == SES_GOOD); + chan_index = cifs_ses_get_chan_index(ses, server); /* TODO: introduce ref counting for channels when the can be freed */ spin_unlock(&ses->chan_lock); + spin_unlock(&ses->ses_lock); /* * All channels use the same encryption/decryption keys but From patchwork Fri Mar 10 15:32:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F09C6FD1F for ; Fri, 10 Mar 2023 15:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234439AbjCJPpM (ORCPT ); Fri, 10 Mar 2023 10:45:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234520AbjCJPow (ORCPT ); Fri, 10 Mar 2023 10:44:52 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893D023A42 for ; Fri, 10 Mar 2023 07:33:15 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id i10so5950731plr.9 for ; Fri, 10 Mar 2023 07:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DITosQCzkfmbNoLNERKbLhYxwr5RKQKfmVmxTFr0qlM=; b=fhDXYkbPpR/WhvAzNKEiO57qyrraLBy9mzB2e+o2P/UEre/uejzNCcaYp+prqtV/g3 2TFafkL69ouhIlWrfoAiwYwyEbB9yG3YBPfrUU8yIPhhl6fXwKBaQ3c+pHEU9lO2OF4H J3GxU8zmJVHfCD/flI6kIp411x7MsoN4cxnK7sbzQCqs8cixtObNXikJRmaDM8N65GQE PTOAhlja/ljduLAzJ6lM78CfEeXwdxr5PqxjN79gP3lAQMAYJ0WQZcWK/J60TrZwsttr 5lsu7t5eT8eYPkYU4cil+4KcDMAShwycW31ooXCf67Q+l87RdKOb4OHV/Tn4RnI3DV1U ebAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DITosQCzkfmbNoLNERKbLhYxwr5RKQKfmVmxTFr0qlM=; b=pAt8jGiZz7/j90j7TQ8/AhbqyZrexjD67I07p6J8Ddj+UHtOXcK92mEm6xfBslzC2W uuvTHgXe6ry0V/sv1UmzvHIRL6HnDFvmg1/w0l+VwXKIrPJ4wVlF6ENviZeamdyi6+gM eM8aRQSBNVOlGLkpIBsDloGZ3hloYbEDV6121rkpoQSLvR7RIofGcXVlkVcb1HbLKogV M27VH9z9UfigkyklwqfKkHI6/HSH+c7/seTdnv18EZRuhxOrznH+qGEvErFugrg3CVM3 /yOtpRvMwXLN42HRySsMhk4HF8XzJLf7VPxO8x+Dj62blS2JVjh9pOXRI7E0Voo0WnyA 7Kgg== X-Gm-Message-State: AO0yUKXHQifJjc/myOQ9ei560wOK4JFW/0SB64bMxj7x4gDRsALsOmdD vqyfOT9PE1NIcL0IpURCgGOyDHul9+s4pstWeQs= X-Google-Smtp-Source: AK7set96CyWwwMK9fefl4vMhy7HpIArjbgr5UNnieVgY12d41AD+AC6n6XtqEOa7rhFoUx9M+amrig== X-Received: by 2002:a17:90b:3885:b0:234:409:9754 with SMTP id mu5-20020a17090b388500b0023404099754mr26129378pjb.45.1678462394723; Fri, 10 Mar 2023 07:33:14 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:14 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 04/11] cifs: serialize channel reconnects Date: Fri, 10 Mar 2023 15:32:03 +0000 Message-Id: <20230310153211.10982-4-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Parallel session reconnects are prone to race conditions that are difficult to avoid cleanly. The changes so far do ensure that parallel reconnects eventually go through. But that can take multiple session setups on the same channel. Avoiding that by serializing the session setups on parallel channels. In doing so, we should avoid such issues. Signed-off-by: Shyam Prasad N --- fs/cifs/connect.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 7b103f69432e..4ea1e51c3fa5 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -222,6 +222,11 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, else cifs_chan_set_need_reconnect(ses, server); + cifs_dbg(FYI, "%s: channel connect bitmaps: 0x%lx 0x%lx\n", + __func__, + ses->chans_need_reconnect, + ses->chans_in_reconnect); + /* If all channels need reconnect, then tcon needs reconnect */ if (!mark_smb_session && !CIFS_ALL_CHANS_NEED_RECONNECT(ses)) { spin_unlock(&ses->chan_lock); @@ -3744,6 +3749,11 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, retries = 5; spin_lock(&ses->ses_lock); + cifs_dbg(FYI, "%s: channel connect bitmaps: 0x%lx 0x%lx\n", + __func__, + ses->chans_need_reconnect, + ses->chans_in_reconnect); + if (ses->ses_status != SES_GOOD && ses->ses_status != SES_NEW && ses->ses_status != SES_NEED_RECON) { @@ -3762,11 +3772,11 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, } /* another process is in the processs of sess setup */ - while (cifs_chan_in_reconnect(ses, server)) { + while (ses->chans_in_reconnect) { spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); rc = wait_event_interruptible_timeout(ses->reconnect_q, - (!cifs_chan_in_reconnect(ses, server)), + (!ses->chans_in_reconnect), HZ); if (rc < 0) { cifs_dbg(FYI, "%s: aborting sess setup due to a received signal by the process\n", @@ -3776,8 +3786,8 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, spin_lock(&ses->ses_lock); spin_lock(&ses->chan_lock); - /* are we still trying to reconnect? */ - if (!cifs_chan_in_reconnect(ses, server)) { + /* did the bitmask change? */ + if (!ses->chans_in_reconnect) { spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); goto check_again; From patchwork Fri Mar 10 15:32:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 564FCC74A44 for ; Fri, 10 Mar 2023 15:45:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234445AbjCJPpN (ORCPT ); Fri, 10 Mar 2023 10:45:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234524AbjCJPow (ORCPT ); Fri, 10 Mar 2023 10:44:52 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BFAD49FD for ; Fri, 10 Mar 2023 07:33:21 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id qa18-20020a17090b4fd200b0023750b675f5so10213311pjb.3 for ; Fri, 10 Mar 2023 07:33:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RycRAdB61mHxmeQ1gcw+uEuoua4OCSgZ9Rhw/hIQ4Js=; b=cCd4+dFqYhleDHtP8ehfvqDNAlv6A9p8q7i2bTT5kae9tz1lxq5F4Rc6iBPQn4aNfW YT37QaozMdqYzUt0zy7NEp98Ku81tDgYtoZ8iLt3F+C0wKFn1acEwrQ/njBdeeIWyA1z ZFSi2jsRPgYlFn/LPwyWOUnEB+9ceXOanet/79q8BP0aIuwymxMBAtgf9aVAsZeeXmX7 6R895h4hW4qDm24D99sDXOhvEN26s9fxd92weKOJa+FVJG425pc0rl5+10qKDfioHlvR A2gZapCkrI6dreIkZYpMgbMo3mhQvxd7XxrF4RArvUFgNBy/HJ5fWsOn24celQLWwLAk B7dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RycRAdB61mHxmeQ1gcw+uEuoua4OCSgZ9Rhw/hIQ4Js=; b=pB0ZC004ilv3cyENqUhYy9JXpwHyFUp+B44tyQfI+krwTGXhBOe6pqgWjgP/p+2zbV 62miWKgGiQONJ4GqubyI9VJQc47WA/DBaT1SaJkR0rDpbW4p0Y6MVfqooHRppPYgcEuk DJ0QbmQl3sYLXV2K+tSIvJ6K0+H+n2ahdBz8qjc3Sj771Oux8vFJH8TtOXzQf4lQ0uEE fp6S4oTNS912Rlv95FxkJHmxe+/Fkm+oYywaUV3WxmAxsHsQYCM9FCt6tM0gl28RLMX1 b3igzvuyx2LhkJ1ISBkktGmWP8uw9nmyRcS7DCXfMdk09Y+imyUJmau2bJvafj9auPWU 550Q== X-Gm-Message-State: AO0yUKU0LcZIQRhLCRqxSTnOEua2OCudJ8ZkFCRLI2ib7ECFpKCGy0AQ S6dbgpnD69Oe7CzdP+YXk4g= X-Google-Smtp-Source: AK7set8cFtNsG+2AWu04cWdqb5vPF+nZJqKb/rOWyr60aQZz9kgHd0YzG/H84CE2A8Blj+x7dFjmLQ== X-Received: by 2002:a17:90a:19c8:b0:234:236f:1a8d with SMTP id 8-20020a17090a19c800b00234236f1a8dmr26266373pjj.14.1678462400796; Fri, 10 Mar 2023 07:33:20 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:20 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 05/11] cifs: lock chan_lock outside match_session Date: Fri, 10 Mar 2023 15:32:04 +0000 Message-Id: <20230310153211.10982-5-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Coverity had rightly indicated a possible deadlock due to chan_lock being done inside match_session. All callers of match_* functions should pick up the necessary locks and call them. Signed-off-by: Shyam Prasad N --- fs/cifs/connect.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 4ea1e51c3fa5..fb9d9994df09 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1735,7 +1735,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx, return ERR_PTR(rc); } -/* this function must be called with ses_lock held */ +/* this function must be called with ses_lock and chan_lock held */ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx) { if (ctx->sectype != Unspecified && @@ -1746,12 +1746,8 @@ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx) * If an existing session is limited to less channels than * requested, it should not be reused */ - spin_lock(&ses->chan_lock); - if (ses->chan_max < ctx->max_channels) { - spin_unlock(&ses->chan_lock); + if (ses->chan_max < ctx->max_channels) return 0; - } - spin_unlock(&ses->chan_lock); switch (ses->sectype) { case Kerberos: @@ -1879,10 +1875,13 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) spin_unlock(&ses->ses_lock); continue; } + spin_lock(&ses->chan_lock); if (!match_session(ses, ctx)) { + spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); continue; } + spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); ++ses->ses_count; @@ -2706,6 +2705,7 @@ cifs_match_super(struct super_block *sb, void *data) spin_lock(&tcp_srv->srv_lock); spin_lock(&ses->ses_lock); + spin_lock(&ses->chan_lock); spin_lock(&tcon->tc_lock); if (!match_server(tcp_srv, ctx, dfs_super_cmp) || !match_session(ses, ctx) || @@ -2718,6 +2718,7 @@ cifs_match_super(struct super_block *sb, void *data) rc = compare_mount_options(sb, mnt_data); out: spin_unlock(&tcon->tc_lock); + spin_unlock(&ses->chan_lock); spin_unlock(&ses->ses_lock); spin_unlock(&tcp_srv->srv_lock); From patchwork Fri Mar 10 15:32:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76660C6FA99 for ; Fri, 10 Mar 2023 15:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234276AbjCJPpS (ORCPT ); Fri, 10 Mar 2023 10:45:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbjCJPoy (ORCPT ); Fri, 10 Mar 2023 10:44:54 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBAAB4345B for ; Fri, 10 Mar 2023 07:33:25 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id 6-20020a17090a190600b00237c5b6ecd7so10200052pjg.4 for ; Fri, 10 Mar 2023 07:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sSqNTtmdDaJXLaSPQY1MYiqxFRrKDF/9afPRapSdy7o=; b=cEWykPoqM6i4u9YOniLc8nsUfEaU+l+ZQlrFfq3cPdziCg6+ilt3gSwHx6VNVnZbfZ 19PmdiRPPekfcIgevv+zpw0sL5q4rma4BaiViLfSAkUKti42wCMNtnnDwDywZ0QEaPg7 e2an8pW8LlcD4pLs8A83KEHvoGxKUPRoJr7RzZ0Fi98G+8JAI7lhwhRYEtAqEjtXrZuk s5CmxqeKrpx/71tfJeoz+UkXAPxpnTRknXjNu/ov12bj3/1Nzi+7FiQvo0Ep00wM5h8X OibthR2vtayno89aABZDJChHVtBZ/DGyWw8gayvtNyJb4P2tm7bJjXXkipEjYAwKYfJY /4dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sSqNTtmdDaJXLaSPQY1MYiqxFRrKDF/9afPRapSdy7o=; b=Tt1bUfCm7Sv8wCP4wkSHACOrPenFx8kHgo/JuYsrLj+5tmzsimslMgjlkU35K1DA90 8xFvsjGhRiKE9Ow4CIF3SUSYhP+6vwJYdwkjkGQZGxGDqG5ki4qIrEB9llqR1Op/BaOV Vu7o0KObRYac3TINixD7EMES+rfgG+AfH8bm2DVA/X4rYBmKkqE+TbdlYHOR5v0CJXJ2 gLKyifISd5vf/BThscEelU2J58/5uHiRilqTybWg5kcS5RIcKL5McFogy2wIodFKAZl6 O7xysXQ/NCfnT30ux8E1KPeBCjqM1jqXwaUUSci4+WCu1XOw1iUEdEWAvjubzLLlLg9I nzvQ== X-Gm-Message-State: AO0yUKXFKtgcuBT6GXZHvXMExkYJSALZ3NnlIjpt9Pt2u5i4n14+zpHc 342NDIxmrwl9nMZbl7Xa2d4utDXOrrTPY5w9z94= X-Google-Smtp-Source: AK7set8YEaP9BL/MwYewiHkr+Da8SmmNeH93qgD6FwWJuxoc1C0Lv/LjM2vhMfv5rt49clmAlptJvw== X-Received: by 2002:a17:90b:4f4a:b0:237:1f17:6842 with SMTP id pj10-20020a17090b4f4a00b002371f176842mr27320541pjb.10.1678462405218; Fri, 10 Mar 2023 07:33:25 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:24 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 06/11] cifs: fix sockaddr comparison in iface_cmp Date: Fri, 10 Mar 2023 15:32:05 +0000 Message-Id: <20230310153211.10982-6-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org iface_cmp used to simply do a memcmp of the two provided struct sockaddrs. The comparison needs to do more based on the address family. Similar logic was already present in cifs_match_ipaddr. Doing something similar now. Signed-off-by: Shyam Prasad N --- fs/cifs/cifsglob.h | 37 --------------------------------- fs/cifs/cifsproto.h | 1 + fs/cifs/connect.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ fs/cifs/smb2ops.c | 37 +++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 37 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 81ff13e41f97..a11e7b10f607 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -965,43 +965,6 @@ release_iface(struct kref *ref) kfree(iface); } -/* - * compare two interfaces a and b - * return 0 if everything matches. - * return 1 if a has higher link speed, or rdma capable, or rss capable - * return -1 otherwise. - */ -static inline int -iface_cmp(struct cifs_server_iface *a, struct cifs_server_iface *b) -{ - int cmp_ret = 0; - - WARN_ON(!a || !b); - if (a->speed == b->speed) { - if (a->rdma_capable == b->rdma_capable) { - if (a->rss_capable == b->rss_capable) { - cmp_ret = memcmp(&a->sockaddr, &b->sockaddr, - sizeof(a->sockaddr)); - if (!cmp_ret) - return 0; - else if (cmp_ret > 0) - return 1; - else - return -1; - } else if (a->rss_capable > b->rss_capable) - return 1; - else - return -1; - } else if (a->rdma_capable > b->rdma_capable) - return 1; - else - return -1; - } else if (a->speed > b->speed) - return 1; - else - return -1; -} - struct cifs_chan { struct TCP_Server_Info *server; struct cifs_server_iface *iface; /* interface in use */ diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index e2eff66eefab..30fd81268eb7 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -86,6 +86,7 @@ extern int cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid); extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx); extern int smb3_parse_opt(const char *options, const char *key, char **val); +extern int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs); extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs); extern int cifs_discard_remaining_data(struct TCP_Server_Info *server); extern int cifs_call_async(struct TCP_Server_Info *server, diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index fb9d9994df09..b9af60417194 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1289,6 +1289,56 @@ cifs_demultiplex_thread(void *p) module_put_and_kthread_exit(0); } +int +cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs) +{ + switch (srcaddr->sa_family) { + case AF_UNSPEC: + switch (rhs->sa_family) { + case AF_UNSPEC: + return 0; + case AF_INET: + case AF_INET6: + return 1; + default: + return -1; + } + case AF_INET: { + switch (rhs->sa_family) { + case AF_UNSPEC: + return -1; + case AF_INET: + struct sockaddr_in *saddr4 = (struct sockaddr_in *)srcaddr; + struct sockaddr_in *vaddr4 = (struct sockaddr_in *)rhs; + return memcmp(&saddr4->sin_addr.s_addr, + &vaddr4->sin_addr.s_addr, + sizeof(struct sockaddr_in)); + case AF_INET6: + return 1; + default: + return -1; + } + } + case AF_INET6: { + switch (rhs->sa_family) { + case AF_UNSPEC: + case AF_INET: + return -1; + case AF_INET6: + struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)srcaddr; + struct sockaddr_in6 *vaddr6 = (struct sockaddr_in6 *)rhs; + return memcmp(&saddr6->sin6_addr, + &vaddr6->sin6_addr, + sizeof(struct sockaddr_in6)); + default: + return -1; + } + } + default: + return -1; /* don't expect to be here */ + } +} + /* * Returns true if srcaddr isn't specified and rhs isn't specified, or * if srcaddr is specified and matches the IP address of the rhs argument diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 6dfb865ee9d7..0627d5e38236 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -510,6 +510,43 @@ smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx) return rsize; } +/* + * compare two interfaces a and b + * return 0 if everything matches. + * return 1 if a is rdma capable, or rss capable, or has higher link speed + * return -1 otherwise. + */ +static int +iface_cmp(struct cifs_server_iface *a, struct cifs_server_iface *b) +{ + int cmp_ret = 0; + + WARN_ON(!a || !b); + if (a->rdma_capable == b->rdma_capable) { + if (a->rss_capable == b->rss_capable) { + if (a->speed == b->speed) { + cmp_ret = cifs_ipaddr_cmp((struct sockaddr *) &a->sockaddr, + (struct sockaddr *) &b->sockaddr); + if (!cmp_ret) + return 0; + else if (cmp_ret > 0) + return 1; + else + return -1; + } else if (a->speed > b->speed) + return 1; + else + return -1; + } else if (a->rss_capable > b->rss_capable) + return 1; + else + return -1; + } else if (a->rdma_capable > b->rdma_capable) + return 1; + else + return -1; +} + static int parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf, size_t buf_len, struct cifs_ses *ses, bool in_mount) From patchwork Fri Mar 10 15:32:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD853C64EC4 for ; Fri, 10 Mar 2023 15:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231627AbjCJPpZ (ORCPT ); Fri, 10 Mar 2023 10:45:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbjCJPpC (ORCPT ); Fri, 10 Mar 2023 10:45:02 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0A525CED8 for ; Fri, 10 Mar 2023 07:33:37 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id y11so5991293plg.1 for ; Fri, 10 Mar 2023 07:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+6vTuiCZpQhEVKc5XBHRnV2OTCH3JI7IcoWG9ZhjUWk=; b=YauIzQiB9w9BWFpMYjZrmcTwBhWBxYEir7qi7Fl82ZA6NlyPq6g/t9MtWCdbsLDGSu 3M+Hn5ikFVTh7UK/uiRdq7XLpiWHKKo53Fytk4JeKBhRosiye0y669HEkDty6rutWMx7 Eqr6AFbm1Czom0YnWbKMU3LYpChegPuOkrtGurWvrLWBpP+1ty4ZIKi9XyYBcNYMVIeP wkWi1zvPMtPlXnfaj7QSq53Qa0Z0HZd4DFxe+AJK3eVN+DRwrvCksugSkX56qlFWM/I2 H0O8pZzeeHxyO36Y86beM2M9lOvc2YHFKbfLisRgXDdq3K6ESuNU5zkduliJiwzSm3HF bsCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+6vTuiCZpQhEVKc5XBHRnV2OTCH3JI7IcoWG9ZhjUWk=; b=cKzmwxQ9nH9RJciEIfX4BYNek74i8QkmHL2Zd+dmyqSIPfw4Bj46DOCNCvXJ5UxPTL He7TrUGxR03lJQajtiD6F8jEWDRl9sz7oHH6PT3YyALOruoCowXLgbroYJS4j1G2KAp+ PwXLyYbivAJ+ozP6URW1CDAfktrkP6awQpiEPzitwQCdp25W8CtH/5uRFI/69itk406t nLn3P26X8S2BCQPs4ueAmvGqfF0BIik9cIg+8NneYO0KfntPkW9xcAuFo2tZ0gI44We3 ZZSJdfYyL5nK2Vq+Be+TRBAI993kN3zWBnZtocU+gVvIq+rhuEm0x6BTAaBIYa2Kh8+K OZAQ== X-Gm-Message-State: AO0yUKUVqfkoVTW2VwrOJSlbeBloasQi6lyxKV48Mpj6A1SVsu0gVn8/ 2kEG8sV/UaWHY3Ic2dZkXpE= X-Google-Smtp-Source: AK7set8ocGNtxevuwIaEb7sWALbptS179xQc0QAfWreVRe6Dcyeij/PoTAyRw+DS/Scy7aWanOwmkw== X-Received: by 2002:a17:90b:1c05:b0:23a:ccb4:64de with SMTP id oc5-20020a17090b1c0500b0023accb464demr2361716pjb.6.1678462417058; Fri, 10 Mar 2023 07:33:37 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:36 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 07/11] cifs: do not poll server interfaces too regularly Date: Fri, 10 Mar 2023 15:32:06 +0000 Message-Id: <20230310153211.10982-7-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org We have the server interface list hanging off the tcon structure today for reasons unknown. So each tcon which is connected to a file server can query them separately, which is really unnecessary. To avoid this, in the query function, we will check the time of last update of the interface list, and avoid querying the server if it is within a certain range. Signed-off-by: Shyam Prasad N --- fs/cifs/smb2ops.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 0627d5e38236..c342a1db33ed 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -567,6 +567,14 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf, p = buf; spin_lock(&ses->iface_lock); + /* do not query too frequently, this time with lock held */ + if (ses->iface_last_update && + time_before(jiffies, ses->iface_last_update + + (SMB_INTERFACE_POLL_INTERVAL * HZ))) { + spin_unlock(&ses->iface_lock); + return 0; + } + /* * Go through iface_list and do kref_put to remove * any unused ifaces. ifaces in use will be removed @@ -733,6 +741,12 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_ struct network_interface_info_ioctl_rsp *out_buf = NULL; struct cifs_ses *ses = tcon->ses; + /* do not query too frequently */ + if (ses->iface_last_update && + time_before(jiffies, ses->iface_last_update + + (SMB_INTERFACE_POLL_INTERVAL * HZ))) + return 0; + rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID, FSCTL_QUERY_NETWORK_INTERFACE_INFO, NULL /* no data input */, 0 /* no data input */, From patchwork Fri Mar 10 15:32:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7DE4C64EC4 for ; Fri, 10 Mar 2023 15:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234160AbjCJPp2 (ORCPT ); Fri, 10 Mar 2023 10:45:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234229AbjCJPpH (ORCPT ); Fri, 10 Mar 2023 10:45:07 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFF89E192A for ; Fri, 10 Mar 2023 07:33:42 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id x34so5715492pjj.0 for ; Fri, 10 Mar 2023 07:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xPRsolOFcQ08OS615HvQ6WjsCmMIeIIEZEMJU0TjORE=; b=V9O26sEI7vTrPOSKgwfOzOXwL4kzSHFt8q5kob61NgRy2wWeQzcljH95v+/C4/wF2I AWuD1/K1+KPfR627Fa4YCqOJUgFjOCTs6lnz8DI6dwdV+1shZaYLn2XX0/dfGXLPbo9p Wkg2uTAzp4tFwGPU9AT2c7O+E0HJpm8Y9Ieo5wLk5jfanaFqNE5ATRAjBpVCiY7doszB VuCkVj9Cbq9dRUR74BBJlbC+azXFX/iAp31AXU0PHVvvEO0SmBbHmTfsbu7NE3Wj07iE HKeXFPJ06UambVM/Cv4DCSsyQzU/kH72sF8+HC8WFA8DoaP8ijUTZjvXECJ00JVeWGOD D1wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462422; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xPRsolOFcQ08OS615HvQ6WjsCmMIeIIEZEMJU0TjORE=; b=0hEBcQLq3UqaDzm/oQKVmrv9h05Wyk9YokgBxd6WzpMCIrYf8/x64M4DY3K6kgsFAJ LK3N2vokvwCbK+/dvDB73a3nmYThPbtodXb/wrlHvJLcy+mCIOsTZaNXp2l8RcnfirOI lcy7FEO0LEir3WaLsTuMdClZZH2sr6CMPOe98aAWbSlEbCHiwtmHVUmra5/wn02rjuTv C7kK3e9SzoAxPFvYObzDlh/ypvsHYSOit7Pt23Mf6TBP8UXzxfp41FrKgOsCMhDxGR2d JWM+oVaAVeIW+V9d5/WkSp2xdWHPSmvIueMH3hvvMDFUPflEE/CLF2OG81kV+EQ3/Y4q 9hXw== X-Gm-Message-State: AO0yUKUYw1NCiL8fIWl5mGxTgTk2EL/81/QZmAhGHSkH+tEDjHIuwKaN Wlgt+WytSuXEMRzRC5XMemA= X-Google-Smtp-Source: AK7set/eAHQM20J6VRUzTNtb4AYVqfn9InI0K5xhJwCgNZkNuryyFQS7ThCEav0daC7eP3WmJfHzPA== X-Received: by 2002:a17:90b:3882:b0:22c:1e06:26ec with SMTP id mu2-20020a17090b388200b0022c1e0626ecmr26269154pjb.44.1678462421696; Fri, 10 Mar 2023 07:33:41 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:41 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 08/11] cifs: distribute channels across interfaces based on speed Date: Fri, 10 Mar 2023 15:32:07 +0000 Message-Id: <20230310153211.10982-8-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Today, if the server interfaces RSS capable, we simply choose the fastest interface to setup a channel. This is not a scalable approach, and does not make a lot of attempt to distribute the connections. This change does a weighted distribution of channels across all the available server interfaces, where the weight is a function of the advertised interface speed. Also make sure that we don't mix rdma and non-rdma for channels. Signed-off-by: Shyam Prasad N --- fs/cifs/cifs_debug.c | 16 +++++++++++ fs/cifs/cifsglob.h | 2 ++ fs/cifs/sess.c | 67 +++++++++++++++++++++++++++++++++++--------- 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 4391c7aac3cb..cee3af02e2c3 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -219,6 +219,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) struct cifs_ses *ses; struct cifs_tcon *tcon; struct cifs_server_iface *iface; + size_t iface_weight = 0, iface_min_speed = 0; + struct cifs_server_iface *last_iface = NULL; int c, i, j; seq_puts(m, @@ -465,11 +467,25 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) "\tLast updated: %lu seconds ago", ses->iface_count, (jiffies - ses->iface_last_update) / HZ); + + last_iface = list_last_entry(&ses->iface_list, + struct cifs_server_iface, + iface_head); + iface_min_speed = last_iface->speed; + j = 0; list_for_each_entry(iface, &ses->iface_list, iface_head) { seq_printf(m, "\n\t%d)", ++j); cifs_dump_iface(m, iface); + + iface_weight = iface->speed / iface_min_speed; + seq_printf(m, "\t\tWeight (cur,total): (%zu,%zu)" + "\n\t\tAllocated channels: %u\n", + iface->weight_fulfilled, + iface_weight, + iface->num_channels); + if (is_ses_using_iface(ses, iface)) seq_puts(m, "\t\t[CONNECTED]\n"); } diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index a11e7b10f607..e3ba5c979832 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -948,6 +948,8 @@ struct cifs_server_iface { struct list_head iface_head; struct kref refcount; size_t speed; + size_t weight_fulfilled; + unsigned int num_channels; unsigned int rdma_capable : 1; unsigned int rss_capable : 1; unsigned int is_active : 1; /* unset if non existent */ diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index b8bfebe4498e..78a7cfa75e91 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -167,7 +167,9 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) int left; int rc = 0; int tries = 0; + size_t iface_weight = 0, iface_min_speed = 0; struct cifs_server_iface *iface = NULL, *niface = NULL; + struct cifs_server_iface *last_iface = NULL; spin_lock(&ses->chan_lock); @@ -196,21 +198,11 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) } spin_unlock(&ses->chan_lock); - /* - * Keep connecting to same, fastest, iface for all channels as - * long as its RSS. Try next fastest one if not RSS or channel - * creation fails. - */ - spin_lock(&ses->iface_lock); - iface = list_first_entry(&ses->iface_list, struct cifs_server_iface, - iface_head); - spin_unlock(&ses->iface_lock); - while (left > 0) { tries++; if (tries > 3*ses->chan_max) { - cifs_dbg(FYI, "too many channel open attempts (%d channels left to open)\n", + cifs_dbg(VFS, "too many channel open attempts (%d channels left to open)\n", left); break; } @@ -218,17 +210,34 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) spin_lock(&ses->iface_lock); if (!ses->iface_count) { spin_unlock(&ses->iface_lock); + cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname); break; } + if (!iface) + iface = list_first_entry(&ses->iface_list, struct cifs_server_iface, + iface_head); + last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface, + iface_head); + iface_min_speed = last_iface->speed; + list_for_each_entry_safe_from(iface, niface, &ses->iface_list, iface_head) { + /* do not mix rdma and non-rdma interfaces */ + if (iface->rdma_capable != ses->server->rdma) + continue; + /* skip ifaces that are unusable */ if (!iface->is_active || (is_ses_using_iface(ses, iface) && - !iface->rss_capable)) { + !iface->rss_capable)) + continue; + + /* check if we already allocated enough channels */ + iface_weight = iface->speed / iface_min_speed; + + if (iface->weight_fulfilled >= iface_weight) continue; - } /* take ref before unlock */ kref_get(&iface->refcount); @@ -245,10 +254,17 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) continue; } - cifs_dbg(FYI, "successfully opened new channel on iface:%pIS\n", + iface->num_channels++; + iface->weight_fulfilled++; + cifs_dbg(VFS, "successfully opened new channel on iface:%pIS\n", &iface->sockaddr); break; } + + /* reached end of list. reset weight_fulfilled */ + if (list_entry_is_head(iface, &ses->iface_list, iface_head)) + list_for_each_entry(iface, &ses->iface_list, iface_head) + iface->weight_fulfilled = 0; spin_unlock(&ses->iface_lock); left--; @@ -267,8 +283,10 @@ int cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) { unsigned int chan_index; + size_t iface_weight = 0, iface_min_speed = 0; struct cifs_server_iface *iface = NULL; struct cifs_server_iface *old_iface = NULL; + struct cifs_server_iface *last_iface = NULL; int rc = 0; spin_lock(&ses->chan_lock); @@ -288,13 +306,34 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) spin_unlock(&ses->chan_lock); spin_lock(&ses->iface_lock); + if (!ses->iface_count) { + spin_unlock(&ses->iface_lock); + cifs_dbg(VFS, "server %s does not advertise interfaces\n", ses->server->hostname); + return 0; + } + + last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface, + iface_head); + iface_min_speed = last_iface->speed; + /* then look for a new one */ list_for_each_entry(iface, &ses->iface_list, iface_head) { + /* do not mix rdma and non-rdma interfaces */ + if (iface->rdma_capable != server->rdma) + continue; + if (!iface->is_active || (is_ses_using_iface(ses, iface) && !iface->rss_capable)) { continue; } + + /* check if we already allocated enough channels */ + iface_weight = iface->speed / iface_min_speed; + + if (iface->weight_fulfilled >= iface_weight) + continue; + kref_get(&iface->refcount); break; } From patchwork Fri Mar 10 15:32:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41956C64EC4 for ; Fri, 10 Mar 2023 15:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbjCJPpe (ORCPT ); Fri, 10 Mar 2023 10:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234442AbjCJPpN (ORCPT ); Fri, 10 Mar 2023 10:45:13 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E78DD366 for ; Fri, 10 Mar 2023 07:33:48 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id p6so6020758plf.0 for ; Fri, 10 Mar 2023 07:33:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QN0KP2zyMGxDCWsrNdRZt2+TYPTgrOVoV6GG9EHRPOA=; b=Ek6w2SlPTnXAz+vr7dOjxPvdfME/eQE7vOjIL8rw9mUEguduBvVna2Wi9RitUMuJ8o 4FiMwLrZD4ZWBUIsZuyCgVSzFrfB3Fo9TIzJ8x9inmbzJHXyZgsQJYA02L5oONNvmOjU GZPujdS1VE4BmRVRml000NQ1A4Q7BGa87ITt7GYOmeXsxLQdZIxJKYVa1dVtqit8vULA IgQjPQ8OYGiuXuYMjDoCSBVw8DDtkOo4cLJMeVDR9QRBxyOvGbq0mz7HnqU28JDOKfiC XXJSlcyCyk9Fy8QvsFYTNzfRdmkNDLUDljvGUTuBx2CopLD8O8U4HAHQ6YFECuYQUCtH asCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QN0KP2zyMGxDCWsrNdRZt2+TYPTgrOVoV6GG9EHRPOA=; b=hpQQ9gtczwAfJeRPnngARVbW6+Lq5Vx7p9LAxFJkeRulyZtcPTqs1wxybGl+cL1nSz HWX7h1XkdEeHRBGqgUI7LDvtBnzPwQ0uj+ILYou1Mzg/bnudpfQlWBhT8SeHOYdMO0Co fflKICOJThabHiVTowxbyQDjCw5JNBZQnrFuwU35apdcX2bBSVGNmCXv7Nnl7aeimfj7 FEmQMsmDYd3Ik9bNUaqzgczuo6wuaxuz8AXHm+EJYJ6HrsOZ3twwk4T0plebn/uMUsFF Rro4Sv5afwCOI8FHOMkc5TjU1A708MoObpKRn5aEG63ItA8TEYDq/uqdOsrBqbMZa9Sv xBhQ== X-Gm-Message-State: AO0yUKXSYyVLqnqMD8MSYIRRVwLRPrtk47AiaXhZ0EwRgc1b+By2FWvF cYFn8jcYohDVkr/8aVDmtKw= X-Google-Smtp-Source: AK7set/A6JPZUWACvdLNibROURBMOOgYwOhTAktb7wwypeTsoaKSnACALp4oZlTHf/ejPIe/IvFLVQ== X-Received: by 2002:a17:90b:1e0f:b0:237:c209:5b14 with SMTP id pg15-20020a17090b1e0f00b00237c2095b14mr5677989pjb.22.1678462427695; Fri, 10 Mar 2023 07:33:47 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:47 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 09/11] cifs: account for primary channel in the interface list Date: Fri, 10 Mar 2023 15:32:08 +0000 Message-Id: <20230310153211.10982-9-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org The refcounting of server interfaces should account for the primary channel too. Although this is not strictly necessary, doing so will account for the primary channel in DebugData. Signed-off-by: Shyam Prasad N --- fs/cifs/sess.c | 40 +++++++++++++++++++++++++++++++++++----- fs/cifs/smb2ops.c | 6 ++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 78a7cfa75e91..9b51b2309e9c 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -291,11 +291,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) spin_lock(&ses->chan_lock); chan_index = cifs_ses_get_chan_index(ses, server); - if (!chan_index) { - spin_unlock(&ses->chan_lock); - return 0; - } - if (ses->chans[chan_index].iface) { old_iface = ses->chans[chan_index].iface; if (old_iface->is_active) { @@ -318,6 +313,16 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) /* then look for a new one */ list_for_each_entry(iface, &ses->iface_list, iface_head) { + if (!chan_index) { + /* if we're trying to get the updated iface for primary channel */ + if (!cifs_match_ipaddr((struct sockaddr *) &server->dstaddr, + (struct sockaddr *) &iface->sockaddr)) + continue; + + kref_get(&iface->refcount); + break; + } + /* do not mix rdma and non-rdma interfaces */ if (iface->rdma_capable != server->rdma) continue; @@ -344,16 +349,41 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) cifs_dbg(FYI, "unable to find a suitable iface\n"); } + if (!chan_index && !iface) { + cifs_dbg(VFS, "unable to get the interface matching: %pIS\n", + &server->dstaddr); + spin_unlock(&ses->iface_lock); + return 0; + } + /* now drop the ref to the current iface */ if (old_iface && iface) { cifs_dbg(FYI, "replacing iface: %pIS with %pIS\n", &old_iface->sockaddr, &iface->sockaddr); + + old_iface->num_channels--; + if (--old_iface->weight_fulfilled < 0) + old_iface->weight_fulfilled = 0; + iface->num_channels++; + iface->weight_fulfilled++; + kref_put(&old_iface->refcount, release_iface); } else if (old_iface) { cifs_dbg(FYI, "releasing ref to iface: %pIS\n", &old_iface->sockaddr); + + old_iface->num_channels--; + if (--old_iface->weight_fulfilled < 0) + old_iface->weight_fulfilled = 0; + kref_put(&old_iface->refcount, release_iface); + } else if (!chan_index) { + /* special case: update interface for primary channel */ + cifs_dbg(FYI, "referencing primary channel iface: %pIS\n", + &iface->sockaddr); + iface->num_channels++; + iface->weight_fulfilled++; } else { WARN_ON(!iface); cifs_dbg(FYI, "adding new iface: %pIS\n", &iface->sockaddr); diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index c342a1db33ed..a5e53cb1ac49 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -740,6 +740,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_ unsigned int ret_data_len = 0; struct network_interface_info_ioctl_rsp *out_buf = NULL; struct cifs_ses *ses = tcon->ses; + struct TCP_Server_Info *pserver; /* do not query too frequently */ if (ses->iface_last_update && @@ -764,6 +765,11 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_ if (rc) goto out; + /* check if iface is still active */ + pserver = ses->chans[0].server; + if (pserver && !cifs_chan_is_iface_active(ses, pserver)) + cifs_chan_update_iface(ses, pserver); + out: kfree(out_buf); return rc; From patchwork Fri Mar 10 15:32:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA85EC6FA99 for ; Fri, 10 Mar 2023 15:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231233AbjCJPpm (ORCPT ); Fri, 10 Mar 2023 10:45:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbjCJPpW (ORCPT ); Fri, 10 Mar 2023 10:45:22 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40B835A1A6 for ; Fri, 10 Mar 2023 07:33:56 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id ky4so5992152plb.3 for ; Fri, 10 Mar 2023 07:33:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nL29z0D9lgUhrq6VnTtNAoUi5dj6i6sq+n1nV6q7Au4=; b=pkoWJhaj/ZFNvAqFGniXp6aKpjrUrqK00H6e/i15/D9huHk0Pqd50ZUxEOI2CeiTB6 mQlPIDotP8U+2RZaZBhGLywuK4PAa4eSsf/5iNwactQdmD+F5Wgbe4GqbzQWscj/o9sG oqEu6YCixRCrtNDkXknxa4NTjm4PTm4jynojyQ2kCwurcBzKzNdAyPJ8obdldvZEkC3T 1ucpeH3SkLnBe89JNFkAfjL9S8dkgZ/Ji4k/CAbLjJvNGE8Plgb7zuwlfryXLXGL+n8p G3W3RyeKrw1zxmIvHqpgNSWtZzHiwoCjNoLxKfrRAET/dQdHvGUfoepn5Ysgz0VgB24v RgeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462435; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nL29z0D9lgUhrq6VnTtNAoUi5dj6i6sq+n1nV6q7Au4=; b=ODHQhD7aBZpT1AF0pORon60w/O66Thki0itwFDhCu837nCl5htlNMATGE68GHpNA6t DuZggc6N3HkIWHNupfVqrZzARxB1UKzA7+L4AqM85xDI+AA5m8rSK1xg1w3+tsjxrx+W P4iA0oaE46JJ29ZY5rUCZBbokJD8WLwZ/mwIEW0bkCXmbbImZysCZ/bX5mcHPHm45dO6 jSn75s/TM2kF1R5UZTzGn6d++Sy2o4BG0LNRLT9vecciMnGHJrUJSK32H0HjPcd8LrbI tqrekqYLE+LbdidF3GxK95UoGZwmbePj6ztf+iO8WagKjCqtsmkx6uItE1fyyaAwQdd0 bbhA== X-Gm-Message-State: AO0yUKWSCd83tNllTNMHBOCHBmEqAfLZS7bu0Sx0MC3b5Q5MDikXjfPR LPZ7qkYLUgOqvYlFaPea8J4= X-Google-Smtp-Source: AK7set/Q/deQPDX7kQoAupUg44OKz+7+L0jbficRS/cY2gfFEcO0Mjm4VtBbY89dApXichkMU6YO0g== X-Received: by 2002:a17:90b:1e41:b0:237:39b1:7b1 with SMTP id pi1-20020a17090b1e4100b0023739b107b1mr26908148pjb.39.1678462435496; Fri, 10 Mar 2023 07:33:55 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:33:55 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 10/11] cifs: handle when server stops supporting multichannel Date: Fri, 10 Mar 2023 15:32:09 +0000 Message-Id: <20230310153211.10982-10-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org When a server stops supporting multichannel, we will keep attempting reconnects to the secondary channels today. Avoid this by freeing extra channels when negotiate returns no multichannel support. Signed-off-by: Shyam Prasad N --- fs/cifs/cifsproto.h | 2 ++ fs/cifs/connect.c | 6 ++++++ fs/cifs/sess.c | 35 +++++++++++++++++++++++++++++++++++ fs/cifs/smb2ops.c | 8 ++++++++ 4 files changed, 51 insertions(+) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 30fd81268eb7..343e582672b9 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -638,6 +638,8 @@ cifs_chan_needs_reconnect(struct cifs_ses *ses, bool cifs_chan_is_iface_active(struct cifs_ses *ses, struct TCP_Server_Info *server); +void +cifs_disable_extra_channels(struct cifs_ses *ses); int cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server); int diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index b9af60417194..6375b08b9bcb 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -130,6 +130,12 @@ static void smb2_query_server_interfaces(struct work_struct *work) if (rc) { cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n", __func__, rc); + + if (rc == -EOPNOTSUPP) { + /* cancel polling of interfaces and do not resched */ + cancel_delayed_work_sync(&tcon->query_interfaces); + return; + } } queue_delayed_work(cifsiod_wq, &tcon->query_interfaces, diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 9b51b2309e9c..34ae292bdff2 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -274,6 +274,41 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) return new_chan_count - old_chan_count; } +/* + * called when multichannel is disabled by the server + */ +void +cifs_disable_extra_channels(struct cifs_ses *ses) +{ + int i, chan_count; + struct cifs_server_iface *iface = NULL; + struct TCP_Server_Info *server = NULL; + + spin_lock(&ses->chan_lock); + chan_count = ses->chan_count; + ses->chan_count = 1; + for (i = 1; i < chan_count; i++) { + iface = ses->chans[i].iface; + server = ses->chans[i].server; + spin_unlock(&ses->chan_lock); + + if (iface) { + spin_lock(&ses->iface_lock); + kref_put(&iface->refcount, release_iface); + iface->num_channels--; + if (--iface->weight_fulfilled < 0) + iface->weight_fulfilled = 0; + spin_unlock(&ses->iface_lock); + } + cifs_put_tcp_session(server, 0); + + spin_lock(&ses->chan_lock); + ses->chans[i].iface = NULL; + ses->chans[i].server = NULL; + } + spin_unlock(&ses->chan_lock); +} + /* * update the iface for the channel if necessary. * will return 0 when iface is updated, 1 if removed, 2 otherwise diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index a5e53cb1ac49..c7a8a6049291 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -411,6 +411,14 @@ smb2_negotiate(const unsigned int xid, /* BB we probably don't need to retry with modern servers */ if (rc == -EAGAIN) rc = -EHOSTDOWN; + + if (!rc && + ses->chan_count > 1 && + !(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { + cifs_dbg(VFS, "server %s does not support multichannel anymore\n", ses->server->hostname); + cifs_disable_extra_channels(ses); + } + return rc; } From patchwork Fri Mar 10 15:32:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Prasad N X-Patchwork-Id: 13169448 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74945C64EC4 for ; Fri, 10 Mar 2023 15:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231476AbjCJPpo (ORCPT ); Fri, 10 Mar 2023 10:45:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232398AbjCJPpZ (ORCPT ); Fri, 10 Mar 2023 10:45:25 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D5CEDFB65 for ; Fri, 10 Mar 2023 07:34:01 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id x20-20020a17090a8a9400b00233ba727724so8091047pjn.1 for ; Fri, 10 Mar 2023 07:34:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678462440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wGeMs3KRVZUBuvHwNydHiKcPsFayYbJTGch1ZqheZKE=; b=j0CyXpx0E34kgfQO/Idd9R2jTNqzbR0DH7ooO77voiMIqXZDlmV9zKP8oAaFeOXS5a yTE1NL4C8n7uXES53+WWXwtqJiZtbbDl9eG9jgbyPAGyf7gFYLk3KEADhostRyGtTpBM QAVLsB/b5Kgd1X4214pQQ0ve1qBqnPbnX1hm51kEPF9ClOxH0EDcnXO0USbvgNqX7uMD Ej1hyXSj5osE4xDcNLpg4SnGDGMpoaSd8KxqXrEw+l3eIWtbvuSY/FoFJbMlTKO4/QIP 8IIvMzkvjn8Z6C7uJ3STuwf7036y0IsGjLRuNaiMxhh/pxYd3AyLusmLqRgc3zF/5xZZ Xjxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678462440; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wGeMs3KRVZUBuvHwNydHiKcPsFayYbJTGch1ZqheZKE=; b=5m9tr4vEynRKckFQHso1TpZpsPJM+ojuGUs4MpsH4iFOCo82brB2pcPfRcjN8WtSHc dSloBt9BCd0x/+/olXS/ZmP0jxpnD+TzHmhZQzT4WYtAqUUiWsbnUrJ5YQZj173Wc8h4 GrgJZdLAzjZYPn3AaSAxPUMeBAkvDy/qtD+wt3R34NWU3tQomG8XHLq/vFiOAMcPpr9H fRksBsv4o7jbkdvhDisfGQnuFOy7DUJ/Wwn67pJI5FIg/sCVbWK1/lxAnieUAwX2Dt6F TiS60NB6CvMYz65GL90qCDl6eAu2+xhat8wHJ1Ln50TK0Nq9Qj4ncvNxV7GQFjrvynfM NF1w== X-Gm-Message-State: AO0yUKXOFbSVGOxQ53xOH3n6u6maSNHBF8tgagOIG2kgpY9eLbETER9f VlUpj8A8zC1uCfIgSBfbf9E= X-Google-Smtp-Source: AK7set8EIdIUmBGyF8n15fimd8ktaX6RXFAFhddVlH0R2Y7b55bjBXECxfNnQY0fNp+n2v3GrIM2TQ== X-Received: by 2002:a17:90b:1b0f:b0:237:c18d:c459 with SMTP id nu15-20020a17090b1b0f00b00237c18dc459mr26357717pjb.31.1678462440621; Fri, 10 Mar 2023 07:34:00 -0800 (PST) Received: from lindev-local-latest.corp.microsoft.com ([2404:f801:8028:3:7e0c:5dff:fea8:2c14]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a604700b00230b8402760sm71637pjm.38.2023.03.10.07.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 07:34:00 -0800 (PST) From: Shyam Prasad N X-Google-Original-From: Shyam Prasad N To: smfrench@gmail.com, bharathsm.hsk@gmail.com, pc@cjr.nz, tom@talpey.com, linux-cifs@vger.kernel.org Cc: Shyam Prasad N Subject: [PATCH 11/11] cifs: empty interface list when server doesn't support query interfaces Date: Fri, 10 Mar 2023 15:32:10 +0000 Message-Id: <20230310153211.10982-11-sprasad@microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230310153211.10982-1-sprasad@microsoft.com> References: <20230310153211.10982-1-sprasad@microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org When querying server interfaces returns -EOPNOTSUPP, clear the list of interfaces. Assumption is that multichannel would be disabled too. Signed-off-by: Shyam Prasad N --- fs/cifs/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index c7a8a6049291..9ca55038b3db 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -763,7 +763,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_ if (rc == -EOPNOTSUPP) { cifs_dbg(FYI, "server does not support query network interfaces\n"); - goto out; + ret_data_len = 0; } else if (rc != 0) { cifs_tcon_dbg(VFS, "error %d on ioctl to get interface list\n", rc); goto out;