summaryrefslogtreecommitdiffstats
path: root/sys/nfs4client
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2008-04-16 11:33:32 +0000
committerkib <kib@FreeBSD.org>2008-04-16 11:33:32 +0000
commit52243403eb48561abd7b33995f5a4be6a56fa1f0 (patch)
tree8616e51dd9b0325c0f52f09db6fcfd6bd22753bc /sys/nfs4client
parent0e16b52aecb9efb40df3384931b2f3afe0d44466 (diff)
downloadFreeBSD-src-52243403eb48561abd7b33995f5a4be6a56fa1f0.zip
FreeBSD-src-52243403eb48561abd7b33995f5a4be6a56fa1f0.tar.gz
Move the head of byte-level advisory lock list from the
filesystem-specific vnode data to the struct vnode. Provide the default implementation for the vop_advlock and vop_advlockasync. Purge the locks on the vnode reclaim by using the lf_purgelocks(). The default implementation is augmented for the nfs and smbfs. In the nfs_advlock, push the Giant inside the nfs_dolock. Before the change, the vop_advlock and vop_advlockasync have taken the unlocked vnode and dereferenced the fs-private inode data, racing with with the vnode reclamation due to forced unmount. Now, the vop_getattr under the shared vnode lock is used to obtain the inode size, and later, in the lf_advlockasync, after locking the vnode interlock, the VI_DOOMED flag is checked to prevent an operation on the doomed vnode. The implementation of the lf_purgelocks() is submitted by dfr. Reported by: kris Tested by: kris, pho Discussed with: jeff, dfr MFC after: 2 weeks
Diffstat (limited to 'sys/nfs4client')
-rw-r--r--sys/nfs4client/nfs4_vnops.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/sys/nfs4client/nfs4_vnops.c b/sys/nfs4client/nfs4_vnops.c
index 633f1c3..276cb1a 100644
--- a/sys/nfs4client/nfs4_vnops.c
+++ b/sys/nfs4client/nfs4_vnops.c
@@ -2763,14 +2763,22 @@ done:
static int
nfs4_advlock(struct vop_advlock_args *ap)
{
- return (EPERM);
+ struct vnode *vp = ap->a_vp;
+ u_quad_t size;
+ int error;
- if ((VFSTONFS(ap->a_vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
- struct nfsnode *np = VTONFS(ap->a_vp);
+ return (EPERM);
- return (lf_advlock(ap, &(np->n_lockf), np->n_size));
- }
- return (nfs_dolock(ap));
+ error = vn_lock(vp, LK_SHARED);
+ if (error)
+ return (error);
+ if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
+ size = VTONFS(vp)->n_size;
+ VOP_UNLOCK(vp, 0);
+ error = lf_advlock(ap, &(vp->v_lockf), size);
+ } else
+ error = nfs_dolock(ap);
+ return (error);
}
/*
@@ -2779,14 +2787,24 @@ nfs4_advlock(struct vop_advlock_args *ap)
static int
nfs4_advlockasync(struct vop_advlockasync_args *ap)
{
- return (EPERM);
+ struct vnode *vp = ap->a_vp;
+ u_quad_t size;
+ int error;
- if ((VFSTONFS(ap->a_vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
- struct nfsnode *np = VTONFS(ap->a_vp);
+ return (EPERM);
- return (lf_advlockasync(ap, &(np->n_lockf), np->n_size));
+ error = vn_lock(vp, LK_SHARED);
+ if (error)
+ return (error);
+ if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NOLOCKD) != 0) {
+ size = VTONFS(vp)->n_size;
+ VOP_UNLOCK(vp, 0);
+ error = lf_advlockasync(ap, &(vp->v_lockf), size);
+ } else {
+ VOP_UNLOCK(vp, 0);
+ error = EOPNOTSUPP;
}
- return (EOPNOTSUPP);
+ return (error);
}
/*
OpenPOWER on IntegriCloud