Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 62a55d088cd8 ("NFS: Additional refactoring for fs_context conversion")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

+43 -17
+17 -4
fs/nfs/client.c
··· 784 784 server->fattr_valid = NFS_ATTR_FATTR_V4; 785 785 } 786 786 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) { 788 792 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) { 790 796 server->wsize = nfs_io_size(ctx->wsize, clp->cl_proto); 797 + server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_WSIZE; 798 + } 791 799 792 800 server->acregmin = ctx->acregmin * HZ; 793 801 server->acregmax = ctx->acregmax * HZ; ··· 985 977 void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source) 986 978 { 987 979 target->flags = source->flags; 988 - target->rsize = source->rsize; 989 - target->wsize = source->wsize; 980 + target->automount_inherit = source->automount_inherit; 981 + if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_BSIZE) 982 + target->bsize = source->bsize; 983 + if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_RSIZE) 984 + target->rsize = source->rsize; 985 + if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_WSIZE) 986 + target->wsize = source->wsize; 990 987 target->acregmin = source->acregmin; 991 988 target->acregmax = source->acregmax; 992 989 target->acdirmin = source->acdirmin;
-1
fs/nfs/internal.h
··· 152 152 struct super_block *sb; 153 153 struct dentry *dentry; 154 154 struct nfs_fattr *fattr; 155 - unsigned int inherited_bsize; 156 155 } clone_data; 157 156 }; 158 157
+4 -1
fs/nfs/namespace.c
··· 190 190 ctx->nfs_mod = client->cl_nfs_mod; 191 191 get_nfs_version(ctx->nfs_mod); 192 192 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 + 193 197 ret = client->rpc_ops->submount(fc, server); 194 198 if (ret < 0) { 195 199 mnt = ERR_PTR(ret); ··· 293 289 return -ENOMEM; 294 290 295 291 ctx->internal = true; 296 - ctx->clone_data.inherited_bsize = ctx->clone_data.sb->s_blocksize_bits; 297 292 298 293 p = nfs_devname(dentry, buffer, 4096); 299 294 if (IS_ERR(p)) {
+14 -4
fs/nfs/nfs4client.c
··· 1179 1179 if (error < 0) 1180 1180 return error; 1181 1181 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 + } 1186 1196 1187 1197 server->acregmin = ctx->acregmin * HZ; 1188 1198 server->acregmax = ctx->acregmax * HZ;
+3 -7
fs/nfs/super.c
··· 1091 1091 sb->s_blocksize = 0; 1092 1092 sb->s_xattr = server->nfs_client->cl_nfs_mod->xattr; 1093 1093 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); 1096 1097 1097 1098 switch (server->nfs_client->rpc_ops->version) { 1098 1099 case 2: ··· 1339 1338 } 1340 1339 1341 1340 if (!s->s_root) { 1342 - unsigned bsize = ctx->clone_data.inherited_bsize; 1343 1341 /* initial superblock/root creation */ 1344 1342 nfs_fill_super(s, ctx); 1345 - if (bsize) { 1346 - s->s_blocksize_bits = bsize; 1347 - s->s_blocksize = 1U << bsize; 1348 - } 1349 1343 error = nfs_get_cache_cookie(s, ctx); 1350 1344 if (error < 0) 1351 1345 goto error_splat_super;
+5
include/linux/nfs_fs_sb.h
··· 172 172 #define NFS_MOUNT_FORCE_RDIRPLUS 0x20000000 173 173 #define NFS_MOUNT_NETUNREACH_FATAL 0x40000000 174 174 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 + 175 180 unsigned int caps; /* server capabilities */ 176 181 __u64 fattr_valid; /* Valid attributes */ 177 182 unsigned int rsize; /* read size */