Commit c5d120f8 authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

NFS: introduce nfs_mount_info struct for calling nfs_mount()

Clean up: convert nfs_mount() to take a single data structure argument to make
it simpler to add more arguments.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 146ec944
...@@ -64,8 +64,17 @@ struct nfs_parsed_mount_data { ...@@ -64,8 +64,17 @@ struct nfs_parsed_mount_data {
}; };
/* mount_clnt.c */ /* mount_clnt.c */
extern int nfs_mount(struct sockaddr *, size_t, char *, char *, struct nfs_mount_request {
int, int, struct nfs_fh *); struct sockaddr *sap;
size_t salen;
char *hostname;
char *dirpath;
u32 version;
unsigned short protocol;
struct nfs_fh *fh;
};
extern int nfs_mount(struct nfs_mount_request *info);
/* client.c */ /* client.c */
extern struct rpc_program nfs_program; extern struct rpc_program nfs_program;
......
...@@ -29,33 +29,26 @@ struct mnt_fhstatus { ...@@ -29,33 +29,26 @@ struct mnt_fhstatus {
/** /**
* nfs_mount - Obtain an NFS file handle for the given host and path * nfs_mount - Obtain an NFS file handle for the given host and path
* @addr: pointer to server's address * @info: pointer to mount request arguments
* @len: size of server's address
* @hostname: name of server host, or NULL
* @path: pointer to string containing export path to mount
* @version: mount version to use for this request
* @protocol: transport protocol to use for thie request
* @fh: pointer to location to place returned file handle
* *
* Uses default timeout parameters specified by underlying transport. * Uses default timeout parameters specified by underlying transport.
*/ */
int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path, int nfs_mount(struct nfs_mount_request *info)
int version, int protocol, struct nfs_fh *fh)
{ {
struct mnt_fhstatus result = { struct mnt_fhstatus result = {
.fh = fh .fh = info->fh
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_argp = path, .rpc_argp = info->dirpath,
.rpc_resp = &result, .rpc_resp = &result,
}; };
struct rpc_create_args args = { struct rpc_create_args args = {
.protocol = protocol, .protocol = info->protocol,
.address = addr, .address = info->sap,
.addrsize = len, .addrsize = info->salen,
.servername = hostname, .servername = info->hostname,
.program = &mnt_program, .program = &mnt_program,
.version = version, .version = info->version,
.authflavor = RPC_AUTH_UNIX, .authflavor = RPC_AUTH_UNIX,
.flags = 0, .flags = 0,
}; };
...@@ -63,13 +56,14 @@ int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path, ...@@ -63,13 +56,14 @@ int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path,
int status; int status;
dprintk("NFS: sending MNT request for %s:%s\n", dprintk("NFS: sending MNT request for %s:%s\n",
(hostname ? hostname : "server"), path); (info->hostname ? info->hostname : "server"),
info->dirpath);
mnt_clnt = rpc_create(&args); mnt_clnt = rpc_create(&args);
if (IS_ERR(mnt_clnt)) if (IS_ERR(mnt_clnt))
goto out_clnt_err; goto out_clnt_err;
if (version == NFS_MNT3_VERSION) if (info->version == NFS_MNT3_VERSION)
msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC3_MNT]; msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC3_MNT];
else else
msg.rpc_proc = &mnt_clnt->cl_procinfo[MNTPROC_MNT]; msg.rpc_proc = &mnt_clnt->cl_procinfo[MNTPROC_MNT];
......
...@@ -487,15 +487,20 @@ static int __init root_nfs_get_handle(void) ...@@ -487,15 +487,20 @@ static int __init root_nfs_get_handle(void)
{ {
struct nfs_fh fh; struct nfs_fh fh;
struct sockaddr_in sin; struct sockaddr_in sin;
struct nfs_mount_request request = {
.sap = (struct sockaddr *)&sin,
.salen = sizeof(sin),
.dirpath = nfs_export_path,
.version = (nfs_data.flags & NFS_MOUNT_VER3) ?
NFS_MNT3_VERSION : NFS_MNT_VERSION,
.protocol = (nfs_data.flags & NFS_MOUNT_TCP) ?
XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP,
.fh = &fh,
};
int status; int status;
int protocol = (nfs_data.flags & NFS_MOUNT_TCP) ?
XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP;
int version = (nfs_data.flags & NFS_MOUNT_VER3) ?
NFS_MNT3_VERSION : NFS_MNT_VERSION;
set_sockaddr(&sin, servaddr, htons(mount_port)); set_sockaddr(&sin, servaddr, htons(mount_port));
status = nfs_mount((struct sockaddr *) &sin, sizeof(sin), NULL, status = nfs_mount(&request);
nfs_export_path, version, protocol, &fh);
if (status < 0) if (status < 0)
printk(KERN_ERR "Root-NFS: Server returned error %d " printk(KERN_ERR "Root-NFS: Server returned error %d "
"while mounting %s\n", status, nfs_export_path); "while mounting %s\n", status, nfs_export_path);
......
...@@ -1329,8 +1329,13 @@ static int nfs_parse_mount_options(char *raw, ...@@ -1329,8 +1329,13 @@ static int nfs_parse_mount_options(char *raw,
static int nfs_try_mount(struct nfs_parsed_mount_data *args, static int nfs_try_mount(struct nfs_parsed_mount_data *args,
struct nfs_fh *root_fh) struct nfs_fh *root_fh)
{ {
struct sockaddr *sap = (struct sockaddr *)&args->mount_server.address; struct nfs_mount_request request = {
char *hostname; .sap = (struct sockaddr *)
&args->mount_server.address,
.dirpath = args->nfs_server.export_path,
.protocol = args->mount_server.protocol,
.fh = root_fh,
};
int status; int status;
if (args->mount_server.version == 0) { if (args->mount_server.version == 0) {
...@@ -1339,42 +1344,38 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, ...@@ -1339,42 +1344,38 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
else else
args->mount_server.version = NFS_MNT_VERSION; args->mount_server.version = NFS_MNT_VERSION;
} }
request.version = args->mount_server.version;
if (args->mount_server.hostname) if (args->mount_server.hostname)
hostname = args->mount_server.hostname; request.hostname = args->mount_server.hostname;
else else
hostname = args->nfs_server.hostname; request.hostname = args->nfs_server.hostname;
/* /*
* Construct the mount server's address. * Construct the mount server's address.
*/ */
if (args->mount_server.address.ss_family == AF_UNSPEC) { if (args->mount_server.address.ss_family == AF_UNSPEC) {
memcpy(sap, &args->nfs_server.address, memcpy(request.sap, &args->nfs_server.address,
args->nfs_server.addrlen); args->nfs_server.addrlen);
args->mount_server.addrlen = args->nfs_server.addrlen; args->mount_server.addrlen = args->nfs_server.addrlen;
} }
request.salen = args->mount_server.addrlen;
/* /*
* autobind will be used if mount_server.port == 0 * autobind will be used if mount_server.port == 0
*/ */
nfs_set_port(sap, args->mount_server.port); nfs_set_port(request.sap, args->mount_server.port);
/* /*
* Now ask the mount server to map our export path * Now ask the mount server to map our export path
* to a file handle. * to a file handle.
*/ */
status = nfs_mount(sap, status = nfs_mount(&request);
args->mount_server.addrlen,
hostname,
args->nfs_server.export_path,
args->mount_server.version,
args->mount_server.protocol,
root_fh);
if (status == 0) if (status == 0)
return 0; return 0;
dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n", dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
hostname, status); request.hostname, status);
return status; return status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment