@@ -4786,6 +4786,17 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
4786
4786
}
4787
4787
4788
4788
#ifdef CONFIG_CIFS_DFS_UPCALL
4789
+ static inline void set_root_tcon (struct cifs_sb_info * cifs_sb ,
4790
+ struct cifs_tcon * tcon ,
4791
+ struct cifs_tcon * * root )
4792
+ {
4793
+ spin_lock (& cifs_tcp_ses_lock );
4794
+ tcon -> tc_count ++ ;
4795
+ tcon -> remap = cifs_remap (cifs_sb );
4796
+ spin_unlock (& cifs_tcp_ses_lock );
4797
+ * root = tcon ;
4798
+ }
4799
+
4789
4800
int cifs_mount (struct cifs_sb_info * cifs_sb , struct smb_vol * vol )
4790
4801
{
4791
4802
int rc = 0 ;
@@ -4887,18 +4898,10 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol)
4887
4898
/* Cache out resolved root server */
4888
4899
(void )dfs_cache_find (xid , ses , cifs_sb -> local_nls , cifs_remap (cifs_sb ),
4889
4900
root_path + 1 , NULL , NULL );
4890
- /*
4891
- * Save root tcon for additional DFS requests to update or create a new
4892
- * DFS cache entry, or even perform DFS failover.
4893
- */
4894
- spin_lock (& cifs_tcp_ses_lock );
4895
- tcon -> tc_count ++ ;
4896
- tcon -> dfs_path = root_path ;
4901
+ kfree (root_path );
4897
4902
root_path = NULL ;
4898
- tcon -> remap = cifs_remap (cifs_sb );
4899
- spin_unlock (& cifs_tcp_ses_lock );
4900
4903
4901
- root_tcon = tcon ;
4904
+ set_root_tcon ( cifs_sb , tcon , & root_tcon ) ;
4902
4905
4903
4906
for (count = 1 ; ;) {
4904
4907
if (!rc && tcon ) {
@@ -4935,6 +4938,15 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol)
4935
4938
mount_put_conns (cifs_sb , xid , server , ses , tcon );
4936
4939
rc = mount_get_conns (vol , cifs_sb , & xid , & server , & ses ,
4937
4940
& tcon );
4941
+ /*
4942
+ * Ensure that DFS referrals go through new root server.
4943
+ */
4944
+ if (!rc && tcon &&
4945
+ (tcon -> share_flags & (SHI1005_FLAGS_DFS |
4946
+ SHI1005_FLAGS_DFS_ROOT ))) {
4947
+ cifs_put_tcon (root_tcon );
4948
+ set_root_tcon (cifs_sb , tcon , & root_tcon );
4949
+ }
4938
4950
}
4939
4951
if (rc ) {
4940
4952
if (rc == - EACCES || rc == - EOPNOTSUPP )
0 commit comments