* 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:
parent
b99c736b83
commit
4eaa43ac48
@ -213,7 +213,7 @@ public:
|
|||||||
virtual bool HasPage(off_t offset);
|
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,
|
||||||
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 WriteAsync(off_t offset, const iovec* vecs,
|
virtual status_t WriteAsync(off_t offset, const iovec* vecs,
|
||||||
|
40
src/system/kernel/cache/vnode_store.cpp
vendored
40
src/system/kernel/cache/vnode_store.cpp
vendored
@ -11,6 +11,33 @@
|
|||||||
|
|
||||||
#include <file_cache.h>
|
#include <file_cache.h>
|
||||||
#include <vfs.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
|
status_t
|
||||||
@ -41,12 +68,12 @@ VMVnodeCache::HasPage(off_t offset)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
VMVnodeCache::Read(off_t offset, const iovec *vecs, size_t count,
|
VMVnodeCache::Read(off_t offset, const iovec *vecs, size_t count,
|
||||||
size_t *_numBytes)
|
uint32 flags, size_t *_numBytes)
|
||||||
{
|
{
|
||||||
size_t bytesUntouched = *_numBytes;
|
size_t bytesUntouched = *_numBytes;
|
||||||
|
|
||||||
status_t status = vfs_read_pages(fVnode, NULL, offset, vecs, count,
|
status_t status = vfs_read_pages(fVnode, NULL, offset, vecs, count,
|
||||||
0, _numBytes);
|
flags, _numBytes);
|
||||||
|
|
||||||
bytesUntouched -= *_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;) {
|
for (int32 i = count; i-- > 0 && bytesUntouched != 0;) {
|
||||||
size_t length = min_c(bytesUntouched, vecs[i].iov_len);
|
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)
|
addr_t address = (addr_t)vecs[i].iov_base + vecs[i].iov_len - length;
|
||||||
memset((void *)((addr_t)vecs[i].iov_base + vecs[i].iov_len - length),
|
if ((flags & B_PHYSICAL_IO_REQUEST) != 0)
|
||||||
0, length);
|
memset_physical(address, 0, length);
|
||||||
|
else
|
||||||
|
memset((void*)address, 0, length);
|
||||||
|
|
||||||
bytesUntouched -= length;
|
bytesUntouched -= length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
src/system/kernel/cache/vnode_store.h
vendored
2
src/system/kernel/cache/vnode_store.h
vendored
@ -20,7 +20,7 @@ public:
|
|||||||
virtual bool HasPage(off_t offset);
|
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,
|
||||||
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 WriteAsync(off_t offset, const iovec* vecs,
|
virtual status_t WriteAsync(off_t offset, const iovec* vecs,
|
||||||
|
@ -496,7 +496,7 @@ VMAnonymousCache::HasPage(off_t offset)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
VMAnonymousCache::Read(off_t offset, const iovec *vecs, size_t count,
|
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;
|
off_t pageIndex = offset >> PAGE_SHIFT;
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ VMAnonymousCache::Read(off_t offset, const iovec *vecs, size_t count,
|
|||||||
* B_PAGE_SIZE;
|
* B_PAGE_SIZE;
|
||||||
|
|
||||||
status_t status = vfs_read_pages(swapFile->vnode, swapFile->cookie, pos,
|
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)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
virtual bool HasPage(off_t offset);
|
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,
|
||||||
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 WriteAsync(off_t offset, const iovec* vecs,
|
virtual status_t WriteAsync(off_t offset, const iovec* vecs,
|
||||||
|
@ -96,7 +96,7 @@ VMAnonymousNoSwapCache::HasPage(off_t offset)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
VMAnonymousNoSwapCache::Read(off_t offset, const iovec *vecs, size_t count,
|
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");
|
panic("anonymous_store: read called. Invalid!\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
virtual bool HasPage(off_t offset);
|
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,
|
||||||
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);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ VMDeviceCache::HasPage(off_t offset)
|
|||||||
|
|
||||||
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,
|
||||||
size_t *_numBytes)
|
uint32 flags, size_t *_numBytes)
|
||||||
{
|
{
|
||||||
panic("device_store: read called. Invalid!\n");
|
panic("device_store: read called. Invalid!\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
virtual bool HasPage(off_t offset);
|
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,
|
||||||
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);
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <vm_priv.h>
|
#include <vm_priv.h>
|
||||||
|
|
||||||
#include "VMAnonymousCache.h"
|
#include "VMAnonymousCache.h"
|
||||||
|
#include "io_requests.h"
|
||||||
|
|
||||||
|
|
||||||
//#define TRACE_VM
|
//#define TRACE_VM
|
||||||
@ -4438,15 +4439,12 @@ fault_find_page(vm_translation_map *map, vm_cache *topCache,
|
|||||||
|
|
||||||
// get a virtual address for the page
|
// get a virtual address for the page
|
||||||
iovec vec;
|
iovec vec;
|
||||||
map->ops->get_physical_page(
|
vec.iov_base = (void*)(page->physical_page_number * B_PAGE_SIZE);
|
||||||
page->physical_page_number * B_PAGE_SIZE,
|
|
||||||
(addr_t *)&vec.iov_base, PHYSICAL_PAGE_CAN_WAIT);
|
|
||||||
size_t bytesRead = vec.iov_len = B_PAGE_SIZE;
|
size_t bytesRead = vec.iov_len = B_PAGE_SIZE;
|
||||||
|
|
||||||
// read it in
|
// read it in
|
||||||
status_t status = cache->Read(cacheOffset, &vec, 1, &bytesRead);
|
status_t status = cache->Read(cacheOffset, &vec, 1,
|
||||||
|
B_PHYSICAL_IO_REQUEST, &bytesRead);
|
||||||
map->ops->put_physical_page((addr_t)vec.iov_base);
|
|
||||||
|
|
||||||
cache->Lock();
|
cache->Lock();
|
||||||
|
|
||||||
|
@ -861,7 +861,8 @@ VMCache::HasPage(off_t offset)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
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;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user