NFS: Remake nfsroot_mount as a permanent part of NFS client

In preparation for supporting NFSv2 and NFSv3 mount option handling in the
kernel NFS client, convert mount_clnt.c to be a permanent part of the NFS
client, instead of built only when CONFIG_ROOT_NFS is enabled.

In addition, we also replace the "struct sockaddr_in *" argument with
something more generic, to help support IPv6 at some later point.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Chuck Lever 2007-07-01 12:13:27 -04:00 committed by Trond Myklebust
parent 43780b87fa
commit 3ea97309e6
4 changed files with 34 additions and 33 deletions

View File

@ -6,8 +6,8 @@ obj-$(CONFIG_NFS_FS) += nfs.o
nfs-y := client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \ nfs-y := client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \
pagelist.o proc.o read.o symlink.o unlink.o \ pagelist.o proc.o read.o symlink.o unlink.o \
write.o namespace.o write.o namespace.o mount_clnt.o
nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o
nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \

View File

@ -18,7 +18,7 @@
#include <linux/nfs_fs.h> #include <linux/nfs_fs.h>
#ifdef RPC_DEBUG #ifdef RPC_DEBUG
# define NFSDBG_FACILITY NFSDBG_ROOT # define NFSDBG_FACILITY NFSDBG_MOUNT
#endif #endif
/* /*
@ -28,7 +28,6 @@
#define MOUNT_UMNT 3 #define MOUNT_UMNT 3
*/ */
static struct rpc_clnt * mnt_create(struct sockaddr_in *, int, int);
static struct rpc_program mnt_program; static struct rpc_program mnt_program;
struct mnt_fhstatus { struct mnt_fhstatus {
@ -36,14 +35,21 @@ struct mnt_fhstatus {
struct nfs_fh * fh; struct nfs_fh * fh;
}; };
/* /**
* 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
* @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.
*/ */
int int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path,
nfsroot_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh, int version, int protocol, struct nfs_fh *fh)
int version, int protocol)
{ {
struct rpc_clnt *mnt_clnt;
struct mnt_fhstatus result = { struct mnt_fhstatus result = {
.fh = fh .fh = fh
}; };
@ -51,12 +57,23 @@ nfsroot_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh,
.rpc_argp = path, .rpc_argp = path,
.rpc_resp = &result, .rpc_resp = &result,
}; };
struct rpc_create_args args = {
.protocol = protocol,
.address = addr,
.addrsize = len,
.servername = hostname,
.program = &mnt_program,
.version = version,
.authflavor = RPC_AUTH_UNIX,
.flags = RPC_CLNT_CREATE_INTR,
};
struct rpc_clnt *mnt_clnt;
int status; int status;
dprintk("NFS: nfs_mount(%08x:%s)\n", dprintk("NFS: sending MNT request for %s:%s\n",
(unsigned)ntohl(addr->sin_addr.s_addr), path); (hostname ? hostname : "server"), path);
mnt_clnt = mnt_create(addr, version, protocol); mnt_clnt = rpc_create(&args);
if (IS_ERR(mnt_clnt)) if (IS_ERR(mnt_clnt))
return PTR_ERR(mnt_clnt); return PTR_ERR(mnt_clnt);
@ -70,22 +87,6 @@ nfsroot_mount(struct sockaddr_in *addr, char *path, struct nfs_fh *fh,
return status < 0? status : (result.status? -EACCES : 0); return status < 0? status : (result.status? -EACCES : 0);
} }
static struct rpc_clnt *mnt_create(struct sockaddr_in *srvaddr, int version,
int protocol)
{
struct rpc_create_args args = {
.protocol = protocol,
.address = (struct sockaddr *)srvaddr,
.addrsize = sizeof(*srvaddr),
.program = &mnt_program,
.version = version,
.authflavor = RPC_AUTH_UNIX,
.flags = RPC_CLNT_CREATE_INTR,
};
return rpc_create(&args);
}
/* /*
* XDR encode/decode functions for MOUNT * XDR encode/decode functions for MOUNT
*/ */

View File

@ -496,7 +496,8 @@ static int __init root_nfs_get_handle(void)
NFS_MNT3_VERSION : NFS_MNT_VERSION; NFS_MNT3_VERSION : NFS_MNT_VERSION;
set_sockaddr(&sin, servaddr, htons(mount_port)); set_sockaddr(&sin, servaddr, htons(mount_port));
status = nfsroot_mount(&sin, nfs_path, &fh, version, protocol); status = nfs_mount((struct sockaddr *) &sin, sizeof(sin), NULL,
nfs_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_path); "while mounting %s\n", status, nfs_path);

View File

@ -494,10 +494,9 @@ static inline void nfs3_forget_cached_acls(struct inode *inode)
/* /*
* linux/fs/mount_clnt.c * linux/fs/mount_clnt.c
* (Used only by nfsroot module)
*/ */
extern int nfsroot_mount(struct sockaddr_in *, char *, struct nfs_fh *, extern int nfs_mount(struct sockaddr *, size_t, char *, char *,
int, int); int, int, struct nfs_fh *);
/* /*
* inline functions * inline functions