cifs: get rid of cifs_sb->mountdata
authorRonnie Sahlberg <lsahlber@redhat.com>
Mon, 9 Nov 2020 23:12:31 +0000 (09:12 +1000)
committerSteve French <stfrench@microsoft.com>
Mon, 14 Dec 2020 01:12:07 +0000 (19:12 -0600)
as we now have a full smb3_fs_context as part of the cifs superblock
we no longer need a local copy of the mount options and can just
reference the copy in the smb3_fs_context.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifs_dfs_ref.c
fs/cifs/cifs_fs_sb.h
fs/cifs/cifsfs.c
fs/cifs/connect.c

index 81f6066..6f7187b 100644 (file)
@@ -23,6 +23,7 @@
 #include "cifs_debug.h"
 #include "cifs_unicode.h"
 #include "dfs_cache.h"
+#include "fs_context.h"
 
 static LIST_HEAD(cifs_dfs_automount_list);
 
@@ -275,7 +276,7 @@ static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt,
        /* See afs_mntpt_do_automount in fs/afs/mntpt.c for an example */
 
        /* strip first '\' from fullpath */
-       mountdata = cifs_compose_mount_options(cifs_sb->mountdata,
+       mountdata = cifs_compose_mount_options(cifs_sb->ctx->mount_options,
                                               fullpath + 1, NULL);
        if (IS_ERR(mountdata)) {
                kfree(devname);
index 34d0229..8ee37c8 100644 (file)
@@ -74,7 +74,6 @@ struct cifs_sb_info {
        umode_t mnt_file_mode;
        umode_t mnt_dir_mode;
        unsigned int mnt_cifs_flags;
-       char   *mountdata; /* options received at mount time or via DFS refs */
        struct delayed_work prune_tlinks;
        struct rcu_head rcu;
 
index 7fe6502..4f27f77 100644 (file)
@@ -812,12 +812,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
                goto out;
        }
 
-       cifs_sb->mountdata = kstrndup(cifs_sb->ctx->mount_options, PAGE_SIZE, GFP_KERNEL);
-       if (cifs_sb->mountdata == NULL) {
-               root = ERR_PTR(-ENOMEM);
-               goto out;
-       }
-
        rc = cifs_setup_cifs_sb(cifs_sb->ctx, cifs_sb);
        if (rc) {
                root = ERR_PTR(rc);
@@ -872,7 +866,6 @@ out_super:
 out:
        if (cifs_sb) {
                kfree(cifs_sb->prepath);
-               kfree(cifs_sb->mountdata);
                cifs_cleanup_volume_info(cifs_sb->ctx);
                kfree(cifs_sb);
        }
index 5146c46..95b12f1 100644 (file)
@@ -3012,7 +3012,7 @@ build_unc_path_to_root(const struct smb3_fs_context *ctx,
  * expand_dfs_referral - Perform a dfs referral query and update the cifs_sb
  *
  *
- * If a referral is found, cifs_sb->mountdata will be (re-)allocated
+ * If a referral is found, cifs_sb->ctx->mount_options will be (re-)allocated
  * to a string containing updated options for the submount.  Otherwise it
  * will be left untouched.
  *
@@ -3038,7 +3038,7 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses,
        rc = dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb),
                            ref_path, &referral, NULL);
        if (!rc) {
-               mdata = cifs_compose_mount_options(cifs_sb->mountdata,
+               mdata = cifs_compose_mount_options(cifs_sb->ctx->mount_options,
                                                   full_path + 1, &referral);
                free_dfs_info_param(&referral);
 
@@ -3049,8 +3049,8 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses,
                        cifs_cleanup_volume_info_contents(ctx);
                        rc = cifs_setup_volume_info(ctx);
                }
-               kfree(cifs_sb->mountdata);
-               cifs_sb->mountdata = mdata;
+               kfree(cifs_sb->ctx->mount_options);
+               cifs_sb->ctx->mount_options = mdata;
        }
        kfree(full_path);
        return rc;
@@ -3109,7 +3109,8 @@ static int setup_dfs_tgt_conn(const char *path, const char *full_path,
        if (rc)
                return rc;
 
-       mdata = cifs_compose_mount_options(cifs_sb->mountdata, full_path + 1, &ref);
+       mdata = cifs_compose_mount_options(cifs_sb->ctx->mount_options,
+                                          full_path + 1, &ref);
        free_dfs_info_param(&ref);
 
        if (IS_ERR(mdata)) {
@@ -3438,7 +3439,8 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
                        goto error;
        }
        /* Save mount options */
-       mntdata = kstrndup(cifs_sb->mountdata, strlen(cifs_sb->mountdata), GFP_KERNEL);
+       mntdata = kstrndup(cifs_sb->ctx->mount_options,
+                          strlen(cifs_sb->ctx->mount_options), GFP_KERNEL);
        if (!mntdata) {
                rc = -ENOMEM;
                goto error;
@@ -3462,12 +3464,12 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
                        break;
                }
                /* Chase referral */
-               oldmnt = cifs_sb->mountdata;
+               oldmnt = cifs_sb->ctx->mount_options;
                rc = expand_dfs_referral(xid, root_ses, ctx, cifs_sb, ref_path + 1);
                if (rc)
                        break;
                /* Connect to new DFS target only if we were redirected */
-               if (oldmnt != cifs_sb->mountdata) {
+               if (oldmnt != cifs_sb->ctx->mount_options) {
                        mount_put_conns(cifs_sb, xid, server, ses, tcon);
                        rc = mount_get_conns(ctx, cifs_sb, &xid, &server, &ses, &tcon);
                }
@@ -3774,7 +3776,6 @@ cifs_umount(struct cifs_sb_info *cifs_sb)
        }
        spin_unlock(&cifs_sb->tlink_tree_lock);
 
-       kfree(cifs_sb->mountdata);
        kfree(cifs_sb->prepath);
 #ifdef CONFIG_CIFS_DFS_UPCALL
        dfs_cache_del_vol(cifs_sb->origin_fullpath);