@@ -98,15 +98,16 @@ static inline int parse_dfs_target(struct smb3_fs_context *ctx,
98
98
return rc ;
99
99
}
100
100
101
- static int setup_dfs_ref (struct cifs_mount_ctx * mnt_ctx ,
102
- struct dfs_info3_param * tgt ,
103
- struct dfs_ref_walk * rw )
101
+ static int setup_dfs_ref (struct dfs_info3_param * tgt , struct dfs_ref_walk * rw )
104
102
{
105
- struct smb3_fs_context * ctx = mnt_ctx -> fs_ctx ;
106
- struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
103
+ struct cifs_sb_info * cifs_sb = rw -> mnt_ctx -> cifs_sb ;
104
+ struct smb3_fs_context * ctx = rw -> mnt_ctx -> fs_ctx ;
107
105
char * ref_path , * full_path ;
108
106
int rc ;
109
107
108
+ set_root_smb_session (rw -> mnt_ctx );
109
+ ref_walk_ses (rw ) = ctx -> dfs_root_ses ;
110
+
110
111
full_path = smb3_fs_context_fullpath (ctx , CIFS_DIR_SEP (cifs_sb ));
111
112
if (IS_ERR (full_path ))
112
113
return PTR_ERR (full_path );
@@ -123,35 +124,22 @@ static int setup_dfs_ref(struct cifs_mount_ctx *mnt_ctx,
123
124
}
124
125
ref_walk_path (rw ) = ref_path ;
125
126
ref_walk_fpath (rw ) = full_path ;
126
- ref_walk_ses (rw ) = ctx -> dfs_root_ses ;
127
- return 0 ;
127
+
128
+ return dfs_get_referral (rw -> mnt_ctx ,
129
+ ref_walk_path (rw ) + 1 ,
130
+ ref_walk_tl (rw ));
128
131
}
129
132
130
- static int __dfs_referral_walk (struct cifs_mount_ctx * mnt_ctx ,
131
- struct dfs_ref_walk * rw )
133
+ static int __dfs_referral_walk (struct dfs_ref_walk * rw )
132
134
{
133
- struct smb3_fs_context * ctx = mnt_ctx -> fs_ctx ;
135
+ struct smb3_fs_context * ctx = rw -> mnt_ctx -> fs_ctx ;
136
+ struct cifs_mount_ctx * mnt_ctx = rw -> mnt_ctx ;
134
137
struct dfs_info3_param tgt = {};
135
138
int rc = - ENOENT ;
136
139
137
140
again :
138
141
do {
139
142
ctx -> dfs_root_ses = ref_walk_ses (rw );
140
- if (ref_walk_empty (rw )) {
141
- rc = dfs_get_referral (mnt_ctx , ref_walk_path (rw ) + 1 ,
142
- NULL , ref_walk_tl (rw ));
143
- if (rc ) {
144
- rc = cifs_mount_get_tcon (mnt_ctx );
145
- if (!rc )
146
- rc = cifs_is_path_remote (mnt_ctx );
147
- continue ;
148
- }
149
- if (!ref_walk_num_tgts (rw )) {
150
- rc = - ENOENT ;
151
- continue ;
152
- }
153
- }
154
-
155
143
while (ref_walk_next_tgt (rw )) {
156
144
rc = parse_dfs_target (ctx , rw , & tgt );
157
145
if (rc )
@@ -162,32 +150,29 @@ static int __dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx,
162
150
if (rc )
163
151
continue ;
164
152
165
- ref_walk_set_tgt_hint (rw );
166
153
if (tgt .flags & DFSREF_STORAGE_SERVER ) {
167
154
rc = cifs_mount_get_tcon (mnt_ctx );
168
155
if (!rc )
169
156
rc = cifs_is_path_remote (mnt_ctx );
170
- if (!rc )
157
+ if (!rc ) {
158
+ ref_walk_set_tgt_hint (rw );
171
159
break ;
160
+ }
172
161
if (rc != - EREMOTE )
173
162
continue ;
174
163
}
175
164
176
- set_root_smb_session (mnt_ctx );
177
165
rc = ref_walk_advance (rw );
178
166
if (!rc ) {
179
- rc = setup_dfs_ref (mnt_ctx , & tgt , rw );
180
- if (! rc ) {
181
- rc = - EREMOTE ;
182
- goto again ;
183
- }
167
+ rc = setup_dfs_ref (& tgt , rw );
168
+ if (rc )
169
+ break ;
170
+ ref_walk_mark_end ( rw ) ;
171
+ goto again ;
184
172
}
185
- if (rc != - ELOOP )
186
- goto out ;
187
173
}
188
174
} while (rc && ref_walk_descend (rw ));
189
175
190
- out :
191
176
free_dfs_info_param (& tgt );
192
177
return rc ;
193
178
}
@@ -204,10 +189,10 @@ static int dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx,
204
189
return rc ;
205
190
}
206
191
207
- ref_walk_init (* rw );
208
- rc = setup_dfs_ref (mnt_ctx , NULL , * rw );
192
+ ref_walk_init (* rw , mnt_ctx );
193
+ rc = setup_dfs_ref (NULL , * rw );
209
194
if (!rc )
210
- rc = __dfs_referral_walk (mnt_ctx , * rw );
195
+ rc = __dfs_referral_walk (* rw );
211
196
return rc ;
212
197
}
213
198
@@ -297,7 +282,7 @@ int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx)
297
282
* to respond with PATH_NOT_COVERED to requests that include the prefix.
298
283
*/
299
284
if (!nodfs ) {
300
- rc = dfs_get_referral (mnt_ctx , ctx -> UNC + 1 , NULL , NULL );
285
+ rc = dfs_get_referral (mnt_ctx , ctx -> UNC + 1 , NULL );
301
286
if (rc ) {
302
287
cifs_dbg (FYI , "%s: no dfs referral for %s: %d\n" ,
303
288
__func__ , ctx -> UNC + 1 , rc );
@@ -317,10 +302,8 @@ int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx)
317
302
cifs_mount_put_conns (mnt_ctx );
318
303
rc = get_session (mnt_ctx , NULL );
319
304
}
320
- if (!rc ) {
321
- set_root_smb_session (mnt_ctx );
305
+ if (!rc )
322
306
rc = __dfs_mount_share (mnt_ctx );
323
- }
324
307
return rc ;
325
308
}
326
309
0 commit comments