Skip to content

Commit

Permalink
cifs: only update prefix path of DFS links in cifs_tree_connect()
Browse files Browse the repository at this point in the history
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) <pc@cjr.nz>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Paulo Alcantara authored and Steve French committed Aug 2, 2020
1 parent c6a80e1 commit 11375a5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -5548,6 +5548,8 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
const char *dfs_host;
size_t dfs_host_len;
char *share = NULL, *prefix = NULL;
struct dfs_info3_param ref = {0};
bool isroot;

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

rc = dfs_cache_noreq_find(tcon->dfs_path + 1, NULL, &tl);
rc = dfs_cache_noreq_find(tcon->dfs_path + 1, &ref, &tl);
if (rc)
goto out;
isroot = ref.server_type == DFS_TYPE_ROOT;
free_dfs_info_param(&ref);

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

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

0 comments on commit 11375a5

Please sign in to comment.