* file_cache_set_size() now clears the last page of its cache if needed. This
fixes #4106 for good. * Also removed a bit of dead code in that function. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31732 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+18
-10
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2008, Axel Dörfler, [email protected].
|
* Copyright 2004-2009, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1197,17 +1197,25 @@ file_cache_set_size(void *_cacheRef, off_t newSize)
|
|||||||
if (ref == NULL)
|
if (ref == NULL)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
AutoLocker<VMCache> _(ref->cache);
|
VMCache* cache = ref->cache;
|
||||||
|
AutoLocker<VMCache> _(cache);
|
||||||
|
|
||||||
off_t offset = ref->cache->virtual_end;
|
off_t oldSize = cache->virtual_end;
|
||||||
off_t size = newSize;
|
status_t status = cache->Resize(newSize);
|
||||||
if (offset > newSize) {
|
if (status == B_OK && newSize < oldSize) {
|
||||||
size = offset - newSize;
|
// We may have a new partial page at the end of the cache that must be
|
||||||
offset = newSize;
|
// cleared.
|
||||||
} else
|
uint32 partialBytes = newSize % B_PAGE_SIZE;
|
||||||
size = newSize - offset;
|
if (partialBytes != 0) {
|
||||||
|
vm_page *page = cache->LookupPage(newSize - partialBytes);
|
||||||
|
if (page != NULL) {
|
||||||
|
vm_memset_physical(page->physical_page_number * B_PAGE_SIZE
|
||||||
|
+ partialBytes, 0, B_PAGE_SIZE - partialBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ref->cache->Resize(newSize);
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user