[haiku-commits] r35500 - haiku/trunk/src/system/kernel/cache

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 16 Feb 2010 18:22:56 +0100 (CET)

Author: bonefish
Date: 2010-02-16 18:22:56 +0100 (Tue, 16 Feb 2010)
New Revision: 35500
Changeset: http://dev.haiku-os.org/changeset/35500/haiku
Ticket: http://dev.haiku-os.org/ticket/5374

Modified:
   haiku/trunk/src/system/kernel/cache/file_cache.cpp
Log:
The file cache code was completely ignoring the vm_page::modified flag. In
particular it wouldn't set the flag when writing something to a page, but
only move it to the modified queue. Since mapping the page would move it to
another queue, the information that the page was modified would be lost and
it would never be written to disk. Was well reproducible with a Haiku image
build and limited amount of memory.
Fixes the hopefully last remaining cause for #5374.


Modified: haiku/trunk/src/system/kernel/cache/file_cache.cpp
===================================================================
--- haiku/trunk/src/system/kernel/cache/file_cache.cpp  2010-02-16 17:12:42 UTC 
(rev 35499)
+++ haiku/trunk/src/system/kernel/cache/file_cache.cpp  2010-02-16 17:22:56 UTC 
(rev 35500)
@@ -309,7 +309,8 @@
                                vm_page* page;
                                for (VMCachePagesTree::Iterator it = 
cache->pages.GetIterator();
                                                (page = it.Next()) != NULL && 
left > 0;) {
-                                       if (page->state != PAGE_STATE_MODIFIED 
&& !page->busy) {
+                                       if (page->state != PAGE_STATE_MODIFIED 
&& !page->modified
+                                                       && !page->busy) {
                                                DEBUG_PAGE_ACCESS_START(page);
                                                cache->RemovePage(page);
                                                vm_page_set_state(page, 
PAGE_STATE_FREE);
@@ -514,6 +515,8 @@
                        (writeThrough ? PAGE_STATE_CACHED : PAGE_STATE_MODIFIED)
                                | VM_PAGE_ALLOC_BUSY);
 
+               page->modified = !writeThrough;
+
                ref->cache->InsertPage(page, offset + pos);
 
                add_to_iovec(vecs, vecCount, MAX_IO_VECS,
@@ -807,9 +810,14 @@
 
                                locker.Lock();
 
-                               if (doWrite && page->state != 
PAGE_STATE_MODIFIED) {
+                               if (doWrite) {
                                        DEBUG_PAGE_ACCESS_START(page);
-                                       vm_page_set_state(page, 
PAGE_STATE_MODIFIED);
+
+                                       page->modified = true;
+
+                                       if (page->state != PAGE_STATE_MODIFIED)
+                                               vm_page_set_state(page, 
PAGE_STATE_MODIFIED);
+
                                        DEBUG_PAGE_ACCESS_END(page);
                                }
 


Other related posts:

  • » [haiku-commits] r35500 - haiku/trunk/src/system/kernel/cache - ingo_weinhold