From 19feaba08bc6b84c117bd21cc71e139c6d086ed7 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 8 Mar 2012 20:27:20 +0000 Subject: Add KTR_VFS traces to track modifications to a vnode's writecount. --- sys/fs/unionfs/union_subr.c | 4 ++++ sys/kern/vfs_syscalls.c | 10 ++++++++-- sys/kern/vfs_vnops.c | 7 ++++++- sys/ufs/ufs/ufs_extattr.c | 2 ++ sys/vm/vnode_pager.c | 6 ++++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 2e74844..074958c 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -952,6 +952,8 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, goto unionfs_vn_create_on_upper_free_out1; } vp->v_writecount++; + CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", __func__, vp, + vp->v_writecount); *vpp = vp; unionfs_vn_create_on_upper_free_out1: @@ -1087,6 +1089,8 @@ unionfs_copyfile(struct unionfs_node *unp, int docopy, struct ucred *cred, } VOP_CLOSE(uvp, FWRITE, cred, td); uvp->v_writecount--; + CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", __func__, uvp, + uvp->v_writecount); vn_finished_write(mp); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 9b7cbe4..a8bb661 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4591,16 +4591,22 @@ sys_fhopen(td, uap) if (error) goto bad; - if (fmode & FWRITE) + if (fmode & FWRITE) { vp->v_writecount++; + CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", + __func__, vp, vp->v_writecount); + } /* * end of vn_open code */ if ((error = falloc(td, &nfp, &indx, fmode)) != 0) { - if (fmode & FWRITE) + if (fmode & FWRITE) { vp->v_writecount--; + CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", + __func__, vp, vp->v_writecount); + } goto bad; } /* An extra reference on `nfp' has been held for us by falloc(). */ diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index ce2d701..d4b60f1 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -245,8 +245,11 @@ restart: if ((error = VOP_OPEN(vp, fmode, cred, td, fp)) != 0) goto bad; - if (fmode & FWRITE) + if (fmode & FWRITE) { vp->v_writecount++; + CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", + __func__, vp, vp->v_writecount); + } *flagp = fmode; ASSERT_VOP_LOCKED(vp, "vn_open_cred"); if (!mpsafe) @@ -309,6 +312,8 @@ vn_close(vp, flags, file_cred, td) VNASSERT(vp->v_writecount > 0, vp, ("vn_close: negative writecount")); vp->v_writecount--; + CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", + __func__, vp, vp->v_writecount); } error = VOP_CLOSE(vp, flags, file_cred, td); vput(vp); diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c index 777f385..210d05a 100644 --- a/sys/ufs/ufs/ufs_extattr.c +++ b/sys/ufs/ufs/ufs_extattr.c @@ -335,6 +335,8 @@ ufs_extattr_enable_with_open(struct ufsmount *ump, struct vnode *vp, } vp->v_writecount++; + CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", __func__, vp, + vp->v_writecount); vref(vp); diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 609205a..c5b6c17 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -272,6 +272,8 @@ vnode_pager_dealloc(object) if (object->un_pager.vnp.writemappings > 0) { object->un_pager.vnp.writemappings = 0; vp->v_writecount--; + CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", + __func__, vp, vp->v_writecount); } vp->v_object = NULL; vp->v_vflag &= ~VV_TEXT; @@ -1241,9 +1243,13 @@ vnode_pager_update_writecount(vm_object_t object, vm_offset_t start, if (old_wm == 0 && object->un_pager.vnp.writemappings != 0) { ASSERT_VOP_ELOCKED(vp, "v_writecount inc"); vp->v_writecount++; + CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", + __func__, vp, vp->v_writecount); } else if (old_wm != 0 && object->un_pager.vnp.writemappings == 0) { ASSERT_VOP_ELOCKED(vp, "v_writecount dec"); vp->v_writecount--; + CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", + __func__, vp, vp->v_writecount); } VM_OBJECT_UNLOCK(object); } -- cgit v1.1