* Introduces VMCache::CanWritePage() returning whether the given cache can

theoretically write the given page.
* page writer: Fixed the incorrect check whether a temporary page can be
  written by using the new CanWritePage().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30281 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-04-20 15:19:41 +00:00
parent fe8e2eb13d
commit 65d2b8a8e9
7 changed files with 37 additions and 1 deletions
+1
View File
@@ -219,6 +219,7 @@ public:
virtual status_t WriteAsync(off_t offset, const iovec* vecs,
size_t count, size_t numBytes, uint32 flags,
AsyncIOCallback* callback);
virtual bool CanWritePage(off_t offset);
virtual status_t Fault(struct vm_address_space *aspace, off_t offset);
+8
View File
@@ -101,6 +101,14 @@ VMVnodeCache::Fault(struct vm_address_space *aspace, off_t offset)
}
bool
VMVnodeCache::CanWritePage(off_t offset)
{
// all pages can be written
return true;
}
status_t
VMVnodeCache::AcquireUnreferencedStoreRef()
{
+1
View File
@@ -26,6 +26,7 @@ public:
virtual status_t WriteAsync(off_t offset, const iovec* vecs,
size_t count, size_t numBytes, uint32 flags,
AsyncIOCallback* callback);
virtual bool CanWritePage(off_t offset);
virtual status_t Fault(struct vm_address_space *aspace, off_t offset);
+10
View File
@@ -641,6 +641,16 @@ VMAnonymousCache::WriteAsync(off_t offset, const iovec* vecs, size_t count,
}
bool
VMAnonymousCache::CanWritePage(off_t offset)
{
// We can write the page, if we have not used all of our committed swap
// space or the page already has a swap slot assigned.
return fAllocatedSwapSize < fCommittedSwapSize
|| _SwapBlockGetAddress(offset >> PAGE_SHIFT) != SWAP_SLOT_NONE;
}
status_t
VMAnonymousCache::Fault(struct vm_address_space *aspace, off_t offset)
{
+1
View File
@@ -45,6 +45,7 @@ public:
virtual status_t WriteAsync(off_t offset, const iovec* vecs,
size_t count, size_t numBytes, uint32 flags,
AsyncIOCallback* callback);
virtual bool CanWritePage(off_t offset);
virtual status_t Fault(struct vm_address_space *aspace, off_t offset);
+14
View File
@@ -892,6 +892,20 @@ VMCache::WriteAsync(off_t offset, const iovec* vecs, size_t count,
}
/*! \brief Returns whether the cache can write the page at the given offset.
The cache must be locked when this function is invoked.
@param offset The page offset.
@return \c true, if the page can be written, \c false otherwise.
*/
bool
VMCache::CanWritePage(off_t offset)
{
return false;
}
status_t
VMCache::Fault(struct vm_address_space *aspace, off_t offset)
{
+2 -1
View File
@@ -1247,7 +1247,8 @@ page_writer(void* /*unused*/)
|| (cache->temporary
#if ENABLE_SWAP_SUPPORT
&& (!lowOnPages /*|| page->usage_count > 0*/
|| swap_available_pages() == 0)
|| !cache->CanWritePage(
(off_t)page->cache_offset << PAGE_SHIFT))
#endif
)) {
continue;