* Added "flags" parameter to VMCache::Read().

* Use the new VMCache::Read() flags parameter to directly read into the
  physical page in the page fault handler instead of mapping it first.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27966 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-10-11 07:30:44 +00:00
parent b99c736b83
commit 4eaa43ac48
11 changed files with 50 additions and 21 deletions

View File

@ -213,7 +213,7 @@ public:
virtual bool HasPage(off_t offset);
virtual status_t Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes);
uint32 flags, size_t *_numBytes);
virtual status_t Write(off_t offset, const iovec *vecs, size_t count,
uint32 flags, size_t *_numBytes);
virtual status_t WriteAsync(off_t offset, const iovec* vecs,

View File

@ -11,6 +11,33 @@
#include <file_cache.h>
#include <vfs.h>
#include <vm.h>
#include "io_requests.h"
static inline status_t
memset_physical(addr_t address, int value, size_t length)
{
while (length > 0) {
addr_t pageOffset = address % B_PAGE_SIZE;
addr_t virtualAddress;
status_t error = vm_get_physical_page(address - pageOffset,
&virtualAddress, 0);
if (error != B_OK)
return error;
size_t toSet = min_c(length, B_PAGE_SIZE - pageOffset);
memset((void*)(virtualAddress + pageOffset), value, toSet);
vm_put_physical_page(virtualAddress);
length -= toSet;
address += toSet;
}
return B_OK;
}
status_t
@ -41,12 +68,12 @@ VMVnodeCache::HasPage(off_t offset)
status_t
VMVnodeCache::Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes)
uint32 flags, size_t *_numBytes)
{
size_t bytesUntouched = *_numBytes;
status_t status = vfs_read_pages(fVnode, NULL, offset, vecs, count,
0, _numBytes);
flags, _numBytes);
bytesUntouched -= *_numBytes;
@ -61,9 +88,12 @@ VMVnodeCache::Read(off_t offset, const iovec *vecs, size_t count,
for (int32 i = count; i-- > 0 && bytesUntouched != 0;) {
size_t length = min_c(bytesUntouched, vecs[i].iov_len);
// ToDo: will have to map the pages in later (when we switch to physical pages)
memset((void *)((addr_t)vecs[i].iov_base + vecs[i].iov_len - length),
0, length);
addr_t address = (addr_t)vecs[i].iov_base + vecs[i].iov_len - length;
if ((flags & B_PHYSICAL_IO_REQUEST) != 0)
memset_physical(address, 0, length);
else
memset((void*)address, 0, length);
bytesUntouched -= length;
}

View File

@ -20,7 +20,7 @@ public:
virtual bool HasPage(off_t offset);
virtual status_t Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes);
uint32 flags, size_t *_numBytes);
virtual status_t Write(off_t offset, const iovec *vecs, size_t count,
uint32 flags, size_t *_numBytes);
virtual status_t WriteAsync(off_t offset, const iovec* vecs,

View File

@ -496,7 +496,7 @@ VMAnonymousCache::HasPage(off_t offset)
status_t
VMAnonymousCache::Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes)
uint32 flags, size_t *_numBytes)
{
off_t pageIndex = offset >> PAGE_SHIFT;
@ -517,7 +517,7 @@ VMAnonymousCache::Read(off_t offset, const iovec *vecs, size_t count,
* B_PAGE_SIZE;
status_t status = vfs_read_pages(swapFile->vnode, swapFile->cookie, pos,
vecs + i, j - i, 0, _numBytes);
vecs + i, j - i, flags, _numBytes);
if (status != B_OK)
return status;
}

View File

@ -39,7 +39,7 @@ public:
virtual bool HasPage(off_t offset);
virtual status_t Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes);
uint32 flags, size_t *_numBytes);
virtual status_t Write(off_t offset, const iovec *vecs, size_t count,
uint32 flags, size_t *_numBytes);
virtual status_t WriteAsync(off_t offset, const iovec* vecs,

View File

@ -96,7 +96,7 @@ VMAnonymousNoSwapCache::HasPage(off_t offset)
status_t
VMAnonymousNoSwapCache::Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes)
uint32 flags, size_t *_numBytes)
{
panic("anonymous_store: read called. Invalid!\n");
return B_ERROR;

View File

@ -23,7 +23,7 @@ public:
virtual bool HasPage(off_t offset);
virtual status_t Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes);
uint32 flags, size_t *_numBytes);
virtual status_t Write(off_t offset, const iovec *vecs, size_t count,
uint32 flags, size_t *_numBytes);

View File

@ -27,7 +27,7 @@ VMDeviceCache::HasPage(off_t offset)
status_t
VMDeviceCache::Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes)
uint32 flags, size_t *_numBytes)
{
panic("device_store: read called. Invalid!\n");
return B_ERROR;

View File

@ -19,7 +19,7 @@ public:
virtual bool HasPage(off_t offset);
virtual status_t Read(off_t offset, const iovec *vecs, size_t count,
size_t *_numBytes);
uint32 flags, size_t *_numBytes);
virtual status_t Write(off_t offset, const iovec *vecs, size_t count,
uint32 flags, size_t *_numBytes);

View File

@ -45,6 +45,7 @@
#include <vm_priv.h>
#include "VMAnonymousCache.h"
#include "io_requests.h"
//#define TRACE_VM
@ -4438,15 +4439,12 @@ fault_find_page(vm_translation_map *map, vm_cache *topCache,
// get a virtual address for the page
iovec vec;
map->ops->get_physical_page(
page->physical_page_number * B_PAGE_SIZE,
(addr_t *)&vec.iov_base, PHYSICAL_PAGE_CAN_WAIT);
vec.iov_base = (void*)(page->physical_page_number * B_PAGE_SIZE);
size_t bytesRead = vec.iov_len = B_PAGE_SIZE;
// read it in
status_t status = cache->Read(cacheOffset, &vec, 1, &bytesRead);
map->ops->put_physical_page((addr_t)vec.iov_base);
status_t status = cache->Read(cacheOffset, &vec, 1,
B_PHYSICAL_IO_REQUEST, &bytesRead);
cache->Lock();

View File

@ -861,7 +861,8 @@ VMCache::HasPage(off_t offset)
status_t
VMCache::Read(off_t offset, const iovec *vecs, size_t count, size_t *_numBytes)
VMCache::Read(off_t offset, const iovec *vecs, size_t count, uint32 flags,
size_t *_numBytes)
{
return B_ERROR;
}