summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2010-10-19 00:20:00 +0000
committerrmacklem <rmacklem@FreeBSD.org>2010-10-19 00:20:00 +0000
commit4cbec41fe48ec04d799dae677c7c44d5a703e182 (patch)
tree58fc2b105e6e1fb43a4b74746fd54253f3f2102d /sys/nfsclient
parent4393b7cb7eaacda209dfdb075d90146991a14617 (diff)
downloadFreeBSD-src-4cbec41fe48ec04d799dae677c7c44d5a703e182.zip
FreeBSD-src-4cbec41fe48ec04d799dae677c7c44d5a703e182.tar.gz
Modify the NFS clients and the NLM so that the NLM can be used
by both clients. Since the NLM uses various fields of the nfsmount structure, those fields were extracted and put in a separate nfs_mountcommon structure stored in sys/nfs/nfs_mountcommon.h. This structure also has a function pointer for a function that extracts the required information from the mount point and nfs vnode for that particular client, for information stored differently by the clients. Reviewed by: jhb MFC after: 2 weeks
Diffstat (limited to 'sys/nfsclient')
-rw-r--r--sys/nfsclient/nfs_node.c2
-rw-r--r--sys/nfsclient/nfs_vfsops.c27
-rw-r--r--sys/nfsclient/nfs_vnops.c2
-rw-r--r--sys/nfsclient/nfsmount.h21
-rw-r--r--sys/nfsclient/nfsnode.h3
5 files changed, 43 insertions, 12 deletions
diff --git a/sys/nfsclient/nfs_node.c b/sys/nfsclient/nfs_node.c
index 9e558f4..5b87bd7 100644
--- a/sys/nfsclient/nfs_node.c
+++ b/sys/nfsclient/nfs_node.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/fcntl.h>
#include <sys/fnv_hash.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -51,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <vm/uma.h>
#include <nfs/nfsproto.h>
+#include <nfs/nfs_lock.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsnode.h>
#include <nfsclient/nfsmount.h>
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index f07bf16..3175e0f 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -115,6 +115,8 @@ static void nfs_decode_args(struct mount *mp, struct nfsmount *nmp,
static int mountnfs(struct nfs_args *, struct mount *,
struct sockaddr *, char *, struct vnode **,
struct ucred *cred, int);
+static void nfs_getnlminfo(struct vnode *, uint8_t *, int *,
+ struct sockaddr_storage *, int *, off_t *);
static vfs_mount_t nfs_mount;
static vfs_cmount_t nfs_cmount;
static vfs_unmount_t nfs_unmount;
@@ -1202,6 +1204,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
bzero((caddr_t)nmp, sizeof (struct nfsmount));
TAILQ_INIT(&nmp->nm_bufq);
mp->mnt_data = nmp;
+ nmp->nm_getinfo = nfs_getnlminfo;
}
vfs_getnewfsid(mp);
nmp->nm_mountp = mp;
@@ -1490,3 +1493,27 @@ nfs_sysctl(struct mount *mp, fsctlop_t op, struct sysctl_req *req)
}
return (0);
}
+
+/*
+ * Extract the information needed by the nlm from the nfs vnode.
+ */
+static void
+nfs_getnlminfo(struct vnode *vp, uint8_t *fhp, int *fhlenp,
+ struct sockaddr_storage *sp, int *is_v3p, off_t *sizep)
+{
+ struct nfsmount *nmp;
+ struct nfsnode *np = VTONFS(vp);
+
+ nmp = VFSTONFS(vp->v_mount);
+ if (fhlenp != NULL)
+ *fhlenp = np->n_fhsize;
+ if (fhp != NULL)
+ bcopy(np->n_fhp, fhp, np->n_fhsize);
+ if (sp != NULL)
+ bcopy(nmp->nm_nam, sp, min(nmp->nm_nam->sa_len, sizeof(*sp)));
+ if (is_v3p != NULL)
+ *is_v3p = NFS_ISV3(vp);
+ if (sizep != NULL)
+ *sizep = np->n_size;
+}
+
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 828a739..cb2a126 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -215,8 +215,6 @@ struct mtx nfs_iod_mtx;
enum nfsiod_state nfs_iodwant[NFS_MAXASYNCDAEMON];
struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON];
int nfs_numasync = 0;
-vop_advlock_t *nfs_advlock_p = nfs_dolock;
-vop_reclaim_t *nfs_reclaim_p = NULL;
#define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1))
SYSCTL_DECL(_vfs_nfs);
diff --git a/sys/nfsclient/nfsmount.h b/sys/nfsclient/nfsmount.h
index d47957c..515c64e 100644
--- a/sys/nfsclient/nfsmount.h
+++ b/sys/nfsclient/nfsmount.h
@@ -36,6 +36,10 @@
#ifndef _NFSCLIENT_NFSMOUNT_H_
#define _NFSCLIENT_NFSMOUNT_H_
+#include <sys/socket.h>
+
+#include <nfs/nfs_mountcommon.h>
+
#include <rpc/types.h>
#include <rpc/auth.h>
#include <rpc/clnt.h>
@@ -47,10 +51,7 @@
* Holds NFS specific information for mount.
*/
struct nfsmount {
- struct mtx nm_mtx;
- int nm_flag; /* Flags for soft/hard... */
- int nm_state; /* Internal state flags */
- struct mount *nm_mountp; /* Vfs structure for this filesystem */
+ struct nfsmount_common nm_com; /* Common fields for nlm */
int nm_numgrps; /* Max. size of groupslist */
u_char nm_fh[NFSX_V4FH]; /* File handle of root dir */
int nm_fhsize; /* Size of root file handle */
@@ -58,8 +59,6 @@ struct nfsmount {
int nm_soproto; /* and protocol */
int nm_soflags; /* pr_flags for socket protocol */
struct sockaddr *nm_nam; /* Addr of server */
- int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */
- int nm_retry; /* Max retries */
int nm_deadthresh; /* Threshold of timeouts-->dead server*/
int nm_rsize; /* Max size of read rpc */
int nm_wsize; /* Max size of write rpc */
@@ -79,7 +78,6 @@ struct nfsmount {
struct nfs_rpcops *nm_rpcops;
int nm_tprintf_initial_delay; /* initial delay */
int nm_tprintf_delay; /* interval for messages */
- char nm_hostname[MNAMELEN]; /* server's name */
int nm_secflavor; /* auth flavor to use for rpc */
struct __rpc_client *nm_client;
struct rpc_timers nm_timers[NFS_MAX_TIMER]; /* RTT Timers for rpcs */
@@ -94,6 +92,15 @@ struct nfsmount {
time_t nm_last_renewal;
};
+#define nm_mtx nm_com.nmcom_mtx
+#define nm_flag nm_com.nmcom_flag
+#define nm_state nm_com.nmcom_state
+#define nm_mountp nm_com.nmcom_mountp
+#define nm_timeo nm_com.nmcom_timeo
+#define nm_retry nm_com.nmcom_retry
+#define nm_hostname nm_com.nmcom_hostname
+#define nm_getinfo nm_com.nmcom_getinfo
+
#if defined(_KERNEL)
/*
* Convert mount ptr to nfsmount ptr.
diff --git a/sys/nfsclient/nfsnode.h b/sys/nfsclient/nfsnode.h
index 8e9e8f6..19c1c47 100644
--- a/sys/nfsclient/nfsnode.h
+++ b/sys/nfsclient/nfsnode.h
@@ -187,9 +187,6 @@ extern struct vop_vector nfs_fifoops;
extern struct vop_vector nfs_vnodeops;
extern struct buf_ops buf_ops_nfs;
-extern vop_advlock_t *nfs_advlock_p;
-extern vop_reclaim_t *nfs_reclaim_p;
-
/*
* Prototypes for NFS vnode operations
*/
OpenPOWER on IntegriCloud