Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1880169ybz; Thu, 30 Apr 2020 07:08:08 -0700 (PDT) X-Google-Smtp-Source: APiQypLXJ8nH1S7w367pDkq/Y3pelTVlKay8WRViw3o8kayekyc0rwKXAL5tRBbuWZH7af0dek+L X-Received: by 2002:a17:906:c44b:: with SMTP id ck11mr2950967ejb.110.1588255688338; Thu, 30 Apr 2020 07:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588255688; cv=none; d=google.com; s=arc-20160816; b=LvvkJ3iWejGR1C3OFvAvpaEVwIktE5siM5RN5LT3HdknZBtD19pf8vK1/ylpIoYSFm 6wC3+mdNfepZRK6kUViawJSjwae6m+fbEL+MuoVw6A3NXfwpUKfOEYqnvwKqKUMsN19K tiOcFrK3YjHq5ZrH6OQWDw6AgfppWpnCjebzcEE3eTzQM0iG/yVFPmS07miZczpTYq0f ajnFk79LObna3gL0n1SoiPXIZb/pVdubI8hDtq/DxQ6yobxt0jt6RWqW1CtmDWvNudch nnKxFBOtLUD7hT0FYeMMZ6pWyeJ4ItpHvyNkNOvNOpwz676rATku5ZOFsg+XTYK26yHM sqxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uVhQ1wGAisfER/ELmrUl6da92FwZReP1kKbrQS2b+yk=; b=EPVbB69vktH2m7VQK4pN5Hbe1DtFAybw4PQUGJ+R4QiuWeg8ENKDi4V8I/u66d5opz oV/1T+AGlxoHjOESJwVkF2RtkpR1R00RjOt/33MD/pOj2d/jYm2uHhkUvhkozvFaaJZb JmdnwzOfGj83wBJqM2mTBMwGeIcZwUgr+nXCTYn6CS64NNnkRF5Z67AneN2pf/FKpMk9 L+qvY6xwEQs3G5ExQqFTpCfeNZP8OT457CkFN2DShhen3DPyDIFshYm+FX+oO5eoi7DW g6sANqaAGeX2t9v/RA6RUfTd1kf2A08jMRGPHZGkMpa2KNWsfQOM0xpD/Rqv/BxDvlx/ mexA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M7WKl3Up; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si5422496edo.354.2020.04.30.07.07.38; Thu, 30 Apr 2020 07:08:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M7WKl3Up; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728824AbgD3Nxw (ORCPT + 99 others); Thu, 30 Apr 2020 09:53:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:34826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbgD3NxL (ORCPT ); Thu, 30 Apr 2020 09:53:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18D99208CA; Thu, 30 Apr 2020 13:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588254791; bh=CMnwyT2LMCD0EZriqR5rgqNhfdV0DFvfJcImtGsdcOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7WKl3UpwA19nBn74aZS87S5mN6s7FpRz0wT+pmpdCbd6LaknFefZenf08AeBPzUI q39woc8LMP+G/XeYF6BIV/QbxW3d4XI1vbLNDUOsy3qh7LATeGalGA3VcH3pg5J3Ds vHbVBarLcDCFxqWCWJPDWsXy4Cs9DLXTRv2nGF/I= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Paulo Alcantara , Aurelien Aptel , Ronnie Sahlberg , Steve French , Sasha Levin , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH AUTOSEL 5.4 46/57] cifs: do not share tcons with DFS Date: Thu, 30 Apr 2020 09:52:07 -0400 Message-Id: <20200430135218.20372-46-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200430135218.20372-1-sashal@kernel.org> References: <20200430135218.20372-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paulo Alcantara [ Upstream commit 65303de829dd6d291a4947c1a31de31896f8a060 ] This disables tcon re-use for DFS shares. tcon->dfs_path stores the path that the tcon should connect to when doing failing over. If that tcon is used multiple times e.g. 2 mounts using it with different prefixpath, each will need a different dfs_path but there is only one tcon. The other solution would be to split the tcon in 2 tcons during failover but that is much harder. tcons could not be shared with DFS in cifs.ko because in a DFS namespace like: //domain/dfsroot -> /serverA/dfsroot, /serverB/dfsroot //serverA/dfsroot/link -> /serverA/target1/aa/bb //serverA/dfsroot/link2 -> /serverA/target1/cc/dd you can see that link and link2 are two DFS links that both resolve to the same target share (/serverA/target1), so cifs.ko will only contain a single tcon for both link and link2. The problem with that is, if we (auto)mount "link" and "link2", cifs.ko will only contain a single tcon for both DFS links so we couldn't perform failover or refresh the DFS cache for both links because tcon->dfs_path was set to either "link" or "link2", but not both -- which is wrong. Signed-off-by: Paulo Alcantara (SUSE) Reviewed-by: Aurelien Aptel Reviewed-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/connect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 52589ea4e3c05..721b2560caa74 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -3362,6 +3362,10 @@ cifs_find_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) spin_lock(&cifs_tcp_ses_lock); list_for_each(tmp, &ses->tcon_list) { tcon = list_entry(tmp, struct cifs_tcon, tcon_list); +#ifdef CONFIG_CIFS_DFS_UPCALL + if (tcon->dfs_path) + continue; +#endif if (!match_tcon(tcon, volume_info)) continue; ++tcon->tc_count; -- 2.20.1