CIFS: make 'nodfs' mount opt a superblock flag
authorAurelien Aptel <aaptel@suse.com>
Fri, 21 Sep 2018 01:10:25 +0000 (18:10 -0700)
committerSteve French <stfrench@microsoft.com>
Wed, 24 Oct 2018 02:16:05 +0000 (21:16 -0500)
tcon->Flags is only used by SMB1 code and changing it is not permanent
(you lose the setting on tcon reconnect).

* Move the setting to superblock flags (per mount-points).
* Make automount callback exit early when flag present
* Make dfs resolving happening in mount syscall exit early if flag present

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Acked-by: Pavel Shilovsky <pshilov@microsoft.com>
fs/cifs/cifs_dfs_ref.c
fs/cifs/cifs_fs_sb.h
fs/cifs/cifsfs.c
fs/cifs/connect.c

index 6b61df117fd48c456f30275053187ffd720d46e1..b97c74efd04ac1eeb0f34923dc62d7ac7a042b7b 100644 (file)
@@ -304,12 +304,17 @@ static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
         */
        mnt = ERR_PTR(-ENOMEM);
 
+       cifs_sb = CIFS_SB(mntpt->d_sb);
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS) {
+               mnt = ERR_PTR(-EREMOTE);
+               goto cdda_exit;
+       }
+
        /* always use tree name prefix */
        full_path = build_path_from_dentry_optional_prefix(mntpt, true);
        if (full_path == NULL)
                goto cdda_exit;
 
-       cifs_sb = CIFS_SB(mntpt->d_sb);
        tlink = cifs_sb_tlink(cifs_sb);
        if (IS_ERR(tlink)) {
                mnt = ERR_CAST(tlink);
index 9731d0d891e7e030e3d4c4c692d2ce653d4b8029..63d7530f2e1d30dfbf94d84fc615d5169b304615 100644 (file)
@@ -51,6 +51,7 @@
                                              */
 #define CIFS_MOUNT_UID_FROM_ACL 0x2000000 /* try to get UID via special SID */
 #define CIFS_MOUNT_NO_HANDLE_CACHE 0x4000000 /* disable caching dir handles */
+#define CIFS_MOUNT_NO_DFS 0x8000000 /* disable DFS resolving */
 
 struct cifs_sb_info {
        struct rb_root tlink_tree;
index ba0054604f85260560db77848a3ce6018f587a68..d2f9bc48ffac86d2044dca19245ea62e9e98f880 100644 (file)
@@ -500,6 +500,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
                seq_puts(s, ",unix");
        else
                seq_puts(s, ",nounix");
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS)
+               seq_puts(s, ",nodfs");
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
                seq_puts(s, ",posixpaths");
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
index 106d3a85f77bf646bae221ba5c6305fd66c44216..6221aef45ff5b41daf9ea97b3c53053b4d693f1c 100644 (file)
@@ -3086,10 +3086,6 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
        if (rc)
                goto out_fail;
 
-       if (volume_info->nodfs) {
-               tcon->Flags &= ~SMB_SHARE_IS_IN_DFS;
-               cifs_dbg(FYI, "DFS disabled (%d)\n", tcon->Flags);
-       }
        tcon->use_persistent = false;
        /* check if SMB2 or later, CIFS does not support persistent handles */
        if (volume_info->persistent) {
@@ -3664,6 +3660,8 @@ int cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
        cifs_sb->actimeo = pvolume_info->actimeo;
        cifs_sb->local_nls = pvolume_info->local_nls;
 
+       if (pvolume_info->nodfs)
+               cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_DFS;
        if (pvolume_info->noperm)
                cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
        if (pvolume_info->setuids)
@@ -3820,6 +3818,9 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses,
        struct dfs_info3_param *referrals = NULL;
        char *full_path = NULL, *ref_path = NULL, *mdata = NULL;
 
+       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS)
+               return -EREMOTE;
+
        full_path = build_unc_path_to_root(volume_info, cifs_sb);
        if (IS_ERR(full_path))
                return PTR_ERR(full_path);