diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index eb0269326808..1e4bf902d075 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1156,7 +1156,7 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo) /* * 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); diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index fa679ef1f812..2be220e36a54 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -151,6 +152,7 @@ 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; @@ -205,6 +207,13 @@ 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); + } ip->i_din2->di_extsize = 0; for (i = 0; i < NXADDR; i++) { oldblks[i] = ip->i_din2->di_extb[i];