summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormpp <mpp@FreeBSD.org>2007-02-12 22:53:01 +0000
committermpp <mpp@FreeBSD.org>2007-02-12 22:53:01 +0000
commit725b149c2db3f8bc35268426a9c1719420d722fa (patch)
treee77027f440c6094788e425df352228d5f05da842 /sys
parentedec07ff3ac5ec95545cb6072c7fa293976cd444 (diff)
downloadFreeBSD-src-725b149c2db3f8bc35268426a9c1719420d722fa.zip
FreeBSD-src-725b149c2db3f8bc35268426a9c1719420d722fa.tar.gz
Add a VNASSERT to vn_close to detect if v_writecount is going
to become negative. This will detect the underflow when it happens, instead of having it discovered when the vnode is taken off the freelist, long after the offending process is long gone.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_vnops.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index c56d7fc..25ee8a4 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -285,8 +285,11 @@ vn_close(vp, flags, file_cred, td)
vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
- if (flags & FWRITE)
+ if (flags & FWRITE) {
+ VNASSERT(vp->v_writecount > 0, vp,
+ ("vn_close: negative writecount"));
vp->v_writecount--;
+ }
error = VOP_CLOSE(vp, flags, file_cred, td);
vput(vp);
vn_finished_write(mp);
OpenPOWER on IntegriCloud