* VMCache::Resize(): Corrected TODO comment.
* Changed the semantics of VMCache::HasPage(). It was interpreted inconsistently by the derived classes. Now it returns whether the backing store can provide the page (via Read()). The default implementation returns false. VNodeCache::HasPage() only returns true, if the given offset is within the cache (i.e. file) bounds. This prevents vm_soft_fault() from adding clean pages to vnode caches on faults beyond the file bounds. Probably fixes #5473 -- at least mmap_resize_test behaves correctly, now. * Removed redundant HasPage() and Fault() overrides in VMCache derived classes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36374 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+6
-4
@@ -36,10 +36,8 @@ VMVnodeCache::Init(struct vnode *vnode, uint32 allocationFlags)
|
|||||||
bool
|
bool
|
||||||
VMVnodeCache::HasPage(off_t offset)
|
VMVnodeCache::HasPage(off_t offset)
|
||||||
{
|
{
|
||||||
// We always pretend to have the page - even if it's beyond the size of
|
return ROUNDUP(offset, B_PAGE_SIZE) >= virtual_base
|
||||||
// the file. The read function will only cut down the size of the read,
|
&& offset < virtual_end;
|
||||||
// it won't fail because of that.
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +101,10 @@ VMVnodeCache::WriteAsync(off_t offset, const iovec* vecs, size_t count,
|
|||||||
status_t
|
status_t
|
||||||
VMVnodeCache::Fault(struct VMAddressSpace *aspace, off_t offset)
|
VMVnodeCache::Fault(struct VMAddressSpace *aspace, off_t offset)
|
||||||
{
|
{
|
||||||
|
if (!HasPage(offset))
|
||||||
|
return B_BAD_ADDRESS;
|
||||||
|
|
||||||
|
// vm_soft_fault() reads the page in.
|
||||||
return B_BAD_HANDLER;
|
return B_BAD_HANDLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1078,8 +1078,9 @@ VMCache::Resize(off_t newSize, int priority)
|
|||||||
DEBUG_PAGE_ACCESS_START(page);
|
DEBUG_PAGE_ACCESS_START(page);
|
||||||
vm_remove_all_page_mappings(page);
|
vm_remove_all_page_mappings(page);
|
||||||
ASSERT(page->wired_count == 0);
|
ASSERT(page->wired_count == 0);
|
||||||
// TODO: Find a real solution! Unmapping is probably fine, but
|
// TODO: Find a real solution! If the page is wired
|
||||||
// we have no way of unmapping wired pages here.
|
// temporarily (e.g. by lock_memory()), we actually must not
|
||||||
|
// unmap it!
|
||||||
RemovePage(page);
|
RemovePage(page);
|
||||||
vm_page_free(this, page);
|
vm_page_free(this, page);
|
||||||
// Note: When iterating through a IteratableSplayTree
|
// Note: When iterating through a IteratableSplayTree
|
||||||
@@ -1145,10 +1146,19 @@ VMCache::Commit(off_t size, int priority)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Returns whether the cache's underlying backing store could deliver the
|
||||||
|
page at the given offset.
|
||||||
|
|
||||||
|
Basically it returns whether a Read() at \a offset would at least read a
|
||||||
|
partial page (assuming that no unexpected errors occur or the situation
|
||||||
|
changes in the meantime).
|
||||||
|
*/
|
||||||
bool
|
bool
|
||||||
VMCache::HasPage(off_t offset)
|
VMCache::HasPage(off_t offset)
|
||||||
{
|
{
|
||||||
return offset >= virtual_base && offset <= virtual_end;
|
// In accordance with Fault() the default implementation doesn't have a
|
||||||
|
// backing store and doesn't allow faults.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "VMDeviceCache.h"
|
#include "VMDeviceCache.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -17,14 +18,6 @@ VMDeviceCache::Init(addr_t baseAddress, uint32 allocationFlags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
VMDeviceCache::HasPage(off_t offset)
|
|
||||||
{
|
|
||||||
// this should never be called
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
VMDeviceCache::Read(off_t offset, const iovec *vecs, size_t count,
|
VMDeviceCache::Read(off_t offset, const iovec *vecs, size_t count,
|
||||||
uint32 flags, size_t *_numBytes)
|
uint32 flags, size_t *_numBytes)
|
||||||
@@ -41,10 +34,3 @@ VMDeviceCache::Write(off_t offset, const iovec *vecs, size_t count,
|
|||||||
// no place to write, this will cause the page daemon to skip this store
|
// no place to write, this will cause the page daemon to skip this store
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
VMDeviceCache::Fault(struct VMAddressSpace* addressSpace, off_t offset)
|
|
||||||
{
|
|
||||||
return B_BAD_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,16 +17,11 @@ class VMDeviceCache : public VMCache {
|
|||||||
public:
|
public:
|
||||||
status_t Init(addr_t baseAddress, uint32 allocationFlags);
|
status_t Init(addr_t baseAddress, uint32 allocationFlags);
|
||||||
|
|
||||||
virtual bool HasPage(off_t offset);
|
|
||||||
|
|
||||||
virtual status_t Read(off_t offset, const iovec *vecs, size_t count,
|
virtual status_t Read(off_t offset, const iovec *vecs, size_t count,
|
||||||
uint32 flags, size_t *_numBytes);
|
uint32 flags, size_t *_numBytes);
|
||||||
virtual status_t Write(off_t offset, const iovec *vecs, size_t count,
|
virtual status_t Write(off_t offset, const iovec *vecs, size_t count,
|
||||||
uint32 flags, size_t *_numBytes);
|
uint32 flags, size_t *_numBytes);
|
||||||
|
|
||||||
virtual status_t Fault(struct VMAddressSpace* addressSpace,
|
|
||||||
off_t offset);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
addr_t fBaseAddress;
|
addr_t fBaseAddress;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "VMNullCache.h"
|
#include "VMNullCache.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -11,10 +12,3 @@ VMNullCache::Init(uint32 allocationFlags)
|
|||||||
{
|
{
|
||||||
return VMCache::Init(CACHE_TYPE_NULL, allocationFlags);
|
return VMCache::Init(CACHE_TYPE_NULL, allocationFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
VMNullCache::Fault(struct VMAddressSpace* addressSpace, off_t offset)
|
|
||||||
{
|
|
||||||
return B_BAD_ADDRESS;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,9 +16,6 @@
|
|||||||
class VMNullCache : public VMCache {
|
class VMNullCache : public VMCache {
|
||||||
public:
|
public:
|
||||||
status_t Init(uint32 allocationFlags);
|
status_t Init(uint32 allocationFlags);
|
||||||
|
|
||||||
virtual status_t Fault(struct VMAddressSpace* addressSpace,
|
|
||||||
off_t offset);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user