Skip to content

Commit 11375a5

Browse files
Paulo Alcantarasmfrench
authored andcommitted
cifs: only update prefix path of DFS links in cifs_tree_connect()
For DFS root mounts that contain a prefix path, do not change them after failover. E.g., if the user mounts //srvA/root/dir1 and then lost connection to srvA, it will reconnect to //srvB/root/dir1 In case of DFS links, which may resolve to different prefix paths depending on their list of targets, the following must be supported: - mount //srvA/root/link/bar - connect to //srvA/share - set prefix path to "bar" - lost connection to srvA - reconnect to next target: //srvB/share/foo - set new prefix path to "foo/bar" In cifs_tree_connect(), check the server_type field of the cached DFS referral to determine whether or not prefix path should be updated. Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent c6a80e1 commit 11375a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/cifs/connect.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5548,6 +5548,8 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
55485548
const char *dfs_host;
55495549
size_t dfs_host_len;
55505550
char *share = NULL, *prefix = NULL;
5551+
struct dfs_info3_param ref = {0};
5552+
bool isroot;
55515553

55525554
tree = kzalloc(MAX_TREE_SIZE, GFP_KERNEL);
55535555
if (!tree)
@@ -5563,9 +5565,11 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
55635565
goto out;
55645566
}
55655567

5566-
rc = dfs_cache_noreq_find(tcon->dfs_path + 1, NULL, &tl);
5568+
rc = dfs_cache_noreq_find(tcon->dfs_path + 1, &ref, &tl);
55675569
if (rc)
55685570
goto out;
5571+
isroot = ref.server_type == DFS_TYPE_ROOT;
5572+
free_dfs_info_param(&ref);
55695573

55705574
extract_unc_hostname(server->hostname, &tcp_host, &tcp_host_len);
55715575

@@ -5609,7 +5613,8 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
56095613
} else {
56105614
scnprintf(tree, MAX_TREE_SIZE, "\\%s", share);
56115615
rc = ops->tree_connect(xid, tcon->ses, tree, tcon, nlsc);
5612-
if (!rc) {
5616+
/* Only handle prefix paths of DFS link targets */
5617+
if (!rc && !isroot) {
56135618
rc = update_super_prepath(tcon, prefix);
56145619
break;
56155620
}

0 commit comments

Comments
 (0)