提交 d17abdf7 编写于 作者: R Ronnie Sahlberg 提交者: Steve French

cifs: add an smb3_fs_context to cifs_sb

and populate it during mount in cifs_smb3_do_mount()
Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: NShyam Prasad N <sprasad@microsoft.com>
Signed-off-by: NSteve French <stfrench@microsoft.com>
上级 4deb0759
...@@ -61,6 +61,7 @@ struct cifs_sb_info { ...@@ -61,6 +61,7 @@ struct cifs_sb_info {
spinlock_t tlink_tree_lock; spinlock_t tlink_tree_lock;
struct tcon_link *master_tlink; struct tcon_link *master_tlink;
struct nls_table *local_nls; struct nls_table *local_nls;
struct smb3_fs_context *ctx;
unsigned int bsize; unsigned int bsize;
unsigned int rsize; unsigned int rsize;
unsigned int wsize; unsigned int wsize;
......
...@@ -776,8 +776,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, ...@@ -776,8 +776,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
{ {
int rc; int rc;
struct super_block *sb; struct super_block *sb;
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb = NULL;
struct smb3_fs_context *ctx;
struct cifs_mnt_data mnt_data; struct cifs_mnt_data mnt_data;
struct dentry *root; struct dentry *root;
...@@ -790,49 +789,51 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, ...@@ -790,49 +789,51 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
else else
cifs_info("Attempting to mount %s\n", old_ctx->UNC); cifs_info("Attempting to mount %s\n", old_ctx->UNC);
ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL); cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
if (!ctx) if (cifs_sb == NULL) {
return ERR_PTR(-ENOMEM); root = ERR_PTR(-ENOMEM);
rc = smb3_fs_context_dup(ctx, old_ctx);
if (rc) {
root = ERR_PTR(rc);
goto out; goto out;
} }
rc = cifs_setup_volume_info(ctx); cifs_sb->ctx = kzalloc(sizeof(struct smb3_fs_context), GFP_KERNEL);
if (!cifs_sb->ctx) {
root = ERR_PTR(-ENOMEM);
goto out;
}
rc = smb3_fs_context_dup(cifs_sb->ctx, old_ctx);
if (rc) { if (rc) {
root = ERR_PTR(rc); root = ERR_PTR(rc);
goto out; goto out;
} }
cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL); rc = cifs_setup_volume_info(cifs_sb->ctx);
if (cifs_sb == NULL) { if (rc) {
root = ERR_PTR(-ENOMEM); root = ERR_PTR(rc);
goto out_nls; goto out;
} }
cifs_sb->mountdata = kstrndup(ctx->mount_options, PAGE_SIZE, GFP_KERNEL); cifs_sb->mountdata = kstrndup(cifs_sb->ctx->mount_options, PAGE_SIZE, GFP_KERNEL);
if (cifs_sb->mountdata == NULL) { if (cifs_sb->mountdata == NULL) {
root = ERR_PTR(-ENOMEM); root = ERR_PTR(-ENOMEM);
goto out_free; goto out;
} }
rc = cifs_setup_cifs_sb(ctx, cifs_sb); rc = cifs_setup_cifs_sb(cifs_sb->ctx, cifs_sb);
if (rc) { if (rc) {
root = ERR_PTR(rc); root = ERR_PTR(rc);
goto out_free; goto out;
} }
rc = cifs_mount(cifs_sb, ctx); rc = cifs_mount(cifs_sb, cifs_sb->ctx);
if (rc) { if (rc) {
if (!(flags & SB_SILENT)) if (!(flags & SB_SILENT))
cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n", cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n",
rc); rc);
root = ERR_PTR(rc); root = ERR_PTR(rc);
goto out_free; goto out;
} }
mnt_data.ctx = ctx; mnt_data.ctx = cifs_sb->ctx;
mnt_data.cifs_sb = cifs_sb; mnt_data.cifs_sb = cifs_sb;
mnt_data.flags = flags; mnt_data.flags = flags;
...@@ -859,26 +860,23 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, ...@@ -859,26 +860,23 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
sb->s_flags |= SB_ACTIVE; sb->s_flags |= SB_ACTIVE;
} }
root = cifs_get_root(ctx, sb); root = cifs_get_root(cifs_sb->ctx, sb);
if (IS_ERR(root)) if (IS_ERR(root))
goto out_super; goto out_super;
cifs_dbg(FYI, "dentry root is: %p\n", root); cifs_dbg(FYI, "dentry root is: %p\n", root);
goto out; return root;
out_super: out_super:
deactivate_locked_super(sb); deactivate_locked_super(sb);
out: out:
cifs_cleanup_volume_info(ctx); if (cifs_sb) {
kfree(cifs_sb->prepath);
kfree(cifs_sb->mountdata);
cifs_cleanup_volume_info(cifs_sb->ctx);
kfree(cifs_sb);
}
return root; return root;
out_free:
kfree(cifs_sb->prepath);
kfree(cifs_sb->mountdata);
kfree(cifs_sb);
out_nls:
unload_nls(ctx->local_nls);
goto out;
} }
......
...@@ -2799,6 +2799,9 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx, ...@@ -2799,6 +2799,9 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
void void
cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx) cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx)
{ {
if (ctx == NULL)
return;
/* /*
* Make sure this stays in sync with smb3_fs_context_dup() * Make sure this stays in sync with smb3_fs_context_dup()
*/ */
...@@ -2818,6 +2821,9 @@ cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx) ...@@ -2818,6 +2821,9 @@ cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx)
ctx->iocharset = NULL; ctx->iocharset = NULL;
kfree(ctx->prepath); kfree(ctx->prepath);
ctx->prepath = NULL; ctx->prepath = NULL;
unload_nls(ctx->local_nls);
ctx->local_nls = NULL;
} }
void void
...@@ -3739,9 +3745,11 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses, ...@@ -3739,9 +3745,11 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
static void delayed_free(struct rcu_head *p) static void delayed_free(struct rcu_head *p)
{ {
struct cifs_sb_info *sbi = container_of(p, struct cifs_sb_info, rcu); struct cifs_sb_info *cifs_sb = container_of(p, struct cifs_sb_info, rcu);
unload_nls(sbi->local_nls);
kfree(sbi); unload_nls(cifs_sb->local_nls);
cifs_cleanup_volume_info(cifs_sb->ctx);
kfree(cifs_sb);
} }
void void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册