Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Mar 2012 20:27:20 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232701 - in head/sys: fs/unionfs kern ufs/ufs vm
Message-ID:  <201203082027.q28KRKri063338@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Mar  8 20:27:20 2012
New Revision: 232701
URL: http://svn.freebsd.org/changeset/base/232701

Log:
  Add KTR_VFS traces to track modifications to a vnode's writecount.

Modified:
  head/sys/fs/unionfs/union_subr.c
  head/sys/kern/vfs_syscalls.c
  head/sys/kern/vfs_vnops.c
  head/sys/ufs/ufs/ufs_extattr.c
  head/sys/vm/vnode_pager.c

Modified: head/sys/fs/unionfs/union_subr.c
==============================================================================
--- head/sys/fs/unionfs/union_subr.c	Thu Mar  8 19:41:05 2012	(r232700)
+++ head/sys/fs/unionfs/union_subr.c	Thu Mar  8 20:27:20 2012	(r232701)
@@ -952,6 +952,8 @@ unionfs_vn_create_on_upper(struct vnode 
 		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 *un
 	}
 	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);
 

Modified: head/sys/kern/vfs_syscalls.c
==============================================================================
--- head/sys/kern/vfs_syscalls.c	Thu Mar  8 19:41:05 2012	(r232700)
+++ head/sys/kern/vfs_syscalls.c	Thu Mar  8 20:27:20 2012	(r232701)
@@ -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(). */

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Thu Mar  8 19:41:05 2012	(r232700)
+++ head/sys/kern/vfs_vnops.c	Thu Mar  8 20:27:20 2012	(r232701)
@@ -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);

Modified: head/sys/ufs/ufs/ufs_extattr.c
==============================================================================
--- head/sys/ufs/ufs/ufs_extattr.c	Thu Mar  8 19:41:05 2012	(r232700)
+++ head/sys/ufs/ufs/ufs_extattr.c	Thu Mar  8 20:27:20 2012	(r232701)
@@ -335,6 +335,8 @@ ufs_extattr_enable_with_open(struct ufsm
 	}
 
 	vp->v_writecount++;
+	CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", __func__, vp,
+	    vp->v_writecount);
 
 	vref(vp);
 

Modified: head/sys/vm/vnode_pager.c
==============================================================================
--- head/sys/vm/vnode_pager.c	Thu Mar  8 19:41:05 2012	(r232700)
+++ head/sys/vm/vnode_pager.c	Thu Mar  8 20:27:20 2012	(r232701)
@@ -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_
 	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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203082027.q28KRKri063338>