Author: kib
Date: Tue Jan 20 22:00:19 2009
New Revision: 187490
URL: http://svn.freebsd.org/changeset/base/187490

Log:
  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().
  
  Reported and tested by:       dchagin
  Reviewed by:  ups
  MFC after:    3 weeks

Modified:
  head/sys/ufs/ffs/ffs_inode.c

Modified: head/sys/ufs/ffs/ffs_inode.c
==============================================================================
--- head/sys/ufs/ffs/ffs_inode.c        Tue Jan 20 21:57:07 2009        
(r187489)
+++ head/sys/ufs/ffs/ffs_inode.c        Tue Jan 20 22:00:19 2009        
(r187490)
@@ -129,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 */
@@ -152,7 +164,6 @@ ffs_truncate(vp, length, flags, cred, td
        struct fs *fs;
        struct buf *bp;
        struct ufsmount *ump;
-       vm_object_t object;
        int needextclean, softdepslowdown, extblocks;
        int offset, size, level, nblocks;
        int i, error, allerror;
@@ -207,13 +218,8 @@ ffs_truncate(vp, length, flags, cred, td
                        (void) chkdq(ip, -extblocks, NOCRED, 0);
 #endif
                        vinvalbuf(vp, V_ALT, 0, 0);
-                       if ((object = vp->v_object) != NULL) {
-                               VM_OBJECT_LOCK(object);
-                               vm_object_page_remove(object,
-                                   OFF_TO_IDX(lblktosize(fs, -extblocks)), 0,
-                                   FALSE);
-                               VM_OBJECT_UNLOCK(object);
-                       }
+                       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];
@@ -290,6 +296,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, 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));
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to