Page MenuHomeFreeBSD

D49443.id152538.diff
No OneTemporary

D49443.id152538.diff

diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -1597,16 +1597,21 @@
}
/*
- * The page was left invalid. Likely placed there by
+ * If the page was left invalid, it was likely placed there by
* an incomplete fault. Just remove and ignore.
+ *
+ * One other possibility is that the map entry is wired, in
+ * which case we must hang on to the page to avoid leaking it,
+ * as the map entry owns the wiring. This case can arise if the
+ * backing pager is truncated.
*/
- if (vm_page_none_valid(m)) {
+ if (vm_page_none_valid(m) && entry->wired_count == 0) {
if (vm_page_iter_remove(&pages, m))
vm_page_free(m);
continue;
}
- /* vm_page_iter_rename() will dirty the page. */
+ /* vm_page_iter_rename() will dirty the page if it is valid. */
if (!vm_page_iter_rename(&pages, m, new_object, m->pindex -
offidxstart)) {
vm_page_xunbusy(m);
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2038,15 +2038,10 @@
*
* Panics if a page already resides in the new object at the new pindex.
*
- * Note: swap associated with the page must be invalidated by the move. We
- * have to do this for several reasons: (1) we aren't freeing the
- * page, (2) we are dirtying the page, (3) the VM system is probably
- * moving the page from object A to B, and will then later move
- * the backing store from A to B and we can't have a conflict.
- *
- * Note: we *always* dirty the page. It is necessary both for the
- * fact that we moved it, and because we may be invalidating
- * swap.
+ * This routine dirties the page if it is valid, as callers are expected to
+ * transfer backing storage only after moving the page. Dirtying the page
+ * ensures that the destination object retains the most recent copy of the
+ * page.
*
* The objects must be locked.
*/
@@ -2087,7 +2082,8 @@
m->object = new_object;
vm_page_insert_radixdone(m, new_object, mpred);
- vm_page_dirty(m);
+ if (vm_page_any_valid(m))
+ vm_page_dirty(m);
vm_pager_page_inserted(new_object, m);
return (true);
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 15, 2:06 PM (17 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29714596
Default Alt Text
D49443.id152538.diff (2 KB)

Event Timeline