From ad07c8101133b01cb9749d2268e5ad99dd002f8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 8 Oct 2004 23:11:50 +0000 Subject: [PATCH] vm_cache_resize() now requires you to have the vm_cache_ref lock held. This actually reflects the only usage of this function anyway, and thus, fixes the resize_area() function. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9265 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/vm/vm_cache.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/kernel/core/vm/vm_cache.c b/src/kernel/core/vm/vm_cache.c index e23dc9337a..4883510583 100755 --- a/src/kernel/core/vm/vm_cache.c +++ b/src/kernel/core/vm/vm_cache.c @@ -289,6 +289,11 @@ vm_cache_remove_page(vm_cache_ref *cache_ref, vm_page *page) } +/** This function updates the size field of the vm_cache structure. + * If needed, it will free up all pages that don't belong to the cache anymore. + * The vm_cache_ref lock must be held when you call it. + */ + status_t vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize) { @@ -299,8 +304,6 @@ vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize) if (!cache->temporary) return B_NOT_ALLOWED; - mutex_lock(&cacheRef->lock); - oldSize = cache->virtual_size; if (newSize < oldSize) { // we need to remove all pages in the cache outside of the new virtual size @@ -318,8 +321,6 @@ vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize) } cache->virtual_size = newSize; - mutex_unlock(&cacheRef->lock); - vm_increase_max_commit(oldSize - newSize); return B_OK;