Skip to content

Commit 6e2a103

Browse files
neilbrownAnna Schumaker
authored andcommitted
NFSv3: only use NFS timeout for MOUNT when protocols are compatible
If a timeout is specified in the mount options, it currently applies to both the NFS protocol and (with v3) the MOUNT protocol. This is sensible when they both use the same underlying protocol, or those protocols are compatible w.r.t timeouts as RDMA and TCP are. However if, for example, NFS is using TCP and MOUNT is using UDP then using the same timeout doesn't make much sense. If you mount -o vers=3,proto=tcp,mountproto=udp,timeo=600,retrans=5 \ server:/path /mountpoint then the timeo=600 which was intended for the NFS/TCP request will apply to the MOUNT/UDP requests with the result that there will only be one request sent (because UDP has a maximum timeout of 60 seconds). This is not what a reasonable person might expect. This patch disables the sharing of timeout information in cases where the underlying protocols are not compatible. Fixes: c9301cb ("nfs: hornor timeo and retrans option when mounting NFSv3") Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 10f0740 commit 6e2a103

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/nfs/super.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,15 @@ static int nfs_request_mount(struct fs_context *fc,
885885
* Now ask the mount server to map our export path
886886
* to a file handle.
887887
*/
888-
status = nfs_mount(&request, ctx->timeo, ctx->retrans);
888+
if ((request.protocol == XPRT_TRANSPORT_UDP) ==
889+
!(ctx->flags & NFS_MOUNT_TCP))
890+
/*
891+
* NFS protocol and mount protocol are both UDP or neither UDP
892+
* so timeouts are compatible. Use NFS timeouts for MOUNT
893+
*/
894+
status = nfs_mount(&request, ctx->timeo, ctx->retrans);
895+
else
896+
status = nfs_mount(&request, NFS_UNSPEC_TIMEO, NFS_UNSPEC_RETRANS);
889897
if (status != 0) {
890898
dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
891899
request.hostname, status);

0 commit comments

Comments
 (0)