From f93c785026c0a75283aff4d66bac572655d5c95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 7 Aug 2008 17:36:01 +0000 Subject: [PATCH] * FlushAndRemoveAllPages() cannot call WriteModified(), as it must be called with the VMCache lock held, and WriteModified() locks itself. * Added an assertion that the lock is held when calling that method. * This fixes a KDL as soon as you would have used O_NOCACHE with a file that had already some pages read in. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26864 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm_cache.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/system/kernel/vm/vm_cache.cpp b/src/system/kernel/vm/vm_cache.cpp index 84e9451239..40208f5f97 100644 --- a/src/system/kernel/vm/vm_cache.cpp +++ b/src/system/kernel/vm/vm_cache.cpp @@ -796,14 +796,17 @@ VMCache::Resize(off_t newSize) } +/*! You have to call this function with the VMCache lock held. */ status_t VMCache::FlushAndRemoveAllPages() { + ASSERT_LOCKED_MUTEX(&fLock); + while (page_count > 0) { // write back modified pages - status_t error = WriteModified(); - if (error != B_OK) - return error; + status_t status = vm_page_write_modified_pages(this); + if (status != B_OK) + return status; // remove pages for (VMCachePagesTree::Iterator it = pages.GetIterator();