@@ -62,20 +62,6 @@ extern bool disable_legacy_dialects;
62
62
/* Drop the connection to not overload the server */
63
63
#define NUM_STATUS_IO_TIMEOUT 5
64
64
65
- struct mount_ctx {
66
- struct cifs_sb_info * cifs_sb ;
67
- struct smb3_fs_context * fs_ctx ;
68
- unsigned int xid ;
69
- struct TCP_Server_Info * server ;
70
- struct cifs_ses * ses ;
71
- struct cifs_tcon * tcon ;
72
- #ifdef CONFIG_CIFS_DFS_UPCALL
73
- struct cifs_ses * root_ses ;
74
- uuid_t mount_id ;
75
- char * origin_fullpath , * leaf_fullpath ;
76
- #endif
77
- };
78
-
79
65
static int ip_connect (struct TCP_Server_Info * server );
80
66
static int generic_ip_connect (struct TCP_Server_Info * server );
81
67
static void tlink_rb_insert (struct rb_root * root , struct tcon_link * new_tlink );
@@ -3191,7 +3177,7 @@ int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)
3191
3177
}
3192
3178
3193
3179
/* Release all succeed connections */
3194
- static inline void mount_put_conns (struct mount_ctx * mnt_ctx )
3180
+ static inline void mount_put_conns (struct cifs_mount_ctx * mnt_ctx )
3195
3181
{
3196
3182
int rc = 0 ;
3197
3183
@@ -3205,19 +3191,22 @@ static inline void mount_put_conns(struct mount_ctx *mnt_ctx)
3205
3191
free_xid (mnt_ctx -> xid );
3206
3192
}
3207
3193
3208
- /* Get connections for tcp, ses and tcon */
3209
- static int mount_get_conns (struct mount_ctx * mnt_ctx )
3194
+ int cifs_mount_get_session (struct cifs_mount_ctx * mnt_ctx )
3210
3195
{
3211
- int rc = 0 ;
3212
3196
struct TCP_Server_Info * server = NULL ;
3197
+ struct smb3_fs_context * ctx ;
3213
3198
struct cifs_ses * ses = NULL ;
3214
- struct cifs_tcon * tcon = NULL ;
3215
- struct smb3_fs_context * ctx = mnt_ctx -> fs_ctx ;
3216
- struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
3217
3199
unsigned int xid ;
3200
+ int rc = 0 ;
3218
3201
3219
3202
xid = get_xid ();
3220
3203
3204
+ if (WARN_ON_ONCE (!mnt_ctx || !mnt_ctx -> fs_ctx )) {
3205
+ rc = - EINVAL ;
3206
+ goto out ;
3207
+ }
3208
+ ctx = mnt_ctx -> fs_ctx ;
3209
+
3221
3210
/* get a reference to a tcp session */
3222
3211
server = cifs_get_tcp_session (ctx , NULL );
3223
3212
if (IS_ERR (server )) {
@@ -3238,11 +3227,36 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
3238
3227
SMB2_GLOBAL_CAP_PERSISTENT_HANDLES ))) {
3239
3228
cifs_server_dbg (VFS , "persistent handles not supported by server\n" );
3240
3229
rc = - EOPNOTSUPP ;
3230
+ }
3231
+
3232
+ out :
3233
+ mnt_ctx -> xid = xid ;
3234
+ mnt_ctx -> server = server ;
3235
+ mnt_ctx -> ses = ses ;
3236
+ mnt_ctx -> tcon = NULL ;
3237
+
3238
+ return rc ;
3239
+ }
3240
+
3241
+ int cifs_mount_get_tcon (struct cifs_mount_ctx * mnt_ctx )
3242
+ {
3243
+ struct TCP_Server_Info * server ;
3244
+ struct cifs_sb_info * cifs_sb ;
3245
+ struct smb3_fs_context * ctx ;
3246
+ struct cifs_tcon * tcon = NULL ;
3247
+ int rc = 0 ;
3248
+
3249
+ if (WARN_ON_ONCE (!mnt_ctx || !mnt_ctx -> server || !mnt_ctx -> ses || !mnt_ctx -> fs_ctx ||
3250
+ !mnt_ctx -> cifs_sb )) {
3251
+ rc = - EINVAL ;
3241
3252
goto out ;
3242
3253
}
3254
+ server = mnt_ctx -> server ;
3255
+ ctx = mnt_ctx -> fs_ctx ;
3256
+ cifs_sb = mnt_ctx -> cifs_sb ;
3243
3257
3244
3258
/* search for existing tcon to this server share */
3245
- tcon = cifs_get_tcon (ses , ctx );
3259
+ tcon = cifs_get_tcon (mnt_ctx -> ses , ctx );
3246
3260
if (IS_ERR (tcon )) {
3247
3261
rc = PTR_ERR (tcon );
3248
3262
tcon = NULL ;
@@ -3260,7 +3274,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
3260
3274
* reset of caps checks mount to see if unix extensions disabled
3261
3275
* for just this mount.
3262
3276
*/
3263
- reset_cifs_unix_caps (xid , tcon , cifs_sb , ctx );
3277
+ reset_cifs_unix_caps (mnt_ctx -> xid , tcon , cifs_sb , ctx );
3264
3278
spin_lock (& tcon -> ses -> server -> srv_lock );
3265
3279
if ((tcon -> ses -> server -> tcpStatus == CifsNeedReconnect ) &&
3266
3280
(le64_to_cpu (tcon -> fsUnixInfo .Capability ) &
@@ -3276,7 +3290,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
3276
3290
3277
3291
/* do not care if a following call succeed - informational */
3278
3292
if (!tcon -> pipe && server -> ops -> qfs_tcon ) {
3279
- server -> ops -> qfs_tcon (xid , tcon , cifs_sb );
3293
+ server -> ops -> qfs_tcon (mnt_ctx -> xid , tcon , cifs_sb );
3280
3294
if (cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_RO_CACHE ) {
3281
3295
if (tcon -> fsDevInfo .DeviceCharacteristics &
3282
3296
cpu_to_le32 (FILE_READ_ONLY_DEVICE ))
@@ -3309,14 +3323,22 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
3309
3323
cifs_fscache_get_super_cookie (tcon );
3310
3324
3311
3325
out :
3312
- mnt_ctx -> server = server ;
3313
- mnt_ctx -> ses = ses ;
3314
3326
mnt_ctx -> tcon = tcon ;
3315
- mnt_ctx -> xid = xid ;
3316
-
3317
3327
return rc ;
3318
3328
}
3319
3329
3330
+ /* Get connections for tcp, ses and tcon */
3331
+ static int mount_get_conns (struct cifs_mount_ctx * mnt_ctx )
3332
+ {
3333
+ int rc ;
3334
+
3335
+ rc = cifs_mount_get_session (mnt_ctx );
3336
+ if (rc )
3337
+ return rc ;
3338
+
3339
+ return cifs_mount_get_tcon (mnt_ctx );
3340
+ }
3341
+
3320
3342
static int mount_setup_tlink (struct cifs_sb_info * cifs_sb , struct cifs_ses * ses ,
3321
3343
struct cifs_tcon * tcon )
3322
3344
{
@@ -3345,7 +3367,7 @@ static int mount_setup_tlink(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
3345
3367
3346
3368
#ifdef CONFIG_CIFS_DFS_UPCALL
3347
3369
/* Get unique dfs connections */
3348
- static int mount_get_dfs_conns (struct mount_ctx * mnt_ctx )
3370
+ static int mount_get_dfs_conns (struct cifs_mount_ctx * mnt_ctx )
3349
3371
{
3350
3372
int rc ;
3351
3373
@@ -3448,7 +3470,7 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
3448
3470
*
3449
3471
* Return -EREMOTE if it is, otherwise 0 or -errno.
3450
3472
*/
3451
- static int is_path_remote (struct mount_ctx * mnt_ctx )
3473
+ static int is_path_remote (struct cifs_mount_ctx * mnt_ctx )
3452
3474
{
3453
3475
int rc ;
3454
3476
struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
@@ -3492,7 +3514,7 @@ static int is_path_remote(struct mount_ctx *mnt_ctx)
3492
3514
}
3493
3515
3494
3516
#ifdef CONFIG_CIFS_DFS_UPCALL
3495
- static void set_root_ses (struct mount_ctx * mnt_ctx )
3517
+ static void set_root_ses (struct cifs_mount_ctx * mnt_ctx )
3496
3518
{
3497
3519
if (mnt_ctx -> ses ) {
3498
3520
spin_lock (& cifs_tcp_ses_lock );
@@ -3503,7 +3525,8 @@ static void set_root_ses(struct mount_ctx *mnt_ctx)
3503
3525
mnt_ctx -> root_ses = mnt_ctx -> ses ;
3504
3526
}
3505
3527
3506
- static int is_dfs_mount (struct mount_ctx * mnt_ctx , bool * isdfs , struct dfs_cache_tgt_list * root_tl )
3528
+ static int is_dfs_mount (struct cifs_mount_ctx * mnt_ctx , bool * isdfs ,
3529
+ struct dfs_cache_tgt_list * root_tl )
3507
3530
{
3508
3531
int rc ;
3509
3532
struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
@@ -3534,7 +3557,7 @@ static int is_dfs_mount(struct mount_ctx *mnt_ctx, bool *isdfs, struct dfs_cache
3534
3557
return 0 ;
3535
3558
}
3536
3559
3537
- static int connect_dfs_target (struct mount_ctx * mnt_ctx , const char * full_path ,
3560
+ static int connect_dfs_target (struct cifs_mount_ctx * mnt_ctx , const char * full_path ,
3538
3561
const char * ref_path , struct dfs_cache_tgt_iterator * tit )
3539
3562
{
3540
3563
int rc ;
@@ -3568,7 +3591,7 @@ static int connect_dfs_target(struct mount_ctx *mnt_ctx, const char *full_path,
3568
3591
return rc ;
3569
3592
}
3570
3593
3571
- static int connect_dfs_root (struct mount_ctx * mnt_ctx , struct dfs_cache_tgt_list * root_tl )
3594
+ static int connect_dfs_root (struct cifs_mount_ctx * mnt_ctx , struct dfs_cache_tgt_list * root_tl )
3572
3595
{
3573
3596
int rc ;
3574
3597
char * full_path ;
@@ -3613,7 +3636,7 @@ static int connect_dfs_root(struct mount_ctx *mnt_ctx, struct dfs_cache_tgt_list
3613
3636
return rc ;
3614
3637
}
3615
3638
3616
- static int __follow_dfs_link (struct mount_ctx * mnt_ctx )
3639
+ static int __follow_dfs_link (struct cifs_mount_ctx * mnt_ctx )
3617
3640
{
3618
3641
int rc ;
3619
3642
struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
@@ -3662,7 +3685,7 @@ static int __follow_dfs_link(struct mount_ctx *mnt_ctx)
3662
3685
return rc ;
3663
3686
}
3664
3687
3665
- static int follow_dfs_link (struct mount_ctx * mnt_ctx )
3688
+ static int follow_dfs_link (struct cifs_mount_ctx * mnt_ctx )
3666
3689
{
3667
3690
int rc ;
3668
3691
struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
@@ -3695,7 +3718,7 @@ static int follow_dfs_link(struct mount_ctx *mnt_ctx)
3695
3718
}
3696
3719
3697
3720
/* Set up DFS referral paths for failover */
3698
- static void setup_server_referral_paths (struct mount_ctx * mnt_ctx )
3721
+ static void setup_server_referral_paths (struct cifs_mount_ctx * mnt_ctx )
3699
3722
{
3700
3723
struct TCP_Server_Info * server = mnt_ctx -> server ;
3701
3724
@@ -3710,7 +3733,7 @@ static void setup_server_referral_paths(struct mount_ctx *mnt_ctx)
3710
3733
int cifs_mount (struct cifs_sb_info * cifs_sb , struct smb3_fs_context * ctx )
3711
3734
{
3712
3735
int rc ;
3713
- struct mount_ctx mnt_ctx = { .cifs_sb = cifs_sb , .fs_ctx = ctx , };
3736
+ struct cifs_mount_ctx mnt_ctx = { .cifs_sb = cifs_sb , .fs_ctx = ctx , };
3714
3737
struct dfs_cache_tgt_list tl = DFS_CACHE_TGT_LIST_INIT (tl );
3715
3738
bool isdfs ;
3716
3739
@@ -3770,7 +3793,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3770
3793
int cifs_mount (struct cifs_sb_info * cifs_sb , struct smb3_fs_context * ctx )
3771
3794
{
3772
3795
int rc = 0 ;
3773
- struct mount_ctx mnt_ctx = { .cifs_sb = cifs_sb , .fs_ctx = ctx , };
3796
+ struct cifs_mount_ctx mnt_ctx = { .cifs_sb = cifs_sb , .fs_ctx = ctx , };
3774
3797
3775
3798
rc = mount_get_conns (& mnt_ctx );
3776
3799
if (rc )
0 commit comments