summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/nfsclient/nfs_clnode.c8
-rw-r--r--sys/fs/nfsclient/nfs_clvfsops.c44
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c5
-rw-r--r--sys/fs/nfsclient/nfsmount.h17
4 files changed, 58 insertions, 16 deletions
diff --git a/sys/fs/nfsclient/nfs_clnode.c b/sys/fs/nfsclient/nfs_clnode.c
index 7d76be0..8ca1c43 100644
--- a/sys/fs/nfsclient/nfs_clnode.c
+++ b/sys/fs/nfsclient/nfs_clnode.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/fcntl.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mount.h>
@@ -53,12 +54,13 @@ __FBSDID("$FreeBSD$");
#include <fs/nfsclient/nfsmount.h>
#include <fs/nfsclient/nfs.h>
+#include <nfs/nfs_lock.h>
+
extern struct vop_vector newnfs_vnodeops;
extern struct buf_ops buf_ops_newnfs;
MALLOC_DECLARE(M_NEWNFSREQ);
uma_zone_t newnfsnode_zone;
-vop_reclaim_t *ncl_reclaim_p = NULL;
void
ncl_nhinit(void)
@@ -238,8 +240,8 @@ ncl_reclaim(struct vop_reclaim_args *ap)
* If the NLM is running, give it a chance to abort pending
* locks.
*/
- if (ncl_reclaim_p)
- ncl_reclaim_p(ap);
+ if (nfs_reclaim_p != NULL)
+ nfs_reclaim_p(ap);
/*
* Destroy the vm object and flush associated pages.
diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index b2cd92b..816d288 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -96,10 +96,13 @@ SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_DELAY,
static void nfs_sec_name(char *, int *);
static void nfs_decode_args(struct mount *mp, struct nfsmount *nmp,
- struct nfs_args *argp, struct ucred *, struct thread *);
+ struct nfs_args *argp, const char *, struct ucred *,
+ struct thread *);
static int mountnfs(struct nfs_args *, struct mount *,
struct sockaddr *, char *, u_char *, u_char *, u_char *,
struct vnode **, struct ucred *, struct thread *, 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;
@@ -518,10 +521,11 @@ nfs_sec_name(char *sec, int *flagsp)
static void
nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
- struct ucred *cred, struct thread *td)
+ const char *hostname, struct ucred *cred, struct thread *td)
{
int s;
int adjsock;
+ char *p;
s = splnet();
@@ -659,6 +663,14 @@ nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp,
nmp->nm_sotype = argp->sotype;
nmp->nm_soproto = argp->proto;
}
+
+ if (hostname != NULL) {
+ strlcpy(nmp->nm_hostname, hostname,
+ sizeof(nmp->nm_hostname));
+ p = strchr(nmp->nm_hostname, ':');
+ if (p != NULL)
+ *p = '\0';
+ }
}
static const char *nfs_opts[] = { "from",
@@ -933,7 +945,7 @@ nfs_mount(struct mount *mp)
NFSMNT_INTEGRITY |
NFSMNT_PRIVACY |
NFSMNT_NOLOCKD /*|NFSMNT_XLATECOOKIE*/));
- nfs_decode_args(mp, nmp, &args, td->td_ucred, td);
+ nfs_decode_args(mp, nmp, &args, NULL, td->td_ucred, td);
goto out;
}
@@ -1110,13 +1122,14 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
nmp->nm_sockreq.nr_cred = crhold(cred);
mtx_init(&nmp->nm_sockreq.nr_mtx, "nfssock", NULL, MTX_DEF);
mp->mnt_data = nmp;
+ nmp->nm_getinfo = nfs_getnlminfo;
}
vfs_getnewfsid(mp);
nmp->nm_mountp = mp;
mtx_init(&nmp->nm_mtx, "NFSmount lock", NULL, MTX_DEF | MTX_DUPOK);
nmp->nm_negnametimeo = negnametimeo;
- nfs_decode_args(mp, nmp, argp, cred, td);
+ nfs_decode_args(mp, nmp, argp, hst, cred, td);
/*
* V2 can only handle 32 bit filesizes. A 4GB-1 limit may be too
@@ -1447,3 +1460,26 @@ 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_fhp->nfh_len;
+ if (fhp != NULL)
+ bcopy(np->n_fhp->nfh_fh, fhp, np->n_fhp->nfh_len);
+ 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/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 8f1ec27..b02c4bf 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -84,7 +84,6 @@ __FBSDID("$FreeBSD$");
extern struct nfsstats newnfsstats;
MALLOC_DECLARE(M_NEWNFSREQ);
-vop_advlock_t *ncl_advlock_p = NULL;
/*
* Ifdef for FreeBSD-current merged buffer cache. It is unfortunate that these
@@ -2937,8 +2936,8 @@ nfs_advlock(struct vop_advlock_args *ap)
VOP_UNLOCK(vp, 0);
error = lf_advlock(ap, &(vp->v_lockf), size);
} else {
- if (ncl_advlock_p)
- error = ncl_advlock_p(ap);
+ if (nfs_advlock_p != NULL)
+ error = nfs_advlock_p(ap);
else {
VOP_UNLOCK(vp, 0);
error = ENOLCK;
diff --git a/sys/fs/nfsclient/nfsmount.h b/sys/fs/nfsclient/nfsmount.h
index 9fd9331..5bc69f8 100644
--- a/sys/fs/nfsclient/nfsmount.h
+++ b/sys/fs/nfsclient/nfsmount.h
@@ -35,22 +35,19 @@
#ifndef _NFSCLIENT_NFSMOUNT_H_
#define _NFSCLIENT_NFSMOUNT_H_
+#include <nfs/nfs_mountcommon.h>
+
/*
* Mount structure.
* One allocated on every NFS mount.
* 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_FHMAX]; /* File handle of root dir */
int nm_fhsize; /* Size of root file handle */
struct nfssockreq nm_sockreq; /* Socket Info */
- int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */
- int nm_retry; /* Max retries */
int nm_timeouts; /* Request timeouts */
int nm_rsize; /* Max size of read rpc */
int nm_wsize; /* Max size of write rpc */
@@ -89,6 +86,14 @@ struct nfsmount {
#define nm_soproto nm_sockreq.nr_soproto
#define nm_client nm_sockreq.nr_client
#define nm_krbname nm_name
+#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
#define NFSMNT_DIRPATH(m) (&((m)->nm_name[(m)->nm_krbnamelen + 1]))
#define NFSMNT_SRVKRBNAME(m) \
OpenPOWER on IntegriCloud