diff options
author | kib <kib@FreeBSD.org> | 2009-01-20 22:00:19 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2009-01-20 22:00:19 +0000 |
commit | 1a9032d3393992926a15a517a335cdb0e656baf9 (patch) | |
tree | 171c0d95dc51681f7c02fbd33a72c6ace89e0058 /sys | |
parent | e9f20885b0b1b11db397b1bbea8fde81b4766e22 (diff) | |
download | FreeBSD-src-1a9032d3393992926a15a517a335cdb0e656baf9.zip FreeBSD-src-1a9032d3393992926a15a517a335cdb0e656baf9.tar.gz |
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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 36aac0e..e6269b6 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -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)); |