* 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:
@@ -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
@@ -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
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user