]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cifs: move [brw]size from cifs_sb to cifs_sb->ctx
authorRonnie Sahlberg <lsahlber@redhat.com>
Mon, 14 Dec 2020 06:40:17 +0000 (16:40 +1000)
committerSteve French <stfrench@microsoft.com>
Mon, 14 Dec 2020 15:26:30 +0000 (09:26 -0600)
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifs_fs_sb.h
fs/cifs/cifsfs.c
fs/cifs/connect.c
fs/cifs/file.c
fs/cifs/fs_context.c
fs/cifs/fs_context.h
fs/cifs/inode.c
fs/cifs/smb1ops.c
fs/cifs/smb2ops.c

index 69d26313d350ba902a8a52bb1b4e45a9d52fa1d3..aa77edc12212680e53291806c0e98769d95031b8 100644 (file)
@@ -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;
index 9c2959f552e0f3b094a9abeec88bd3f8f0bfee7f..6a3cb192d75a8c572d12b703d9d993015b4a5840 100644 (file)
@@ -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",
index 16d92ff4ae5ed6f3bb436e7ea7aa5eda07a562fc..eb036cf0f6310a9b49ed48cb09c116df15a6e92b 100644 (file)
@@ -2248,10 +2248,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) ||
@@ -2714,14 +2714,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);
 
@@ -2925,8 +2917,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;
 }
index 583074546e6ff116444418bfb26ada57c9c15b5d..6d001905c8e51af170559f67b26609af5fb48afc 100644 (file)
@@ -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 @@ retry:
                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;
index 4d8caf5b951991dc10262c0ea4d1c5c88c7dce53..b7f5633a1c64051b09014ac575cc9204788b59c5 100644 (file)
@@ -784,12 +784,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;
index 4c4c392b97674d4a87a6db564695fb253b0e36b4..7c794df7a87432a51cdd78266c72f9efc4dc2a97 100644 (file)
@@ -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;
index 240d79e3aa14ea8aeba51766f9a7f4522d87577f..a83b3a8ffaacca690838f66fe4048efe89caf6db 100644 (file)
@@ -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 */
index 359a0ef796de4163f7b5a976e2a8de3b60bc7386..e31b939e628cc4f8c0d195290f6ed6bdae037a47 100644 (file)
@@ -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
index 940e61e92a8c8a6179f791d30bf9a293544a9690..a505cc3e58dab1859081a0e722361b17ec31880a 100644 (file)
@@ -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);
 }