[haiku-commits] r35477 - haiku/trunk/src/system/kernel/arch/x86

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 15 Feb 2010 20:36:17 +0100 (CET)

Author: bonefish
Date: 2010-02-15 20:36:17 +0100 (Mon, 15 Feb 2010)
New Revision: 35477
Changeset: http://dev.haiku-os.org/changeset/35477/haiku
Ticket: http://dev.haiku-os.org/ticket/5374

Modified:
   haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp
Log:
X86VMTranslationMap::UnmapArea(): Don't change the page state before
it has been unmapped. This way modified pages could end up in the "cached"
queue without having been written back. That would be a good explanation for
#5374 (partially wrong file contents) -- as soon as such a page was freed,
the invalid on-disk contents would become visible.


Modified: haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp
===================================================================
--- haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp  
2010-02-15 19:10:44 UTC (rev 35476)
+++ haiku/trunk/src/system/kernel/arch/x86/arch_vm_translation_map.cpp  
2010-02-15 19:36:17 UTC (rev 35477)
@@ -800,23 +800,12 @@
 
                VMCache* cache = page->Cache();
 
-               DEBUG_PAGE_ACCESS_START(page);
-
+               bool pageFullyUnmapped = false;
                if (page->wired_count == 0 && page->mappings.IsEmpty()) {
                        atomic_add(&gMappedPagesCount, -1);
-
-                       if (!ignoreTopCachePageFlags || cache != area->cache) {
-                               if (cache->temporary)
-                                       vm_page_set_state(page, 
PAGE_STATE_INACTIVE);
-                               else if (page->modified)
-                                       vm_page_set_state(page, 
PAGE_STATE_MODIFIED);
-                               else
-                                       vm_page_set_state(page, 
PAGE_STATE_CACHED);
-                       }
+                       pageFullyUnmapped = true;
                }
 
-               DEBUG_PAGE_ACCESS_END(page);
-
                if (unmapPages || cache != area->cache) {
                        addr_t address = area->Base()
                                + ((page->cache_offset * B_PAGE_SIZE) - 
area->cache_offset);
@@ -861,6 +850,19 @@
 
                        if ((oldEntry & X86_PTE_DIRTY) != 0)
                                page->modified = true;
+
+                       if (pageFullyUnmapped) {
+                               DEBUG_PAGE_ACCESS_START(page);
+
+                               if (cache->temporary)
+                                       vm_page_set_state(page, 
PAGE_STATE_INACTIVE);
+                               else if (page->modified)
+                                       vm_page_set_state(page, 
PAGE_STATE_MODIFIED);
+                               else
+                                       vm_page_set_state(page, 
PAGE_STATE_CACHED);
+
+                               DEBUG_PAGE_ACCESS_END(page);
+                       }
                }
 
                fMapCount--;


Other related posts:

  • » [haiku-commits] r35477 - haiku/trunk/src/system/kernel/arch/x86 - ingo_weinhold