Skip to content

Commit b322bf9

Browse files
martin-kaiserTrond Myklebust
authored andcommitted
nfs: keep server info for remounts
With newer kernels that use fs_context for nfs mounts, remounts fail with -EINVAL. $ mount -t nfs -o nolock 10.0.0.1:/tmp/test /mnt/test/ $ mount -t nfs -o remount /mnt/test/ mount: mounting 10.0.0.1:/tmp/test on /mnt/test failed: Invalid argument For remounts, the nfs server address and port are populated by nfs_init_fs_context and later overwritten with 0x00 bytes by nfs23_parse_monolithic. The remount then fails as the server address is invalid. Fix this by not overwriting nfs server info in nfs23_parse_monolithic if we're doing a remount. Fixes: f2aedb7 ("NFS: Add fs_context support.") Signed-off-by: Martin Kaiser <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 37ffe06 commit b322bf9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/nfs/fs_context.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,9 +1114,12 @@ static int nfs23_parse_monolithic(struct fs_context *fc,
11141114
ctx->acdirmax = data->acdirmax;
11151115
ctx->need_mount = false;
11161116

1117-
memcpy(sap, &data->addr, sizeof(data->addr));
1118-
ctx->nfs_server.addrlen = sizeof(data->addr);
1119-
ctx->nfs_server.port = ntohs(data->addr.sin_port);
1117+
if (!is_remount_fc(fc)) {
1118+
memcpy(sap, &data->addr, sizeof(data->addr));
1119+
ctx->nfs_server.addrlen = sizeof(data->addr);
1120+
ctx->nfs_server.port = ntohs(data->addr.sin_port);
1121+
}
1122+
11201123
if (sap->ss_family != AF_INET ||
11211124
!nfs_verify_server_address(sap))
11221125
goto out_no_address;

0 commit comments

Comments
 (0)