Skip to content

Commit c9301cb

Browse files
eryugeyTrond Myklebust
authored andcommitted
nfs: hornor timeo and retrans option when mounting NFSv3
Mounting NFSv3 uses default timeout parameters specified by underlying sunrpc transport, and mount options like 'timeo' and 'retrans', unlike NFSv4, are not honored. But sometimes we want to set non-default timeout value when mounting NFSv3, so pass 'timeo' and 'retrans' to nfs_mount() and fill the 'timeout' field of struct rpc_create_args before creating RPC connection. This is also consistent with NFSv4 behavior. Note that this only sets the timeout value of rpc connection to mountd, but the timeout of rpcbind connection should be set as well. A later patch will fix the rpcbind part. Signed-off-by: Eryu Guan <eguan@linux.alibaba.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 6b99647 commit c9301cb

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

fs/nfs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct nfs_mount_request {
180180
struct net *net;
181181
};
182182

183-
extern int nfs_mount(struct nfs_mount_request *info);
183+
extern int nfs_mount(struct nfs_mount_request *info, int timeo, int retrans);
184184
extern void nfs_umount(const struct nfs_mount_request *info);
185185

186186
/* client.c */

fs/nfs/mount_clnt.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,16 @@ struct mnt_fhstatus {
136136
/**
137137
* nfs_mount - Obtain an NFS file handle for the given host and path
138138
* @info: pointer to mount request arguments
139+
* @timeo: deciseconds the mount waits for a response before it retries
140+
* @retrans: number of times the mount retries a request
139141
*
140-
* Uses default timeout parameters specified by underlying transport. On
141-
* successful return, the auth_flavs list and auth_flav_len will be populated
142-
* with the list from the server or a faked-up list if the server didn't
143-
* provide one.
142+
* Uses timeout parameters specified by caller. On successful return, the
143+
* auth_flavs list and auth_flav_len will be populated with the list from the
144+
* server or a faked-up list if the server didn't provide one.
144145
*/
145-
int nfs_mount(struct nfs_mount_request *info)
146+
int nfs_mount(struct nfs_mount_request *info, int timeo, int retrans)
146147
{
148+
struct rpc_timeout mnt_timeout;
147149
struct mountres result = {
148150
.fh = info->fh,
149151
.auth_count = info->auth_flav_len,
@@ -158,6 +160,7 @@ int nfs_mount(struct nfs_mount_request *info)
158160
.protocol = info->protocol,
159161
.address = info->sap,
160162
.addrsize = info->salen,
163+
.timeout = &mnt_timeout,
161164
.servername = info->hostname,
162165
.program = &mnt_program,
163166
.version = info->version,
@@ -177,6 +180,7 @@ int nfs_mount(struct nfs_mount_request *info)
177180
if (info->noresvport)
178181
args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
179182

183+
nfs_init_timeout_values(&mnt_timeout, info->protocol, timeo, retrans);
180184
mnt_clnt = rpc_create(&args);
181185
if (IS_ERR(mnt_clnt))
182186
goto out_clnt_err;

fs/nfs/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ static int nfs_request_mount(struct fs_context *fc,
867867
* Now ask the mount server to map our export path
868868
* to a file handle.
869869
*/
870-
status = nfs_mount(&request);
870+
status = nfs_mount(&request, ctx->timeo, ctx->retrans);
871871
if (status != 0) {
872872
dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
873873
request.hostname, status);

0 commit comments

Comments
 (0)