svn commit: r188441 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern ufs/ffs

Konstantin Belousov kib at FreeBSD.org
Tue Feb 10 09:43:50 PST 2009


Author: kib
Date: Tue Feb 10 17:43:47 2009
New Revision: 188441
URL: http://svn.freebsd.org/changeset/base/188441

Log:
  MFC r187467:
  Change vinvalbuf() to not remove any pages from the object when
  V_NORMAL or V_ALT are specified. Instead, the only in-tree caller
  in ffs_inode.c:ffs_truncate() that specifies V_ALT explicitely
  removes the corresponding page range. The V_NORMAL caller
  does vnode_pager_setsize(vp, 0) immediately after the call to
  vinvalbuf(V_NORMAL) already.
  
  MFC r187490:
  The r187467 should remove all pages for V_NORMAL case too, because
  indirect block pages are not removed by the mentioned invocation of
  the vnode_pager_setsize().
  
  Put a common code into the helper function ffs_pages_remove().

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/kern/vfs_subr.c
  stable/7/sys/ufs/ffs/ffs_inode.c

Modified: stable/7/sys/kern/vfs_subr.c
==============================================================================
--- stable/7/sys/kern/vfs_subr.c	Tue Feb 10 15:50:19 2009	(r188440)
+++ stable/7/sys/kern/vfs_subr.c	Tue Feb 10 17:43:47 2009	(r188441)
@@ -1103,7 +1103,7 @@ bufobj_invalbuf(struct bufobj *bo, int f
 	/*
 	 * Destroy the copy in the VM cache, too.
 	 */
-	if (bo->bo_object != NULL) {
+	if (bo->bo_object != NULL && (flags & (V_ALT | V_NORMAL)) == 0) {
 		VM_OBJECT_LOCK(bo->bo_object);
 		vm_object_page_remove(bo->bo_object, 0, 0,
 			(flags & V_SAVE) ? TRUE : FALSE);

Modified: stable/7/sys/ufs/ffs/ffs_inode.c
==============================================================================
--- stable/7/sys/ufs/ffs/ffs_inode.c	Tue Feb 10 15:50:19 2009	(r188440)
+++ stable/7/sys/ufs/ffs/ffs_inode.c	Tue Feb 10 17:43:47 2009	(r188441)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 
 #include <vm/vm.h>
 #include <vm/vm_extern.h>
+#include <vm/vm_object.h>
 
 #include <ufs/ufs/extattr.h>
 #include <ufs/ufs/quota.h>
@@ -128,6 +129,18 @@ ffs_update(vp, waitfor)
 	}
 }
 
+static void
+ffs_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end)
+{
+	vm_object_t object;
+
+	if ((object = vp->v_object) == NULL)
+		return;
+	VM_OBJECT_LOCK(object);
+	vm_object_page_remove(object, start, end, FALSE);
+	VM_OBJECT_UNLOCK(object);
+}
+
 #define	SINGLE	0	/* index of single indirect block */
 #define	DOUBLE	1	/* index of double indirect block */
 #define	TRIPLE	2	/* index of triple indirect block */
@@ -203,6 +216,8 @@ ffs_truncate(vp, length, flags, cred, td
 			(void) chkdq(ip, -extblocks, NOCRED, 0);
 #endif
 			vinvalbuf(vp, V_ALT, td, 0, 0);
+			ffs_pages_remove(vp,
+			    OFF_TO_IDX(lblktosize(fs, -extblocks)), 0);
 			ip->i_din2->di_extsize = 0;
 			for (i = 0; i < NXADDR; i++) {
 				oldblks[i] = ip->i_din2->di_extb[i];
@@ -279,6 +294,9 @@ ffs_truncate(vp, length, flags, cred, td
 			    IO_EXT | IO_NORMAL : IO_NORMAL);
 			ASSERT_VOP_LOCKED(vp, "ffs_truncate1");
 			vinvalbuf(vp, needextclean ? 0 : V_NORMAL, td, 0, 0);
+			if (!needextclean)
+				ffs_pages_remove(vp, 0,
+				    OFF_TO_IDX(lblktosize(fs, -extblocks)));
 			vnode_pager_setsize(vp, 0);
 			ip->i_flag |= IN_CHANGE | IN_UPDATE;
 			return (ffs_update(vp, 0));


More information about the svn-src-stable mailing list