Skip to content

Commit 4a5ba0e

Browse files
Paulo AlcantaraSteve French
authored andcommitted
smb: client: handle DFS tcons in cifs_construct_tcon()
The tcons created by cifs_construct_tcon() on multiuser mounts must also be able to failover and refresh DFS referrals, so set the appropriate fields in order to get a full DFS tcon. They could be shared among different superblocks later, too. Cc: [email protected] # 6.4+ Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 0a05ad2 commit 4a5ba0e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

fs/smb/client/connect.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,6 +3995,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
39953995
struct cifs_ses *ses;
39963996
struct cifs_tcon *tcon = NULL;
39973997
struct smb3_fs_context *ctx;
3998+
char *origin_fullpath = NULL;
39983999

39994000
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
40004001
if (ctx == NULL)
@@ -4018,6 +4019,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
40184019
ctx->sign = master_tcon->ses->sign;
40194020
ctx->seal = master_tcon->seal;
40204021
ctx->witness = master_tcon->use_witness;
4022+
ctx->dfs_root_ses = master_tcon->ses->dfs_root_ses;
40214023

40224024
rc = cifs_set_vol_auth(ctx, master_tcon->ses);
40234025
if (rc) {
@@ -4037,12 +4039,39 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
40374039
goto out;
40384040
}
40394041

4042+
#ifdef CONFIG_CIFS_DFS_UPCALL
4043+
spin_lock(&master_tcon->tc_lock);
4044+
if (master_tcon->origin_fullpath) {
4045+
spin_unlock(&master_tcon->tc_lock);
4046+
origin_fullpath = dfs_get_path(cifs_sb, cifs_sb->ctx->source);
4047+
if (IS_ERR(origin_fullpath)) {
4048+
tcon = ERR_CAST(origin_fullpath);
4049+
origin_fullpath = NULL;
4050+
cifs_put_smb_ses(ses);
4051+
goto out;
4052+
}
4053+
} else {
4054+
spin_unlock(&master_tcon->tc_lock);
4055+
}
4056+
#endif
4057+
40404058
tcon = cifs_get_tcon(ses, ctx);
40414059
if (IS_ERR(tcon)) {
40424060
cifs_put_smb_ses(ses);
40434061
goto out;
40444062
}
40454063

4064+
#ifdef CONFIG_CIFS_DFS_UPCALL
4065+
if (origin_fullpath) {
4066+
spin_lock(&tcon->tc_lock);
4067+
tcon->origin_fullpath = origin_fullpath;
4068+
spin_unlock(&tcon->tc_lock);
4069+
origin_fullpath = NULL;
4070+
queue_delayed_work(dfscache_wq, &tcon->dfs_cache_work,
4071+
dfs_cache_get_ttl() * HZ);
4072+
}
4073+
#endif
4074+
40464075
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
40474076
if (cap_unix(ses))
40484077
reset_cifs_unix_caps(0, tcon, NULL, ctx);
@@ -4051,6 +4080,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
40514080
out:
40524081
kfree(ctx->username);
40534082
kfree_sensitive(ctx->password);
4083+
kfree(origin_fullpath);
40544084
kfree(ctx);
40554085

40564086
return tcon;

0 commit comments

Comments
 (0)