@@ -368,13 +368,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
368
368
cifs_server_dbg (VFS , "%s: failed to update DFS target hint: rc = %d\n" ,
369
369
__func__ , rc );
370
370
}
371
- rc = dfs_cache_update_vol (cifs_sb -> origin_fullpath , server );
372
- if (rc ) {
373
- cifs_server_dbg (VFS , "%s: failed to update vol info in DFS cache: rc = %d\n" ,
374
- __func__ , rc );
375
- }
376
371
dfs_cache_free_tgts (& tgt_list );
377
-
378
372
}
379
373
380
374
cifs_put_tcp_super (sb );
@@ -1601,14 +1595,17 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
1601
1595
{
1602
1596
unsigned int rc , xid ;
1603
1597
struct TCP_Server_Info * server = ses -> server ;
1604
-
1605
1598
cifs_dbg (FYI , "%s: ses_count=%d\n" , __func__ , ses -> ses_count );
1606
1599
1607
1600
spin_lock (& cifs_tcp_ses_lock );
1608
1601
if (ses -> status == CifsExiting ) {
1609
1602
spin_unlock (& cifs_tcp_ses_lock );
1610
1603
return ;
1611
1604
}
1605
+
1606
+ cifs_dbg (FYI , "%s: ses_count=%d\n" , __func__ , ses -> ses_count );
1607
+ cifs_dbg (FYI , "%s: ses ipc: %s\n" , __func__ , ses -> tcon_ipc ? ses -> tcon_ipc -> treeName : "NONE" );
1608
+
1612
1609
if (-- ses -> ses_count > 0 ) {
1613
1610
spin_unlock (& cifs_tcp_ses_lock );
1614
1611
return ;
@@ -3284,25 +3281,23 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *
3284
3281
}
3285
3282
3286
3283
#ifdef CONFIG_CIFS_DFS_UPCALL
3287
- static void set_root_ses (struct cifs_sb_info * cifs_sb , struct cifs_ses * ses ,
3284
+ static void set_root_ses (struct cifs_sb_info * cifs_sb , const uuid_t * mount_id , struct cifs_ses * ses ,
3288
3285
struct cifs_ses * * root_ses )
3289
3286
{
3290
3287
if (ses ) {
3291
3288
spin_lock (& cifs_tcp_ses_lock );
3292
3289
ses -> ses_count ++ ;
3293
- if (ses -> tcon_ipc )
3290
+ cifs_dbg (FYI , "%s: new ses_count=%d\n" , __func__ , ses -> ses_count );
3291
+ if (ses -> tcon_ipc ) {
3292
+ cifs_dbg (FYI , "%s: ipc tcon: %s\n" , __func__ , ses -> tcon_ipc -> treeName );
3294
3293
ses -> tcon_ipc -> remap = cifs_remap (cifs_sb );
3294
+ }
3295
3295
spin_unlock (& cifs_tcp_ses_lock );
3296
+ dfs_cache_add_refsrv_session (mount_id , ses );
3296
3297
}
3297
3298
* root_ses = ses ;
3298
3299
}
3299
3300
3300
- static void put_root_ses (struct cifs_ses * ses )
3301
- {
3302
- if (ses )
3303
- cifs_put_smb_ses (ses );
3304
- }
3305
-
3306
3301
/* Set up next dfs prefix path in @dfs_path */
3307
3302
static int next_dfs_prepath (struct cifs_sb_info * cifs_sb , struct smb3_fs_context * ctx ,
3308
3303
const unsigned int xid , struct TCP_Server_Info * server ,
@@ -3382,9 +3377,9 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3382
3377
struct cifs_ses * ses = NULL , * root_ses = NULL ;
3383
3378
struct cifs_tcon * tcon = NULL ;
3384
3379
int count = 0 ;
3380
+ uuid_t mount_id = {0 };
3385
3381
char * ref_path = NULL , * full_path = NULL ;
3386
3382
char * oldmnt = NULL ;
3387
- char * mntdata = NULL ;
3388
3383
bool ref_server = false;
3389
3384
3390
3385
rc = mount_get_conns (ctx , cifs_sb , & xid , & server , & ses , & tcon );
@@ -3407,12 +3402,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3407
3402
if (rc != - EREMOTE )
3408
3403
goto error ;
3409
3404
}
3410
- /* Save mount options */
3411
- mntdata = kstrdup (cifs_sb -> ctx -> mount_options , GFP_KERNEL );
3412
- if (!mntdata ) {
3413
- rc = - ENOMEM ;
3414
- goto error ;
3415
- }
3405
+
3416
3406
/* Get path of DFS root */
3417
3407
ref_path = build_unc_path_to_root (ctx , cifs_sb , false);
3418
3408
if (IS_ERR (ref_path )) {
@@ -3421,7 +3411,8 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3421
3411
goto error ;
3422
3412
}
3423
3413
3424
- set_root_ses (cifs_sb , ses , & root_ses );
3414
+ uuid_gen (& mount_id );
3415
+ set_root_ses (cifs_sb , & mount_id , ses , & root_ses );
3425
3416
do {
3426
3417
/* Save full path of last DFS path we used to resolve final target server */
3427
3418
kfree (full_path );
@@ -3455,10 +3446,8 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3455
3446
rc = is_referral_server (ref_path + 1 , tcon , & ref_server );
3456
3447
if (rc )
3457
3448
break ;
3458
- if (ref_server ) {
3459
- put_root_ses (root_ses );
3460
- set_root_ses (cifs_sb , ses , & root_ses );
3461
- }
3449
+ if (ref_server )
3450
+ set_root_ses (cifs_sb , & mount_id , ses , & root_ses );
3462
3451
3463
3452
/* Get next dfs path and then continue chasing them if -EREMOTE */
3464
3453
rc = next_dfs_prepath (cifs_sb , ctx , xid , server , tcon , & ref_path );
@@ -3469,8 +3458,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3469
3458
3470
3459
if (rc )
3471
3460
goto error ;
3472
- put_root_ses (root_ses );
3473
- root_ses = NULL ;
3461
+
3474
3462
kfree (ref_path );
3475
3463
ref_path = NULL ;
3476
3464
/*
@@ -3492,10 +3480,6 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3492
3480
tcon -> remap = cifs_remap (cifs_sb );
3493
3481
spin_unlock (& cifs_tcp_ses_lock );
3494
3482
3495
- /* Add original context for DFS cache to be used when refreshing referrals */
3496
- rc = dfs_cache_add_vol (mntdata , ctx , cifs_sb -> origin_fullpath );
3497
- if (rc )
3498
- goto error ;
3499
3483
/*
3500
3484
* After reconnecting to a different server, unique ids won't
3501
3485
* match anymore, so we disable serverino. This prevents
@@ -3510,6 +3494,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3510
3494
kfree (cifs_sb -> prepath );
3511
3495
cifs_sb -> prepath = ctx -> prepath ;
3512
3496
ctx -> prepath = NULL ;
3497
+ uuid_copy (& cifs_sb -> dfs_mount_id , & mount_id );
3513
3498
3514
3499
out :
3515
3500
free_xid (xid );
@@ -3519,9 +3504,8 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
3519
3504
error :
3520
3505
kfree (ref_path );
3521
3506
kfree (full_path );
3522
- kfree (mntdata );
3523
3507
kfree (cifs_sb -> origin_fullpath );
3524
- put_root_ses ( root_ses );
3508
+ dfs_cache_put_refsrv_sessions ( & mount_id );
3525
3509
mount_put_conns (cifs_sb , xid , server , ses , tcon );
3526
3510
return rc ;
3527
3511
}
@@ -3751,7 +3735,7 @@ cifs_umount(struct cifs_sb_info *cifs_sb)
3751
3735
3752
3736
kfree (cifs_sb -> prepath );
3753
3737
#ifdef CONFIG_CIFS_DFS_UPCALL
3754
- dfs_cache_del_vol ( cifs_sb -> origin_fullpath );
3738
+ dfs_cache_put_refsrv_sessions ( & cifs_sb -> dfs_mount_id );
3755
3739
kfree (cifs_sb -> origin_fullpath );
3756
3740
#endif
3757
3741
call_rcu (& cifs_sb -> rcu , delayed_free );
0 commit comments