From 0ab3c7a5949efc2a176abb974e523c8f0a6b6e94 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 22 Oct 2007 06:23:46 +0000 Subject: [PATCH] Correct an error of omission in the reimplementation of the page cache: vnode_pager_setsize() must handle the case where a file is truncated to a non-page-size-aligned boundary and there is a cached page underlying the new end of file. Reported by: kris, tegge Tested by: kris MFC after: 3 days --- sys/vm/vnode_pager.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 67164e8918f1..fd60f7e12c92 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -426,6 +426,10 @@ vnode_pager_setsize(vp, nsize) if (m->dirty != 0) m->dirty = VM_PAGE_BITS_ALL; vm_page_unlock_queues(); + } else if ((nsize & PAGE_MASK) && + __predict_false(object->cache != NULL)) { + vm_page_cache_free(object, OFF_TO_IDX(nsize), + nobjsize); } } object->un_pager.vnp.vnp_size = nsize;