summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/nfs_vnops.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2003-05-15 21:12:08 +0000
committerrwatson <rwatson@FreeBSD.org>2003-05-15 21:12:08 +0000
commit94ff93f449f6846c6c61435659387b97cfd4aa8c (patch)
tree4a74e55c92f8d4993ed69006e456d2e6870c355c /sys/nfsclient/nfs_vnops.c
parent7e2cfac5e09cab2e6a3c4e05c476c2326bb4ba09 (diff)
downloadFreeBSD-src-94ff93f449f6846c6c61435659387b97cfd4aa8c.zip
FreeBSD-src-94ff93f449f6846c6c61435659387b97cfd4aa8c.tar.gz
This change grabs the vnode lock for NFS client vnodes when calling
VOP_SETATTR() or VOP_GETATTR(); without these locks (a) VFS_DEBUG_LOCKS will panic, and (b) it may be possible to corrupt entries in the cached vnode attributes in the nfsnode, since nfsnode attribute cache data is also protected by the vnode lock. Approved by: re (jhb) Pointed out by: VFS_DEBUG_LOCKS
Diffstat (limited to 'sys/nfsclient/nfs_vnops.c')
-rw-r--r--sys/nfsclient/nfs_vnops.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index a3f7d8f..9e23230 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -526,7 +526,9 @@ nfs_close(struct vop_close_args *ap)
error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_td, cm);
/* np->n_flag &= ~NMODIFIED; */
} else {
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td);
error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1);
+ VOP_UNLOCK(vp, 0, ap->a_td);
}
np->n_attrstamp = 0;
}
@@ -3131,7 +3133,9 @@ nfsfifo_close(struct vop_close_args *ap)
vattr.va_atime = np->n_atim;
if (np->n_flag & NUPD)
vattr.va_mtime = np->n_mtim;
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_td);
(void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_td);
+ VOP_UNLOCK(vp, 0, ap->a_td);
}
}
return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap));
OpenPOWER on IntegriCloud