All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Alcantara <pc@cjr.nz>
To: Matthew Ruffell <matthew.ruffell@canonical.com>,
	linux-cifs@vger.kernel.org
Cc: sfrench@samba.org
Subject: Re: PROBLEM: DFS Caching feature causing problems traversing multi-tier DFS setups
Date: Tue, 12 Nov 2019 22:11:20 -0300	[thread overview]
Message-ID: <87imnooa13.fsf@cjr.nz> (raw)
In-Reply-To: <05aa2995-e85e-0ff4-d003-5bb08bd17a22@canonical.com>

Hi Matthew,

Thanks for the report.

Matthew Ruffell <matthew.ruffell@canonical.com> writes:

> We have come across a problem where kernels 5.0-rc1 and onwards cannot mount
> a multi tier DFS setup, while kernels 4.20 and below can mount the share fine.
>
> The DFS tiering structure looks like this:
>
> Domain virtual DFS (i.e. \\company.com\folders\share)
> |-- Domain controller DFS (i.e. \\regional-dc.company.com\folders\share)
>     |-- Regional DFS Server (i.e. \\regional-dfs.company.com\folders\share)
>         |-- Actual file server (i.e. \\regional-svr.company.com\share)
>
> On the 5.x series kernels, after getting the DFS referrals list through to the
> Regional DFS Server, which responds with the correct server/share, instead of
> going to the Actual file server, the kernel backtracks from the Regional DFS
> Server back to the Domain controller and requests the share there. Of course,
> this share does not exist on the Domain controller, as it only exists on the
> Actual file server, and the connection dies.

I've got some DFS cache patches[1] and haven't sent them yet due to lack
of time and testing. Those contain a lot of important fixes but none of
them seem to fix the issue you're having -- thus I won't ask you to
apply them on top.

Instead, could you please try below changes?

Thanks,
Paulo

[1] https://git.cjr.nz/linux.git/log/?h=cifs-dfscache

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 3991d6c8f255..9158d5d14ac9 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -4777,6 +4777,15 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
 }
 
 #ifdef CONFIG_CIFS_DFS_UPCALL
+static inline void set_root_tcon(struct cifs_tcon *tcon,
+				 struct cifs_tcon **root)
+{
+	spin_lock(&cifs_tcp_ses_lock);
+	tcon->tc_count++;
+	spin_unlock(&cifs_tcp_ses_lock);
+	*root = tcon;
+}
+
 int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol)
 {
 	int rc = 0;
@@ -4878,18 +4887,10 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol)
 	/* Cache out resolved root server */
 	(void)dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb),
 			     root_path + 1, NULL, NULL);
-	/*
-	 * Save root tcon for additional DFS requests to update or create a new
-	 * DFS cache entry, or even perform DFS failover.
-	 */
-	spin_lock(&cifs_tcp_ses_lock);
-	tcon->tc_count++;
-	tcon->dfs_path = root_path;
+	kfree(root_path);
 	root_path = NULL;
-	tcon->remap = cifs_remap(cifs_sb);
-	spin_unlock(&cifs_tcp_ses_lock);
 
-	root_tcon = tcon;
+	set_root_tcon(tcon, &root_tcon);
 
 	for (count = 1; ;) {
 		if (!rc && tcon) {
@@ -4926,6 +4927,15 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol)
 			mount_put_conns(cifs_sb, xid, server, ses, tcon);
 			rc = mount_get_conns(vol, cifs_sb, &xid, &server, &ses,
 					     &tcon);
+			/*
+			 * Ensure that DFS referrals go through new root server.
+			 */
+			if (!rc && tcon &&
+			    (tcon->share_flags & (SHI1005_FLAGS_DFS |
+						  SHI1005_FLAGS_DFS_ROOT))) {
+				cifs_put_tcon(root_tcon);
+				set_root_tcon(tcon, &root_tcon);
+			}
 		}
 		if (rc) {
 			if (rc == -EACCES || rc == -EOPNOTSUPP)

  reply	other threads:[~2019-11-13  1:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 21:52 PROBLEM: DFS Caching feature causing problems traversing multi-tier DFS setups Matthew Ruffell
2019-11-13  1:11 ` Paulo Alcantara [this message]
2019-11-19 16:55   ` Matthew Ruffell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87imnooa13.fsf@cjr.nz \
    --to=pc@cjr.nz \
    --cc=linux-cifs@vger.kernel.org \
    --cc=matthew.ruffell@canonical.com \
    --cc=sfrench@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.