diff --git a/headers/private/kernel/vm/VMCache.h b/headers/private/kernel/vm/VMCache.h index c7f291b7d1..584f4919d5 100644 --- a/headers/private/kernel/vm/VMCache.h +++ b/headers/private/kernel/vm/VMCache.h @@ -200,7 +200,6 @@ public: // TODO: Remove! uint32 page_count; uint32 temporary : 1; - uint32 unmergeable : 1; uint32 type : 6; #if DEBUG_CACHE_LIST diff --git a/src/add-ons/kernel/file_systems/ramfs/DataContainer.cpp b/src/add-ons/kernel/file_systems/ramfs/DataContainer.cpp index ebd29b6ec1..85d7fb5375 100644 --- a/src/add-ons/kernel/file_systems/ramfs/DataContainer.cpp +++ b/src/add-ons/kernel/file_systems/ramfs/DataContainer.cpp @@ -303,7 +303,6 @@ DataContainer::_SwitchToCacheMode() fCache = cache; fCache->temporary = 1; - fCache->unmergeable = 1; fCache->virtual_end = fSize; error = fCache->Commit(fSize, VM_PRIORITY_USER); diff --git a/src/system/kernel/vm/VMCache.cpp b/src/system/kernel/vm/VMCache.cpp index 4500e21ae8..957162602a 100644 --- a/src/system/kernel/vm/VMCache.cpp +++ b/src/system/kernel/vm/VMCache.cpp @@ -611,7 +611,7 @@ VMCacheRef::VMCacheRef(VMCache* cache) bool VMCache::_IsMergeable() const { - return areas.IsEmpty() && temporary && !unmergeable + return areas.IsEmpty() && temporary && !consumers.IsEmpty() && consumers.Head() == consumers.Tail(); } @@ -642,7 +642,6 @@ VMCache::Init(uint32 cacheType, uint32 allocationFlags) virtual_end = 0; committed_size = 0; temporary = 0; - unmergeable = 0; page_count = 0; fWiredPagesCount = 0; type = cacheType; @@ -1561,21 +1560,22 @@ void VMCache::_RemoveConsumer(VMCache* consumer) { TRACE(("remove consumer vm cache %p from cache %p\n", consumer, this)); - consumer->AssertLocked(); - T(RemoveConsumer(this, consumer)); - // Remove the store ref before locking the cache. Otherwise we'd call into - // the VFS while holding the cache lock, which would reverse the usual - // locking order. - ReleaseStoreRef(); + consumer->AssertLocked(); - // remove the consumer from the cache, but keep its reference until later + // Remove the consumer from the cache, but keep its reference until the end. Lock(); consumers.Remove(consumer); consumer->source = NULL; + Unlock(); - ReleaseRefAndUnlock(); + // Release the store ref without holding the cache lock, as calling into + // the VFS while holding the cache lock would reverse the usual locking order. + ReleaseStoreRef(); + + // Now release the consumer's reference. + ReleaseRef(); }