Skip to content

Commit 1443f76

Browse files
chenhanxiaoTrond Myklebust
authored andcommitted
nfs: fix regression in handling of fsc= option in NFSv4
Setting the uniquifier for fscache via the fsc= mount option is currently broken in NFSv4. Fix this by passing fscache_uniq to root_fc if possible. Signed-off-by: Chen Hanxiao <chenhx.fnst@fujitsu.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 47f7c95 commit 1443f76

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

fs/nfs/nfs4super.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ static int do_nfs4_mount(struct nfs_server *server,
145145
const char *export_path)
146146
{
147147
struct nfs_fs_context *root_ctx;
148+
struct nfs_fs_context *ctx;
148149
struct fs_context *root_fc;
149150
struct vfsmount *root_mnt;
150151
struct dentry *dentry;
@@ -157,6 +158,12 @@ static int do_nfs4_mount(struct nfs_server *server,
157158
.dirfd = -1,
158159
};
159160

161+
struct fs_parameter param_fsc = {
162+
.key = "fsc",
163+
.type = fs_value_is_string,
164+
.dirfd = -1,
165+
};
166+
160167
if (IS_ERR(server))
161168
return PTR_ERR(server);
162169

@@ -168,9 +175,26 @@ static int do_nfs4_mount(struct nfs_server *server,
168175
kfree(root_fc->source);
169176
root_fc->source = NULL;
170177

178+
ctx = nfs_fc2context(fc);
171179
root_ctx = nfs_fc2context(root_fc);
172180
root_ctx->internal = true;
173181
root_ctx->server = server;
182+
183+
if (ctx->fscache_uniq) {
184+
len = strlen(ctx->fscache_uniq);
185+
param_fsc.size = len;
186+
param_fsc.string = kmemdup_nul(ctx->fscache_uniq, len, GFP_KERNEL);
187+
if (param_fsc.string == NULL) {
188+
put_fs_context(root_fc);
189+
return -ENOMEM;
190+
}
191+
ret = vfs_parse_fs_param(root_fc, &param_fsc);
192+
kfree(param_fsc.string);
193+
if (ret < 0) {
194+
put_fs_context(root_fc);
195+
return ret;
196+
}
197+
}
174198
/* We leave export_path unset as it's not used to find the root. */
175199

176200
len = strlen(hostname) + 5;

0 commit comments

Comments
 (0)