Skip to content

Commit 2b09217

Browse files
author
Trond Myklebust
committed
NFS: Fix inheritance of the block sizes when automounting
Only inherit the block sizes that were actually specified as mount parameters for the parent mount. Fixes: 62a55d0 ("NFS: Additional refactoring for fs_context conversion") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 8675c69 commit 2b09217

6 files changed

Lines changed: 43 additions & 17 deletions

File tree

fs/nfs/client.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,10 +784,18 @@ static int nfs_init_server(struct nfs_server *server,
784784
server->fattr_valid = NFS_ATTR_FATTR_V4;
785785
}
786786

787-
if (ctx->rsize)
787+
if (ctx->bsize) {
788+
server->bsize = ctx->bsize;
789+
server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_BSIZE;
790+
}
791+
if (ctx->rsize) {
788792
server->rsize = nfs_io_size(ctx->rsize, clp->cl_proto);
789-
if (ctx->wsize)
793+
server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_RSIZE;
794+
}
795+
if (ctx->wsize) {
790796
server->wsize = nfs_io_size(ctx->wsize, clp->cl_proto);
797+
server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_WSIZE;
798+
}
791799

792800
server->acregmin = ctx->acregmin * HZ;
793801
server->acregmax = ctx->acregmax * HZ;
@@ -977,8 +985,13 @@ EXPORT_SYMBOL_GPL(nfs_probe_server);
977985
void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source)
978986
{
979987
target->flags = source->flags;
980-
target->rsize = source->rsize;
981-
target->wsize = source->wsize;
988+
target->automount_inherit = source->automount_inherit;
989+
if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_BSIZE)
990+
target->bsize = source->bsize;
991+
if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_RSIZE)
992+
target->rsize = source->rsize;
993+
if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_WSIZE)
994+
target->wsize = source->wsize;
982995
target->acregmin = source->acregmin;
983996
target->acregmax = source->acregmax;
984997
target->acdirmin = source->acdirmin;

fs/nfs/internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ struct nfs_fs_context {
152152
struct super_block *sb;
153153
struct dentry *dentry;
154154
struct nfs_fattr *fattr;
155-
unsigned int inherited_bsize;
156155
} clone_data;
157156
};
158157

fs/nfs/namespace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ struct vfsmount *nfs_d_automount(struct path *path)
190190
ctx->nfs_mod = client->cl_nfs_mod;
191191
get_nfs_version(ctx->nfs_mod);
192192

193+
/* Inherit block sizes if they were specified as mount parameters */
194+
if (server->automount_inherit & NFS_AUTOMOUNT_INHERIT_BSIZE)
195+
ctx->bsize = server->bsize;
196+
193197
ret = client->rpc_ops->submount(fc, server);
194198
if (ret < 0) {
195199
mnt = ERR_PTR(ret);
@@ -289,7 +293,6 @@ int nfs_do_submount(struct fs_context *fc)
289293
return -ENOMEM;
290294

291295
ctx->internal = true;
292-
ctx->clone_data.inherited_bsize = ctx->clone_data.sb->s_blocksize_bits;
293296

294297
p = nfs_devname(dentry, buffer, 4096);
295298
if (IS_ERR(p)) {

fs/nfs/nfs4client.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,10 +1179,20 @@ static int nfs4_init_server(struct nfs_server *server, struct fs_context *fc)
11791179
if (error < 0)
11801180
return error;
11811181

1182-
if (ctx->rsize)
1183-
server->rsize = nfs_io_size(ctx->rsize, server->nfs_client->cl_proto);
1184-
if (ctx->wsize)
1185-
server->wsize = nfs_io_size(ctx->wsize, server->nfs_client->cl_proto);
1182+
if (ctx->bsize) {
1183+
server->bsize = ctx->bsize;
1184+
server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_BSIZE;
1185+
}
1186+
if (ctx->rsize) {
1187+
server->rsize =
1188+
nfs_io_size(ctx->rsize, server->nfs_client->cl_proto);
1189+
server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_RSIZE;
1190+
}
1191+
if (ctx->wsize) {
1192+
server->wsize =
1193+
nfs_io_size(ctx->wsize, server->nfs_client->cl_proto);
1194+
server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_WSIZE;
1195+
}
11861196

11871197
server->acregmin = ctx->acregmin * HZ;
11881198
server->acregmax = ctx->acregmax * HZ;

fs/nfs/super.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,9 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx)
10911091
sb->s_blocksize = 0;
10921092
sb->s_xattr = server->nfs_client->cl_nfs_mod->xattr;
10931093
sb->s_op = server->nfs_client->cl_nfs_mod->sops;
1094-
if (ctx->bsize)
1095-
sb->s_blocksize = nfs_block_size(ctx->bsize, &sb->s_blocksize_bits);
1094+
if (server->bsize)
1095+
sb->s_blocksize =
1096+
nfs_block_size(server->bsize, &sb->s_blocksize_bits);
10961097

10971098
switch (server->nfs_client->rpc_ops->version) {
10981099
case 2:
@@ -1338,13 +1339,8 @@ int nfs_get_tree_common(struct fs_context *fc)
13381339
}
13391340

13401341
if (!s->s_root) {
1341-
unsigned bsize = ctx->clone_data.inherited_bsize;
13421342
/* initial superblock/root creation */
13431343
nfs_fill_super(s, ctx);
1344-
if (bsize) {
1345-
s->s_blocksize_bits = bsize;
1346-
s->s_blocksize = 1U << bsize;
1347-
}
13481344
error = nfs_get_cache_cookie(s, ctx);
13491345
if (error < 0)
13501346
goto error_splat_super;

include/linux/nfs_fs_sb.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ struct nfs_server {
172172
#define NFS_MOUNT_FORCE_RDIRPLUS 0x20000000
173173
#define NFS_MOUNT_NETUNREACH_FATAL 0x40000000
174174

175+
unsigned int automount_inherit; /* Properties inherited by automount */
176+
#define NFS_AUTOMOUNT_INHERIT_BSIZE 0x0001
177+
#define NFS_AUTOMOUNT_INHERIT_RSIZE 0x0002
178+
#define NFS_AUTOMOUNT_INHERIT_WSIZE 0x0004
179+
175180
unsigned int caps; /* server capabilities */
176181
__u64 fattr_valid; /* Valid attributes */
177182
unsigned int rsize; /* read size */

0 commit comments

Comments
 (0)