Commit 387ec58f authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: simplify handling of cifs_sb/ctx->local_nls

Only load/unload local_nls from cifs_sb and just make the ctx
contain a pointer to cifs_sb->ctx.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 9ccecae8
...@@ -598,9 +598,7 @@ extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page, ...@@ -598,9 +598,7 @@ extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
unsigned int *len, unsigned int *offset); unsigned int *len, unsigned int *offset);
struct cifs_chan * struct cifs_chan *
cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server); cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server);
int cifs_try_adding_channels(struct cifs_ses *ses); int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);
int cifs_ses_add_channel(struct cifs_ses *ses,
struct cifs_server_iface *iface);
bool is_server_using_iface(struct TCP_Server_Info *server, bool is_server_using_iface(struct TCP_Server_Info *server,
struct cifs_server_iface *iface); struct cifs_server_iface *iface);
bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface); bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface);
......
...@@ -2717,7 +2717,19 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx, ...@@ -2717,7 +2717,19 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
cifs_dbg(FYI, "file mode: %04ho dir mode: %04ho\n", cifs_dbg(FYI, "file mode: %04ho dir mode: %04ho\n",
cifs_sb->ctx->file_mode, cifs_sb->ctx->dir_mode); cifs_sb->ctx->file_mode, cifs_sb->ctx->dir_mode);
cifs_sb->local_nls = ctx->local_nls; /* this is needed for ASCII cp to Unicode converts */
if (ctx->iocharset == NULL) {
/* load_nls_default cannot return null */
cifs_sb->local_nls = load_nls_default();
} else {
cifs_sb->local_nls = load_nls(ctx->iocharset);
if (cifs_sb->local_nls == NULL) {
cifs_dbg(VFS, "CIFS mount error: iocharset %s not found\n",
ctx->iocharset);
return -ELIBACC;
}
}
ctx->local_nls = cifs_sb->local_nls;
if (ctx->nodfs) if (ctx->nodfs)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_DFS; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_DFS;
...@@ -3187,19 +3199,6 @@ cifs_setup_volume_info(struct smb3_fs_context *ctx) ...@@ -3187,19 +3199,6 @@ cifs_setup_volume_info(struct smb3_fs_context *ctx)
return -EINVAL; return -EINVAL;
} }
/* this is needed for ASCII cp to Unicode converts */
if (ctx->iocharset == NULL) {
/* load_nls_default cannot return null */
ctx->local_nls = load_nls_default();
} else {
ctx->local_nls = load_nls(ctx->iocharset);
if (ctx->local_nls == NULL) {
cifs_dbg(VFS, "CIFS mount error: iocharset %s not found\n",
ctx->iocharset);
return -ELIBACC;
}
}
return rc; return rc;
} }
...@@ -3521,7 +3520,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx) ...@@ -3521,7 +3520,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
out: out:
free_xid(xid); free_xid(xid);
cifs_try_adding_channels(ses); cifs_try_adding_channels(cifs_sb, ses);
return mount_setup_tlink(cifs_sb, ses, tcon); return mount_setup_tlink(cifs_sb, ses, tcon);
error: error:
......
...@@ -304,7 +304,6 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx ...@@ -304,7 +304,6 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
memcpy(new_ctx, ctx, sizeof(*ctx)); memcpy(new_ctx, ctx, sizeof(*ctx));
new_ctx->prepath = NULL; new_ctx->prepath = NULL;
new_ctx->mount_options = NULL; new_ctx->mount_options = NULL;
new_ctx->local_nls = NULL;
new_ctx->nodename = NULL; new_ctx->nodename = NULL;
new_ctx->username = NULL; new_ctx->username = NULL;
new_ctx->password = NULL; new_ctx->password = NULL;
...@@ -1350,9 +1349,6 @@ smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx) ...@@ -1350,9 +1349,6 @@ smb3_cleanup_fs_context_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
......
...@@ -237,7 +237,7 @@ struct smb3_fs_context { ...@@ -237,7 +237,7 @@ struct smb3_fs_context {
char *prepath; char *prepath;
struct sockaddr_storage dstaddr; /* destination address */ struct sockaddr_storage dstaddr; /* destination address */
struct sockaddr_storage srcaddr; /* allow binding to a local IP */ struct sockaddr_storage srcaddr; /* allow binding to a local IP */
struct nls_table *local_nls; struct nls_table *local_nls; /* This is a copy of the pointer in cifs_sb */
unsigned int echo_interval; /* echo interval in secs */ unsigned int echo_interval; /* echo interval in secs */
__u64 snapshot_time; /* needed for timewarp tokens */ __u64 snapshot_time; /* needed for timewarp tokens */
__u32 handle_timeout; /* persistent and durable handle timeout in ms */ __u32 handle_timeout; /* persistent and durable handle timeout in ms */
......
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
#include "smb2proto.h" #include "smb2proto.h"
#include "fs_context.h" #include "fs_context.h"
static int
cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
struct cifs_server_iface *iface);
bool bool
is_server_using_iface(struct TCP_Server_Info *server, is_server_using_iface(struct TCP_Server_Info *server,
struct cifs_server_iface *iface) struct cifs_server_iface *iface)
...@@ -71,7 +75,7 @@ bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface) ...@@ -71,7 +75,7 @@ bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface)
} }
/* returns number of channels added */ /* returns number of channels added */
int cifs_try_adding_channels(struct cifs_ses *ses) int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses)
{ {
int old_chan_count = ses->chan_count; int old_chan_count = ses->chan_count;
int left = ses->chan_max - ses->chan_count; int left = ses->chan_max - ses->chan_count;
...@@ -134,7 +138,7 @@ int cifs_try_adding_channels(struct cifs_ses *ses) ...@@ -134,7 +138,7 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
continue; continue;
} }
rc = cifs_ses_add_channel(ses, iface); rc = cifs_ses_add_channel(cifs_sb, ses, iface);
if (rc) { if (rc) {
cifs_dbg(FYI, "failed to open extra channel on iface#%d rc=%d\n", cifs_dbg(FYI, "failed to open extra channel on iface#%d rc=%d\n",
i, rc); i, rc);
...@@ -167,8 +171,9 @@ cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server) ...@@ -167,8 +171,9 @@ cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server)
return NULL; return NULL;
} }
int static int
cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface) cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
struct cifs_server_iface *iface)
{ {
struct cifs_chan *chan; struct cifs_chan *chan;
struct smb3_fs_context ctx = {NULL}; struct smb3_fs_context ctx = {NULL};
...@@ -229,13 +234,8 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface) ...@@ -229,13 +234,8 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
/* /*
* This will be used for encoding/decoding user/domain/pw * This will be used for encoding/decoding user/domain/pw
* during sess setup auth. * during sess setup auth.
*
* XXX: We use the default for simplicity but the proper way
* would be to use the one that ses used, which is not
* stored. This might break when dealing with non-ascii
* strings.
*/ */
ctx.local_nls = load_nls_default(); ctx.local_nls = cifs_sb->local_nls;
/* Use RDMA if possible */ /* Use RDMA if possible */
ctx.rdma = iface->rdma_capable; ctx.rdma = iface->rdma_capable;
...@@ -275,7 +275,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface) ...@@ -275,7 +275,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
if (rc) if (rc)
goto out; goto out;
rc = cifs_setup_session(xid, ses, ctx.local_nls); rc = cifs_setup_session(xid, ses, cifs_sb->local_nls);
if (rc) if (rc)
goto out; goto out;
...@@ -298,7 +298,6 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface) ...@@ -298,7 +298,6 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
if (rc && chan->server) if (rc && chan->server)
cifs_put_tcp_session(chan->server, 0); cifs_put_tcp_session(chan->server, 0);
unload_nls(ctx.local_nls);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment