* [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c
@ 2020-12-14 6:40 Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 02/12] cifs: move [brw]size from cifs_sb to cifs_sb->ctx Ronnie Sahlberg
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
and rename it to smb3_cleanup_fs_context[_content]
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifsfs.c | 2 +-
fs/cifs/cifsproto.h | 3 ---
fs/cifs/connect.c | 47 ++++-------------------------------------------
fs/cifs/dfs_cache.c | 4 ++--
fs/cifs/fs_context.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
fs/cifs/fs_context.h | 2 ++
6 files changed, 51 insertions(+), 52 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 0932a3b225be..9c2959f552e0 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -874,7 +874,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
out:
if (cifs_sb) {
kfree(cifs_sb->prepath);
- cifs_cleanup_volume_info(cifs_sb->ctx);
+ smb3_cleanup_fs_context(cifs_sb->ctx);
kfree(cifs_sb);
}
return root;
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index b80b57a66804..891c8d8c2bb5 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -237,7 +237,6 @@ extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
extern int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
struct cifs_sb_info *cifs_sb);
extern int cifs_match_super(struct super_block *, void *);
-extern void cifs_cleanup_volume_info(struct smb3_fs_context *ctx);
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
extern void cifs_umount(struct cifs_sb_info *);
extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
@@ -552,8 +551,6 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
extern int
cifs_setup_volume_info(struct smb3_fs_context *ctx);
-extern void
-cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx);
extern struct TCP_Server_Info *
cifs_find_tcp_session(struct smb3_fs_context *ctx);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 1c8b08c06ad7..068b13e1b499 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2806,45 +2806,6 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
return 0;
}
-void
-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()
- */
- kfree(ctx->mount_options);
- ctx->mount_options = NULL;
- kfree(ctx->username);
- ctx->username = NULL;
- kfree_sensitive(ctx->password);
- ctx->password = NULL;
- kfree(ctx->UNC);
- ctx->UNC = NULL;
- kfree(ctx->domainname);
- ctx->domainname = NULL;
- kfree(ctx->nodename);
- ctx->nodename = NULL;
- kfree(ctx->iocharset);
- ctx->iocharset = NULL;
- kfree(ctx->prepath);
- ctx->prepath = NULL;
-
- unload_nls(ctx->local_nls);
- ctx->local_nls = NULL;
-}
-
-void
-cifs_cleanup_volume_info(struct smb3_fs_context *ctx)
-{
- if (!ctx)
- return;
- cifs_cleanup_volume_info_contents(ctx);
- kfree(ctx);
-}
-
/* Release all succeed connections */
static inline void mount_put_conns(struct cifs_sb_info *cifs_sb,
unsigned int xid,
@@ -3055,7 +3016,7 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses,
rc = PTR_ERR(mdata);
mdata = NULL;
} else {
- cifs_cleanup_volume_info_contents(ctx);
+ smb3_cleanup_fs_context_contents(ctx);
rc = cifs_setup_volume_info(ctx);
}
kfree(cifs_sb->ctx->mount_options);
@@ -3147,7 +3108,7 @@ static int setup_dfs_tgt_conn(const char *path, const char *full_path,
rc = update_vol_info(tgt_it, &fake_ctx, ctx);
}
}
- cifs_cleanup_volume_info_contents(&fake_ctx);
+ smb3_cleanup_fs_context_contents(&fake_ctx);
return rc;
}
@@ -3395,7 +3356,7 @@ static int check_dfs_prepath(struct cifs_sb_info *cifs_sb, struct smb3_fs_contex
break;
rc = -EREMOTE;
npath = build_unc_path_to_root(&v, cifs_sb, true);
- cifs_cleanup_volume_info_contents(&v);
+ smb3_cleanup_fs_context_contents(&v);
} else {
v.UNC = ctx->UNC;
v.prepath = path + 1;
@@ -3759,7 +3720,7 @@ static void delayed_free(struct rcu_head *p)
struct cifs_sb_info *cifs_sb = container_of(p, struct cifs_sb_info, rcu);
unload_nls(cifs_sb->local_nls);
- cifs_cleanup_volume_info(cifs_sb->ctx);
+ smb3_cleanup_fs_context(cifs_sb->ctx);
kfree(cifs_sb);
}
diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c
index 6bccff4596bf..6ad6ba5f6ebe 100644
--- a/fs/cifs/dfs_cache.c
+++ b/fs/cifs/dfs_cache.c
@@ -587,7 +587,7 @@ static void __vol_release(struct vol_info *vi)
{
kfree(vi->fullpath);
kfree(vi->mntdata);
- cifs_cleanup_volume_info_contents(&vi->ctx);
+ smb3_cleanup_fs_context_contents(&vi->ctx);
kfree(vi);
}
@@ -1468,7 +1468,7 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi,
ses = cifs_get_smb_ses(server, &ctx);
out:
- cifs_cleanup_volume_info_contents(&ctx);
+ smb3_cleanup_fs_context_contents(&ctx);
kfree(mdata);
kfree(rpath);
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index fe5cc60f4393..4739caa0af97 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -289,7 +289,7 @@ do { \
if (ctx->field) { \
new_ctx->field = kstrdup(ctx->field, GFP_ATOMIC); \
if (new_ctx->field == NULL) { \
- cifs_cleanup_volume_info_contents(new_ctx); \
+ smb3_cleanup_fs_context_contents(new_ctx); \
return -ENOMEM; \
} \
} \
@@ -312,7 +312,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
new_ctx->iocharset = NULL;
/*
- * Make sure to stay in sync with cifs_cleanup_volume_info_contents()
+ * Make sure to stay in sync with smb3_cleanup_fs_context_contents()
*/
DUP_CTX_STR(prepath);
DUP_CTX_STR(mount_options);
@@ -617,7 +617,7 @@ static void smb3_fs_context_free(struct fs_context *fc)
{
struct smb3_fs_context *ctx = smb3_fc2context(fc);
- cifs_cleanup_volume_info(ctx);
+ smb3_cleanup_fs_context(ctx);
}
static int smb3_reconfigure(struct fs_context *fc)
@@ -1243,3 +1243,42 @@ int smb3_init_fs_context(struct fs_context *fc)
fc->ops = &smb3_fs_context_ops;
return 0;
}
+
+void
+smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
+{
+ if (ctx == NULL)
+ return;
+
+ /*
+ * Make sure this stays in sync with smb3_fs_context_dup()
+ */
+ kfree(ctx->mount_options);
+ ctx->mount_options = NULL;
+ kfree(ctx->username);
+ ctx->username = NULL;
+ kfree_sensitive(ctx->password);
+ ctx->password = NULL;
+ kfree(ctx->UNC);
+ ctx->UNC = NULL;
+ kfree(ctx->domainname);
+ ctx->domainname = NULL;
+ kfree(ctx->nodename);
+ ctx->nodename = NULL;
+ kfree(ctx->iocharset);
+ ctx->iocharset = NULL;
+ kfree(ctx->prepath);
+ ctx->prepath = NULL;
+
+ unload_nls(ctx->local_nls);
+ ctx->local_nls = NULL;
+}
+
+void
+smb3_cleanup_fs_context(struct smb3_fs_context *ctx)
+{
+ if (!ctx)
+ return;
+ smb3_cleanup_fs_context_contents(ctx);
+ kfree(ctx);
+}
diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
index aaec8a819d34..4c4c392b9767 100644
--- a/fs/cifs/fs_context.h
+++ b/fs/cifs/fs_context.h
@@ -254,6 +254,8 @@ extern int cifs_parse_cache_flavor(char *value,
extern int cifs_parse_security_flavors(char *value,
struct smb3_fs_context *ctx);
extern int smb3_init_fs_context(struct fs_context *fc);
+extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
+extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
{
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 02/12] cifs: move [brw]size from cifs_sb to cifs_sb->ctx
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 03/12] cifs: add initial reconfigure support Ronnie Sahlberg
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifs_fs_sb.h | 3 ---
fs/cifs/cifsfs.c | 11 +++++++----
fs/cifs/connect.c | 21 +++++++++------------
fs/cifs/file.c | 12 ++++++------
fs/cifs/fs_context.c | 3 +++
fs/cifs/fs_context.h | 3 +++
fs/cifs/inode.c | 2 +-
fs/cifs/smb1ops.c | 2 +-
fs/cifs/smb2ops.c | 2 +-
9 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h
index 69d26313d350..aa77edc12212 100644
--- a/fs/cifs/cifs_fs_sb.h
+++ b/fs/cifs/cifs_fs_sb.h
@@ -62,9 +62,6 @@ struct cifs_sb_info {
struct tcon_link *master_tlink;
struct nls_table *local_nls;
struct smb3_fs_context *ctx;
- unsigned int bsize;
- unsigned int rsize;
- unsigned int wsize;
atomic_t active;
unsigned int mnt_cifs_flags;
struct delayed_work prune_tlinks;
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 9c2959f552e0..6a3cb192d75a 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -218,7 +218,7 @@ cifs_read_super(struct super_block *sb)
if (rc)
goto out_no_root;
/* tune readahead according to rsize */
- sb->s_bdi->ra_pages = cifs_sb->rsize / PAGE_SIZE;
+ sb->s_bdi->ra_pages = cifs_sb->ctx->rsize / PAGE_SIZE;
sb->s_blocksize = CIFS_MAX_MSGSIZE;
sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
@@ -615,9 +615,12 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
from_kgid_munged(&init_user_ns,
cifs_sb->ctx->backupgid));
- seq_printf(s, ",rsize=%u", cifs_sb->rsize);
- seq_printf(s, ",wsize=%u", cifs_sb->wsize);
- seq_printf(s, ",bsize=%u", cifs_sb->bsize);
+ if (cifs_sb->ctx->got_rsize)
+ seq_printf(s, ",rsize=%u", cifs_sb->ctx->rsize);
+ if (cifs_sb->ctx->got_wsize)
+ seq_printf(s, ",wsize=%u", cifs_sb->ctx->wsize);
+ if (cifs_sb->ctx->got_bsize)
+ seq_printf(s, ",bsize=%u", cifs_sb->ctx->bsize);
if (tcon->ses->server->min_offload)
seq_printf(s, ",esize=%u", tcon->ses->server->min_offload);
seq_printf(s, ",echo_interval=%lu",
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 068b13e1b499..ceb660e1b601 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2234,10 +2234,10 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
* We want to share sb only if we don't specify an r/wsize or
* specified r/wsize is greater than or equal to existing one.
*/
- if (new->wsize && new->wsize < old->wsize)
+ if (new->ctx->wsize && new->ctx->wsize < old->ctx->wsize)
return 0;
- if (new->rsize && new->rsize < old->rsize)
+ if (new->ctx->rsize && new->ctx->rsize < old->ctx->rsize)
return 0;
if (!uid_eq(old->ctx->linux_uid, new->ctx->linux_uid) ||
@@ -2700,14 +2700,6 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
spin_lock_init(&cifs_sb->tlink_tree_lock);
cifs_sb->tlink_tree = RB_ROOT;
- cifs_sb->bsize = ctx->bsize;
- /*
- * Temporarily set r/wsize for matching superblock. If we end up using
- * new sb then client will later negotiate it downward if needed.
- */
- cifs_sb->rsize = ctx->rsize;
- cifs_sb->wsize = ctx->wsize;
-
cifs_dbg(FYI, "file mode: %04ho dir mode: %04ho\n",
cifs_sb->ctx->file_mode, cifs_sb->ctx->dir_mode);
@@ -2911,8 +2903,13 @@ static int mount_get_conns(struct smb3_fs_context *ctx, struct cifs_sb_info *cif
}
}
- cifs_sb->wsize = server->ops->negotiate_wsize(tcon, ctx);
- cifs_sb->rsize = server->ops->negotiate_rsize(tcon, ctx);
+ /*
+ * Clamp the rsize/wsize mount arguments if they are too big for the server
+ */
+ if (cifs_sb->ctx->wsize > server->ops->negotiate_wsize(tcon, ctx))
+ cifs_sb->ctx->wsize = server->ops->negotiate_wsize(tcon, ctx);
+ if (cifs_sb->ctx->rsize > server->ops->negotiate_rsize(tcon, ctx))
+ cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tcon, ctx);
return 0;
}
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 583074546e6f..6d001905c8e5 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2336,7 +2336,7 @@ static int cifs_writepages(struct address_space *mapping,
* If wsize is smaller than the page cache size, default to writing
* one page at a time via cifs_writepage
*/
- if (cifs_sb->wsize < PAGE_SIZE)
+ if (cifs_sb->ctx->wsize < PAGE_SIZE)
return generic_writepages(mapping, wbc);
xid = get_xid();
@@ -2369,7 +2369,7 @@ static int cifs_writepages(struct address_space *mapping,
if (rc)
get_file_rc = rc;
- rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize,
+ rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->wsize,
&wsize, credits);
if (rc != 0) {
done = true;
@@ -2911,7 +2911,7 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from,
break;
}
- rc = server->ops->wait_mtu_credits(server, cifs_sb->wsize,
+ rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->wsize,
&wsize, credits);
if (rc)
break;
@@ -3642,7 +3642,7 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
break;
}
- rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize,
+ rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
&rsize, credits);
if (rc)
break;
@@ -4028,7 +4028,7 @@ cifs_read(struct file *file, char *read_data, size_t read_size, loff_t *offset)
cifs_sb = CIFS_FILE_SB(file);
/* FIXME: set up handlers for larger reads and/or convert to async */
- rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize);
+ rsize = min_t(unsigned int, cifs_sb->ctx->rsize, CIFSMaxBufSize);
if (file->private_data == NULL) {
rc = -EBADF;
@@ -4413,7 +4413,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
break;
}
- rc = server->ops->wait_mtu_credits(server, cifs_sb->rsize,
+ rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
&rsize, credits);
if (rc)
break;
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 4739caa0af97..e83bd4382dfa 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -783,12 +783,15 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
goto cifs_parse_mount_err;
}
ctx->bsize = result.uint_32;
+ ctx->got_bsize = true;
break;
case Opt_rsize:
ctx->rsize = result.uint_32;
+ ctx->got_rsize = true;
break;
case Opt_wsize:
ctx->wsize = result.uint_32;
+ ctx->got_wsize = true;
break;
case Opt_actimeo:
ctx->actimeo = HZ * result.uint_32;
diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
index 4c4c392b9767..7c794df7a874 100644
--- a/fs/cifs/fs_context.h
+++ b/fs/cifs/fs_context.h
@@ -152,6 +152,9 @@ struct smb3_fs_context {
char *nodename;
bool got_ip;
bool got_version;
+ bool got_rsize;
+ bool got_wsize;
+ bool got_bsize;
unsigned short port;
char *username;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 240d79e3aa14..a83b3a8ffaac 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2409,7 +2409,7 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
}
generic_fillattr(inode, stat);
- stat->blksize = cifs_sb->bsize;
+ stat->blksize = cifs_sb->ctx->bsize;
stat->ino = CIFS_I(inode)->uniqueid;
/* old CIFS Unix Extensions doesn't return create time */
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 359a0ef796de..e31b939e628c 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -1006,7 +1006,7 @@ cifs_is_read_op(__u32 oplock)
static unsigned int
cifs_wp_retry_size(struct inode *inode)
{
- return CIFS_SB(inode->i_sb)->wsize;
+ return CIFS_SB(inode->i_sb)->ctx->wsize;
}
static bool
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 940e61e92a8c..a505cc3e58da 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -3951,7 +3951,7 @@ smb3_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key)
static unsigned int
smb2_wp_retry_size(struct inode *inode)
{
- return min_t(unsigned int, CIFS_SB(inode->i_sb)->wsize,
+ return min_t(unsigned int, CIFS_SB(inode->i_sb)->ctx->wsize,
SMB2_MAX_BUFFER_SIZE);
}
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 03/12] cifs: add initial reconfigure support
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 02/12] cifs: move [brw]size from cifs_sb to cifs_sb->ctx Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 04/12] cifs: we do not allow changing username/password/unc/... during remount Ronnie Sahlberg
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/fs_context.c | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index e83bd4382dfa..4bab06f97727 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -620,14 +620,44 @@ static void smb3_fs_context_free(struct fs_context *fc)
smb3_cleanup_fs_context(ctx);
}
-static int smb3_reconfigure(struct fs_context *fc)
+/*
+ * Compare the old and new proposed context during reconfigure
+ * and check if the changes are compatible.
+ */
+static int smb3_verify_reconfigure_ctx(struct smb3_fs_context *new_ctx,
+ struct smb3_fs_context *old_ctx)
{
- // TODO: struct smb3_fs_context *ctx = smb3_fc2context(fc);
+ if (new_ctx->sectype != old_ctx->sectype) {
+ cifs_dbg(VFS, "can not change sec during remount\n");
+ return -EINVAL;
+ }
- /* FIXME : add actual reconfigure */
return 0;
}
+static int smb3_reconfigure(struct fs_context *fc)
+{
+ struct smb3_fs_context *ctx = smb3_fc2context(fc);
+ struct dentry *root = fc->root;
+ struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
+ int rc;
+
+ rc = smb3_verify_reconfigure_ctx(ctx, cifs_sb->ctx);
+ if (rc)
+ return rc;
+
+ /*
+ * Steal the UNC from the old and to be destroyed context.
+ */
+ ctx->UNC = cifs_sb->ctx->UNC;
+ cifs_sb->ctx->UNC = NULL;
+
+ smb3_cleanup_fs_context_contents(cifs_sb->ctx);
+ rc = smb3_fs_context_dup(cifs_sb->ctx, ctx);
+
+ return rc;
+}
+
static int smb3_fs_context_parse_param(struct fs_context *fc,
struct fs_parameter *param)
{
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 04/12] cifs: we do not allow changing username/password/unc/... during remount
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 02/12] cifs: move [brw]size from cifs_sb to cifs_sb->ctx Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 03/12] cifs: add initial reconfigure support Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 05/12] cifs: simplify handling of cifs_sb/ctx->local_nls Ronnie Sahlberg
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifsfs.c | 2 +-
fs/cifs/fs_context.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---
fs/cifs/fs_context.h | 2 +-
3 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 6a3cb192d75a..276b0659c238 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -493,7 +493,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
if (tcon->no_lease)
seq_puts(s, ",nolease");
- if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
+ if (cifs_sb->ctx->multiuser)
seq_puts(s, ",multiuser");
else if (tcon->ses->user_name)
seq_show_option(s, "username", tcon->ses->user_name);
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 4bab06f97727..d312d4bac3d1 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -631,10 +631,51 @@ static int smb3_verify_reconfigure_ctx(struct smb3_fs_context *new_ctx,
cifs_dbg(VFS, "can not change sec during remount\n");
return -EINVAL;
}
+ if (new_ctx->multiuser != old_ctx->multiuser) {
+ cifs_dbg(VFS, "can not change multiuser during remount\n");
+ return -EINVAL;
+ }
+ if (new_ctx->UNC &&
+ (!old_ctx->UNC || strcmp(new_ctx->UNC, old_ctx->UNC))) {
+ cifs_dbg(VFS, "can not change UNC during remount\n");
+ return -EINVAL;
+ }
+ if (new_ctx->username &&
+ (!old_ctx->username || strcmp(new_ctx->username, old_ctx->username))) {
+ cifs_dbg(VFS, "can not change username during remount\n");
+ return -EINVAL;
+ }
+ if (new_ctx->password &&
+ (!old_ctx->password || strcmp(new_ctx->password, old_ctx->password))) {
+ cifs_dbg(VFS, "can not change password during remount\n");
+ return -EINVAL;
+ }
+ if (new_ctx->domainname &&
+ (!old_ctx->domainname || strcmp(new_ctx->domainname, old_ctx->domainname))) {
+ cifs_dbg(VFS, "can not change domainname during remount\n");
+ return -EINVAL;
+ }
+ if (new_ctx->nodename &&
+ (!old_ctx->nodename || strcmp(new_ctx->nodename, old_ctx->nodename))) {
+ cifs_dbg(VFS, "can not change nodename during remount\n");
+ return -EINVAL;
+ }
+ if (new_ctx->iocharset &&
+ (!old_ctx->iocharset || strcmp(new_ctx->iocharset, old_ctx->iocharset))) {
+ cifs_dbg(VFS, "can not change iocharset during remount\n");
+ return -EINVAL;
+ }
return 0;
}
+#define STEAL_STRING(cifs_sb, ctx, field) \
+do { \
+ kfree(ctx->field); \
+ ctx->field = cifs_sb->ctx->field; \
+ cifs_sb->ctx->field = NULL; \
+} while (0)
+
static int smb3_reconfigure(struct fs_context *fc)
{
struct smb3_fs_context *ctx = smb3_fc2context(fc);
@@ -647,10 +688,16 @@ static int smb3_reconfigure(struct fs_context *fc)
return rc;
/*
- * Steal the UNC from the old and to be destroyed context.
+ * We can not change UNC/username/password/domainname/nodename/iocharset
+ * during reconnect so ignore what we have in the new context and
+ * just use what we already have in cifs_sb->ctx.
*/
- ctx->UNC = cifs_sb->ctx->UNC;
- cifs_sb->ctx->UNC = NULL;
+ STEAL_STRING(cifs_sb, ctx, UNC);
+ STEAL_STRING(cifs_sb, ctx, username);
+ STEAL_STRING(cifs_sb, ctx, password);
+ STEAL_STRING(cifs_sb, ctx, domainname);
+ STEAL_STRING(cifs_sb, ctx, nodename);
+ STEAL_STRING(cifs_sb, ctx, iocharset);
smb3_cleanup_fs_context_contents(cifs_sb->ctx);
rc = smb3_fs_context_dup(cifs_sb->ctx, ctx);
diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
index 7c794df7a874..1680d0ceed38 100644
--- a/fs/cifs/fs_context.h
+++ b/fs/cifs/fs_context.h
@@ -149,7 +149,6 @@ struct smb3_fs_context {
bool uid_specified;
bool gid_specified;
bool sloppy;
- char *nodename;
bool got_ip;
bool got_version;
bool got_rsize;
@@ -161,6 +160,7 @@ struct smb3_fs_context {
char *password;
char *domainname;
char *UNC;
+ char *nodename;
char *iocharset; /* local code page for mapping to and from Unicode */
char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 05/12] cifs: simplify handling of cifs_sb/ctx->local_nls
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (2 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 04/12] cifs: we do not allow changing username/password/unc/... during remount Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 06/12] cifs: don't create a temp nls in cifs_setup_ipc Ronnie Sahlberg
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Only load/unload local_nls from cifs_sb and just make the ctx
contain a pointer to cifs_sb->ctx.
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifsproto.h | 4 +---
fs/cifs/connect.c | 29 ++++++++++++++---------------
fs/cifs/fs_context.c | 4 ----
fs/cifs/fs_context.h | 2 +-
fs/cifs/sess.c | 23 +++++++++++------------
5 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 891c8d8c2bb5..313d252bbbe9 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -598,9 +598,7 @@ extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
unsigned int *len, unsigned int *offset);
struct cifs_chan *
cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server);
-int cifs_try_adding_channels(struct cifs_ses *ses);
-int cifs_ses_add_channel(struct cifs_ses *ses,
- struct cifs_server_iface *iface);
+int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);
bool is_server_using_iface(struct TCP_Server_Info *server,
struct cifs_server_iface *iface);
bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index ceb660e1b601..62daed702e51 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2703,7 +2703,19 @@ int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
cifs_dbg(FYI, "file mode: %04ho dir mode: %04ho\n",
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)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_DFS;
@@ -3173,19 +3185,6 @@ cifs_setup_volume_info(struct smb3_fs_context *ctx)
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;
}
@@ -3507,7 +3506,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
out:
free_xid(xid);
- cifs_try_adding_channels(ses);
+ cifs_try_adding_channels(cifs_sb, ses);
return mount_setup_tlink(cifs_sb, ses, tcon);
error:
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index d312d4bac3d1..40a5cfe0615b 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -303,7 +303,6 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
memcpy(new_ctx, ctx, sizeof(*ctx));
new_ctx->prepath = NULL;
new_ctx->mount_options = NULL;
- new_ctx->local_nls = NULL;
new_ctx->nodename = NULL;
new_ctx->username = NULL;
new_ctx->password = NULL;
@@ -1349,9 +1348,6 @@ smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
ctx->iocharset = NULL;
kfree(ctx->prepath);
ctx->prepath = NULL;
-
- unload_nls(ctx->local_nls);
- ctx->local_nls = NULL;
}
void
diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
index 1680d0ceed38..2519108eeb29 100644
--- a/fs/cifs/fs_context.h
+++ b/fs/cifs/fs_context.h
@@ -237,7 +237,7 @@ struct smb3_fs_context {
char *prepath;
struct sockaddr_storage dstaddr; /* destination address */
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 */
__u64 snapshot_time; /* needed for timewarp tokens */
__u32 handle_timeout; /* persistent and durable handle timeout in ms */
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 00ca687a17dd..213465718fa8 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -34,6 +34,10 @@
#include "smb2proto.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
is_server_using_iface(struct TCP_Server_Info *server,
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 */
-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 left = ses->chan_max - ses->chan_count;
@@ -134,7 +138,7 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
continue;
}
- rc = cifs_ses_add_channel(ses, iface);
+ rc = cifs_ses_add_channel(cifs_sb, ses, iface);
if (rc) {
cifs_dbg(FYI, "failed to open extra channel on iface#%d rc=%d\n",
i, rc);
@@ -167,8 +171,9 @@ cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server)
return NULL;
}
-int
-cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
+static int
+cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
+ struct cifs_server_iface *iface)
{
struct cifs_chan *chan;
struct smb3_fs_context ctx = {NULL};
@@ -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
* 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 */
ctx.rdma = iface->rdma_capable;
@@ -275,7 +275,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
if (rc)
goto out;
- rc = cifs_setup_session(xid, ses, ctx.local_nls);
+ rc = cifs_setup_session(xid, ses, cifs_sb->local_nls);
if (rc)
goto out;
@@ -298,7 +298,6 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
if (rc && chan->server)
cifs_put_tcp_session(chan->server, 0);
- unload_nls(ctx.local_nls);
return rc;
}
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 06/12] cifs: don't create a temp nls in cifs_setup_ipc
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (3 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 05/12] cifs: simplify handling of cifs_sb/ctx->local_nls Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 07/12] cifs: uncomplicate printing the iocharset parameter Ronnie Sahlberg
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
just use the one that is already available in ctx
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/connect.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 62daed702e51..926a8b310366 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1464,7 +1464,6 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb3_fs_context *ctx)
{
int rc = 0, xid;
struct cifs_tcon *tcon;
- struct nls_table *nls_codepage;
char unc[SERVER_NAME_LENGTH + sizeof("//x/IPC$")] = {0};
bool seal = false;
struct TCP_Server_Info *server = ses->server;
@@ -1489,14 +1488,11 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb3_fs_context *ctx)
scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname);
- /* cannot fail */
- nls_codepage = load_nls_default();
-
xid = get_xid();
tcon->ses = ses;
tcon->ipc = true;
tcon->seal = seal;
- rc = server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
+ rc = server->ops->tree_connect(xid, ses, unc, tcon, ctx->local_nls);
free_xid(xid);
if (rc) {
@@ -1509,7 +1505,6 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb3_fs_context *ctx)
ses->tcon_ipc = tcon;
out:
- unload_nls(nls_codepage);
return rc;
}
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 07/12] cifs: uncomplicate printing the iocharset parameter
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (4 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 06/12] cifs: don't create a temp nls in cifs_setup_ipc Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 08/12] cifs: do not allow changing posix_paths during remount Ronnie Sahlberg
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
There is no need to load the default nls to check if the iocharset argument
was specified or not since we have it in cifs_sb->ctx
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifsfs.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 276b0659c238..229e5cbcaf18 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -462,18 +462,6 @@ cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
seq_puts(s, "loose");
}
-static void
-cifs_show_nls(struct seq_file *s, struct nls_table *cur)
-{
- struct nls_table *def;
-
- /* Display iocharset= option if it's not default charset */
- def = load_nls_default();
- if (def != cur)
- seq_printf(s, ",iocharset=%s", cur->charset);
- unload_nls(def);
-}
-
/*
* cifs_show_options() is for displaying mount options in /proc/mounts.
* Not all settable options are displayed but most of the important
@@ -537,9 +525,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
seq_printf(s, ",file_mode=0%ho,dir_mode=0%ho",
cifs_sb->ctx->file_mode,
cifs_sb->ctx->dir_mode);
-
- cifs_show_nls(s, cifs_sb->local_nls);
-
+ if (cifs_sb->ctx->iocharset)
+ seq_printf(s, ",iocharset=%s", cifs_sb->ctx->iocharset);
if (tcon->seal)
seq_puts(s, ",seal");
else if (tcon->ses->server->ignore_signature)
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 08/12] cifs: do not allow changing posix_paths during remount
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (5 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 07/12] cifs: uncomplicate printing the iocharset parameter Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 09/12] cifs: remove ctx argument from cifs_setup_cifs_sb Ronnie Sahlberg
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/fs_context.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 40a5cfe0615b..4995082b7285 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -626,6 +626,10 @@ static void smb3_fs_context_free(struct fs_context *fc)
static int smb3_verify_reconfigure_ctx(struct smb3_fs_context *new_ctx,
struct smb3_fs_context *old_ctx)
{
+ if (new_ctx->posix_paths != old_ctx->posix_paths) {
+ cifs_dbg(VFS, "can not change posixpaths during remount\n");
+ return -EINVAL;
+ }
if (new_ctx->sectype != old_ctx->sectype) {
cifs_dbg(VFS, "can not change sec during remount\n");
return -EINVAL;
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 09/12] cifs: remove ctx argument from cifs_setup_cifs_sb
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (6 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 08/12] cifs: do not allow changing posix_paths during remount Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 10/12] cifs: move update of flags into a separate function Ronnie Sahlberg
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cifsfs.c | 2 +-
fs/cifs/cifsproto.h | 3 +--
fs/cifs/connect.c | 7 ++++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 229e5cbcaf18..4c385eeecc05 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -810,7 +810,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
goto out;
}
- rc = cifs_setup_cifs_sb(cifs_sb->ctx, cifs_sb);
+ rc = cifs_setup_cifs_sb(cifs_sb);
if (rc) {
root = ERR_PTR(rc);
goto out;
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 313d252bbbe9..bd1c9b038568 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -234,8 +234,7 @@ extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
struct page *page,
unsigned int page_offset,
unsigned int to_read);
-extern int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
- struct cifs_sb_info *cifs_sb);
+extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
extern int cifs_match_super(struct super_block *, void *);
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
extern void cifs_umount(struct cifs_sb_info *);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 926a8b310366..606f36322c60 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2687,16 +2687,17 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
}
}
-int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
- struct cifs_sb_info *cifs_sb)
+int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)
{
+ struct smb3_fs_context *ctx = cifs_sb->ctx;
+
INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks);
spin_lock_init(&cifs_sb->tlink_tree_lock);
cifs_sb->tlink_tree = RB_ROOT;
cifs_dbg(FYI, "file mode: %04ho dir mode: %04ho\n",
- cifs_sb->ctx->file_mode, cifs_sb->ctx->dir_mode);
+ ctx->file_mode, ctx->dir_mode);
/* this is needed for ASCII cp to Unicode converts */
if (ctx->iocharset == NULL) {
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 10/12] cifs: move update of flags into a separate function
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (7 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 09/12] cifs: remove ctx argument from cifs_setup_cifs_sb Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 11/12] cifs: update mnt_cifs_flags during reconfigure Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 12/12] cifs: fix uninitialized variable in smb3_fs_context_parse_param Ronnie Sahlberg
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
This funciton will set/clear flags that can be changed during mount or remount
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/connect.c | 74 +-----------------------
fs/cifs/fs_context.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++
fs/cifs/fs_context.h | 1 +
3 files changed, 159 insertions(+), 71 deletions(-)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 606f36322c60..592cc6e365af 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2713,61 +2713,10 @@ int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)
}
ctx->local_nls = cifs_sb->local_nls;
- if (ctx->nodfs)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_DFS;
- if (ctx->noperm)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
- if (ctx->setuids)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
- if (ctx->setuidfromacl)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UID_FROM_ACL;
- if (ctx->server_ino)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
- if (ctx->remap)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SFM_CHR;
- if (ctx->sfu_remap)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
- if (ctx->no_xattr)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
- if (ctx->sfu_emul)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
- if (ctx->nobrl)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
- if (ctx->nohandlecache)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_HANDLE_CACHE;
- if (ctx->nostrictsync)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOSSYNC;
- if (ctx->mand_lock)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL;
- if (ctx->rwpidforward)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD;
- if (ctx->mode_ace)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MODE_FROM_SID;
- if (ctx->cifs_acl)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
- if (ctx->backupuid_specified) {
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID;
- }
- if (ctx->backupgid_specified) {
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID;
- }
- if (ctx->override_uid)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
- if (ctx->override_gid)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
- if (ctx->dynperm)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM;
- if (ctx->fsc)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_FSCACHE;
- if (ctx->multiuser)
- cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_MULTIUSER |
- CIFS_MOUNT_NO_PERM);
- if (ctx->strict_io)
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_STRICT_IO;
- if (ctx->direct_io) {
+ smb3_update_mnt_flags(cifs_sb);
+
+ if (ctx->direct_io)
cifs_dbg(FYI, "mounting share using direct i/o\n");
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
- }
if (ctx->cache_ro) {
cifs_dbg(VFS, "mounting share with read only caching. Ensure that the share will not be modified while in use.\n");
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RO_CACHE;
@@ -2776,23 +2725,6 @@ int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)
cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_RO_CACHE |
CIFS_MOUNT_RW_CACHE);
}
- if (ctx->mfsymlinks) {
- if (ctx->sfu_emul) {
- /*
- * Our SFU ("Services for Unix" emulation does not allow
- * creating symlinks but does allow reading existing SFU
- * symlinks (it does allow both creating and reading SFU
- * style mknod and FIFOs though). When "mfsymlinks" and
- * "sfu" are both enabled at the same time, it allows
- * reading both types of symlinks, but will only create
- * them with mfsymlinks format. This allows better
- * Apple compatibility (probably better for Samba too)
- * while still recognizing old Windows style symlinks.
- */
- cifs_dbg(VFS, "mount options mfsymlinks and sfu both enabled\n");
- }
- cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MF_SYMLINKS;
- }
if ((ctx->cifs_acl) && (ctx->dynperm))
cifs_dbg(VFS, "mount option dynperm ignored if cifsacl mount option supported\n");
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 4995082b7285..c1e53121526d 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -1362,3 +1362,158 @@ smb3_cleanup_fs_context(struct smb3_fs_context *ctx)
smb3_cleanup_fs_context_contents(ctx);
kfree(ctx);
}
+
+void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb)
+{
+ struct smb3_fs_context *ctx = cifs_sb->ctx;
+
+ if (ctx->nodfs)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_DFS;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_DFS;
+
+ if (ctx->noperm)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_PERM;
+
+ if (ctx->setuids)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SET_UID;
+
+ if (ctx->setuidfromacl)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UID_FROM_ACL;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_UID_FROM_ACL;
+
+ if (ctx->server_ino)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
+
+ if (ctx->remap)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SFM_CHR;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MAP_SFM_CHR;
+
+ if (ctx->sfu_remap)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MAP_SPECIAL_CHR;
+
+ if (ctx->no_xattr)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_XATTR;
+
+ if (ctx->sfu_emul)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_UNX_EMUL;
+
+ if (ctx->nobrl)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_BRL;
+
+ if (ctx->nohandlecache)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_HANDLE_CACHE;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_HANDLE_CACHE;
+
+ if (ctx->nostrictsync)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOSSYNC;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NOSSYNC;
+
+ if (ctx->mand_lock)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NOPOSIXBRL;
+
+ if (ctx->rwpidforward)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_RWPIDFORWARD;
+
+ if (ctx->mode_ace)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MODE_FROM_SID;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MODE_FROM_SID;
+
+ if (ctx->cifs_acl)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_CIFS_ACL;
+
+ if (ctx->backupuid_specified)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_CIFS_BACKUPUID;
+
+ if (ctx->backupgid_specified)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_CIFS_BACKUPGID;
+
+ if (ctx->override_uid)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_OVERR_UID;
+
+ if (ctx->override_gid)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_OVERR_GID;
+
+ if (ctx->dynperm)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_DYNPERM;
+
+ if (ctx->fsc)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_FSCACHE;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_FSCACHE;
+
+ if (ctx->multiuser)
+ cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_MULTIUSER |
+ CIFS_MOUNT_NO_PERM);
+ else
+ cifs_sb->mnt_cifs_flags &= ~(CIFS_MOUNT_MULTIUSER |
+ CIFS_MOUNT_NO_PERM);
+
+ if (ctx->strict_io)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_STRICT_IO;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_STRICT_IO;
+
+ if (ctx->direct_io)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_DIRECT_IO;
+
+ if (ctx->mfsymlinks)
+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MF_SYMLINKS;
+ else
+ cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MF_SYMLINKS;
+ if (ctx->mfsymlinks) {
+ if (ctx->sfu_emul) {
+ /*
+ * Our SFU ("Services for Unix" emulation does not allow
+ * creating symlinks but does allow reading existing SFU
+ * symlinks (it does allow both creating and reading SFU
+ * style mknod and FIFOs though). When "mfsymlinks" and
+ * "sfu" are both enabled at the same time, it allows
+ * reading both types of symlinks, but will only create
+ * them with mfsymlinks format. This allows better
+ * Apple compatibility (probably better for Samba too)
+ * while still recognizing old Windows style symlinks.
+ */
+ cifs_dbg(VFS, "mount options mfsymlinks and sfu both enabled\n");
+ }
+ }
+
+ return;
+}
diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
index 2519108eeb29..3358b33abcd0 100644
--- a/fs/cifs/fs_context.h
+++ b/fs/cifs/fs_context.h
@@ -266,5 +266,6 @@ static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *f
}
extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
+extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
#endif
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 11/12] cifs: update mnt_cifs_flags during reconfigure
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (8 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 10/12] cifs: move update of flags into a separate function Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 12/12] cifs: fix uninitialized variable in smb3_fs_context_parse_param Ronnie Sahlberg
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/fs_context.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index c1e53121526d..84a86e91127b 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -704,6 +704,7 @@ static int smb3_reconfigure(struct fs_context *fc)
smb3_cleanup_fs_context_contents(cifs_sb->ctx);
rc = smb3_fs_context_dup(cifs_sb->ctx, ctx);
+ smb3_update_mnt_flags(cifs_sb);
return rc;
}
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 12/12] cifs: fix uninitialized variable in smb3_fs_context_parse_param
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
` (9 preceding siblings ...)
2020-12-14 6:40 ` [PATCH 11/12] cifs: update mnt_cifs_flags during reconfigure Ronnie Sahlberg
@ 2020-12-14 6:40 ` Ronnie Sahlberg
10 siblings, 0 replies; 12+ messages in thread
From: Ronnie Sahlberg @ 2020-12-14 6:40 UTC (permalink / raw)
To: linux-cifs; +Cc: Steve French
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/fs_context.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 84a86e91127b..a6ca0a3dee76 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -725,8 +725,10 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
* we will need special handling of them.
*/
if (param->type == fs_value_is_string && param->string[0] == 0) {
- if (!strcmp("pass", param->key) || !strcmp("password", param->key))
+ if (!strcmp("pass", param->key) || !strcmp("password", param->key)) {
skip_parsing = true;
+ opt = Opt_pass;
+ }
}
if (!skip_parsing) {
--
2.13.6
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-12-14 6:42 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 6:40 [PATCH 01/12] cifs: move cifs_cleanup_volume_info[_content] to fs_context.c Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 02/12] cifs: move [brw]size from cifs_sb to cifs_sb->ctx Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 03/12] cifs: add initial reconfigure support Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 04/12] cifs: we do not allow changing username/password/unc/... during remount Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 05/12] cifs: simplify handling of cifs_sb/ctx->local_nls Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 06/12] cifs: don't create a temp nls in cifs_setup_ipc Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 07/12] cifs: uncomplicate printing the iocharset parameter Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 08/12] cifs: do not allow changing posix_paths during remount Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 09/12] cifs: remove ctx argument from cifs_setup_cifs_sb Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 10/12] cifs: move update of flags into a separate function Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 11/12] cifs: update mnt_cifs_flags during reconfigure Ronnie Sahlberg
2020-12-14 6:40 ` [PATCH 12/12] cifs: fix uninitialized variable in smb3_fs_context_parse_param Ronnie Sahlberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).