@@ -62,20 +62,6 @@ extern bool disable_legacy_dialects;
6262/* Drop the connection to not overload the server */
6363#define NUM_STATUS_IO_TIMEOUT 5
6464
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-
7965static int ip_connect (struct TCP_Server_Info * server );
8066static int generic_ip_connect (struct TCP_Server_Info * server );
8167static 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)
31913177}
31923178
31933179/* 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 )
31953181{
31963182 int rc = 0 ;
31973183
@@ -3205,19 +3191,22 @@ static inline void mount_put_conns(struct mount_ctx *mnt_ctx)
32053191 free_xid (mnt_ctx -> xid );
32063192}
32073193
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 )
32103195{
3211- int rc = 0 ;
32123196 struct TCP_Server_Info * server = NULL ;
3197+ struct smb3_fs_context * ctx ;
32133198 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 ;
32173199 unsigned int xid ;
3200+ int rc = 0 ;
32183201
32193202 xid = get_xid ();
32203203
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+
32213210 /* get a reference to a tcp session */
32223211 server = cifs_get_tcp_session (ctx , NULL );
32233212 if (IS_ERR (server )) {
@@ -3238,11 +3227,36 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
32383227 SMB2_GLOBAL_CAP_PERSISTENT_HANDLES ))) {
32393228 cifs_server_dbg (VFS , "persistent handles not supported by server\n" );
32403229 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 ;
32413252 goto out ;
32423253 }
3254+ server = mnt_ctx -> server ;
3255+ ctx = mnt_ctx -> fs_ctx ;
3256+ cifs_sb = mnt_ctx -> cifs_sb ;
32433257
32443258 /* search for existing tcon to this server share */
3245- tcon = cifs_get_tcon (ses , ctx );
3259+ tcon = cifs_get_tcon (mnt_ctx -> ses , ctx );
32463260 if (IS_ERR (tcon )) {
32473261 rc = PTR_ERR (tcon );
32483262 tcon = NULL ;
@@ -3260,7 +3274,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
32603274 * reset of caps checks mount to see if unix extensions disabled
32613275 * for just this mount.
32623276 */
3263- reset_cifs_unix_caps (xid , tcon , cifs_sb , ctx );
3277+ reset_cifs_unix_caps (mnt_ctx -> xid , tcon , cifs_sb , ctx );
32643278 spin_lock (& tcon -> ses -> server -> srv_lock );
32653279 if ((tcon -> ses -> server -> tcpStatus == CifsNeedReconnect ) &&
32663280 (le64_to_cpu (tcon -> fsUnixInfo .Capability ) &
@@ -3276,7 +3290,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
32763290
32773291 /* do not care if a following call succeed - informational */
32783292 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 );
32803294 if (cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_RO_CACHE ) {
32813295 if (tcon -> fsDevInfo .DeviceCharacteristics &
32823296 cpu_to_le32 (FILE_READ_ONLY_DEVICE ))
@@ -3309,14 +3323,22 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
33093323 cifs_fscache_get_super_cookie (tcon );
33103324
33113325out :
3312- mnt_ctx -> server = server ;
3313- mnt_ctx -> ses = ses ;
33143326 mnt_ctx -> tcon = tcon ;
3315- mnt_ctx -> xid = xid ;
3316-
33173327 return rc ;
33183328}
33193329
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+
33203342static int mount_setup_tlink (struct cifs_sb_info * cifs_sb , struct cifs_ses * ses ,
33213343 struct cifs_tcon * tcon )
33223344{
@@ -3345,7 +3367,7 @@ static int mount_setup_tlink(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
33453367
33463368#ifdef CONFIG_CIFS_DFS_UPCALL
33473369/* 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 )
33493371{
33503372 int rc ;
33513373
@@ -3448,7 +3470,7 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
34483470 *
34493471 * Return -EREMOTE if it is, otherwise 0 or -errno.
34503472 */
3451- static int is_path_remote (struct mount_ctx * mnt_ctx )
3473+ static int is_path_remote (struct cifs_mount_ctx * mnt_ctx )
34523474{
34533475 int rc ;
34543476 struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
@@ -3492,7 +3514,7 @@ static int is_path_remote(struct mount_ctx *mnt_ctx)
34923514}
34933515
34943516#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 )
34963518{
34973519 if (mnt_ctx -> ses ) {
34983520 spin_lock (& cifs_tcp_ses_lock );
@@ -3503,7 +3525,8 @@ static void set_root_ses(struct mount_ctx *mnt_ctx)
35033525 mnt_ctx -> root_ses = mnt_ctx -> ses ;
35043526}
35053527
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 )
35073530{
35083531 int rc ;
35093532 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
35343557 return 0 ;
35353558}
35363559
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 ,
35383561 const char * ref_path , struct dfs_cache_tgt_iterator * tit )
35393562{
35403563 int rc ;
@@ -3568,7 +3591,7 @@ static int connect_dfs_target(struct mount_ctx *mnt_ctx, const char *full_path,
35683591 return rc ;
35693592}
35703593
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 )
35723595{
35733596 int rc ;
35743597 char * full_path ;
@@ -3613,7 +3636,7 @@ static int connect_dfs_root(struct mount_ctx *mnt_ctx, struct dfs_cache_tgt_list
36133636 return rc ;
36143637}
36153638
3616- static int __follow_dfs_link (struct mount_ctx * mnt_ctx )
3639+ static int __follow_dfs_link (struct cifs_mount_ctx * mnt_ctx )
36173640{
36183641 int rc ;
36193642 struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
@@ -3662,7 +3685,7 @@ static int __follow_dfs_link(struct mount_ctx *mnt_ctx)
36623685 return rc ;
36633686}
36643687
3665- static int follow_dfs_link (struct mount_ctx * mnt_ctx )
3688+ static int follow_dfs_link (struct cifs_mount_ctx * mnt_ctx )
36663689{
36673690 int rc ;
36683691 struct cifs_sb_info * cifs_sb = mnt_ctx -> cifs_sb ;
@@ -3695,7 +3718,7 @@ static int follow_dfs_link(struct mount_ctx *mnt_ctx)
36953718}
36963719
36973720/* 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 )
36993722{
37003723 struct TCP_Server_Info * server = mnt_ctx -> server ;
37013724
@@ -3710,7 +3733,7 @@ static void setup_server_referral_paths(struct mount_ctx *mnt_ctx)
37103733int cifs_mount (struct cifs_sb_info * cifs_sb , struct smb3_fs_context * ctx )
37113734{
37123735 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 , };
37143737 struct dfs_cache_tgt_list tl = DFS_CACHE_TGT_LIST_INIT (tl );
37153738 bool isdfs ;
37163739
@@ -3770,7 +3793,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
37703793int cifs_mount (struct cifs_sb_info * cifs_sb , struct smb3_fs_context * ctx )
37713794{
37723795 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 , };
37743797
37753798 rc = mount_get_conns (& mnt_ctx );
37763799 if (rc )
0 commit comments