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
This commit is contained in:
@@ -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
|
status_t
|
||||||
vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize)
|
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)
|
if (!cache->temporary)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
mutex_lock(&cacheRef->lock);
|
|
||||||
|
|
||||||
oldSize = cache->virtual_size;
|
oldSize = cache->virtual_size;
|
||||||
if (newSize < oldSize) {
|
if (newSize < oldSize) {
|
||||||
// we need to remove all pages in the cache outside of the new virtual size
|
// 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;
|
cache->virtual_size = newSize;
|
||||||
mutex_unlock(&cacheRef->lock);
|
|
||||||
|
|
||||||
vm_increase_max_commit(oldSize - newSize);
|
vm_increase_max_commit(oldSize - newSize);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user