[PATCH 2/5] NFS: Refactor nfs_mount() to move rpc_create() to helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clean up:  We want to add another function to mount_clnt.c that can
send an RPC request, so move creation of an RPC client for sending a
MNT request into a separate helper function so it can be shared.

Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---

 fs/nfs/mount_clnt.c |   51 ++++++++++++++++++++++++++++++---------------------
 1 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index 38ef9ea..b5ed325 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -135,6 +135,32 @@ struct mnt_fhstatus {
 	struct nfs_fh *fh;
 };
 
+static struct
+rpc_clnt *nfs_mount_rpc_create(const struct nfs_mount_request *info,
+			       const struct rpc_timeout *timeout)
+{
+	struct rpc_create_args args = {
+		.protocol	= info->protocol,
+		.address	= info->sap,
+		.addrsize	= info->salen,
+		.timeout	= timeout,
+		.servername	= info->hostname,
+		.program	= &mnt_program,
+		.version	= info->version,
+		.authflavor	= RPC_AUTH_UNIX,
+	};
+	struct rpc_clnt *clnt;
+
+	if (info->noresvport)
+		args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
+
+	clnt = rpc_create(&args);
+	if (unlikely(IS_ERR(clnt)))
+		dprintk("NFS: failed to create MNT RPC client, error=%ld\n",
+				PTR_ERR(clnt));
+	return clnt;
+}
+
 /**
  * nfs_mount - Obtain an NFS file handle for the given host and path
  * @info: pointer to mount request arguments
@@ -152,29 +178,17 @@ int nfs_mount(struct nfs_mount_request *info)
 		.rpc_argp	= info->dirpath,
 		.rpc_resp	= &result,
 	};
-	struct rpc_create_args args = {
-		.protocol	= info->protocol,
-		.address	= info->sap,
-		.addrsize	= info->salen,
-		.servername	= info->hostname,
-		.program	= &mnt_program,
-		.version	= info->version,
-		.authflavor	= RPC_AUTH_UNIX,
-	};
 	struct rpc_clnt		*mnt_clnt;
 	int			status;
 
+	mnt_clnt = nfs_mount_rpc_create(info, NULL);
+	if (unlikely(IS_ERR(mnt_clnt)))
+		return PTR_ERR(mnt_clnt);
+
 	dprintk("NFS: sending MNT request for %s:%s\n",
 		(info->hostname ? info->hostname : "server"),
 			info->dirpath);
 
-	if (info->noresvport)
-		args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
-
-	mnt_clnt = rpc_create(&args);
-	if (IS_ERR(mnt_clnt))
-		goto out_clnt_err;
-
 	if (info->version == NFS_MNT3_VERSION)
 		msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC3_MNT];
 	else
@@ -194,11 +208,6 @@ int nfs_mount(struct nfs_mount_request *info)
 out:
 	return status;
 
-out_clnt_err:
-	status = PTR_ERR(mnt_clnt);
-	dprintk("NFS: failed to create MNT RPC client, status=%d\n", status);
-	goto out;
-
 out_call_err:
 	dprintk("NFS: MNT request failed, status=%d\n", status);
 	goto out;

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux