mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
vmmcache: pushpage
This commit is contained in:
@@ -12,6 +12,7 @@ int vmmcache_takepage(page_t *page);
|
||||
int vmmcache_makedirty(page_t *page);
|
||||
int vmmcache_truncate(vnode_t *vnode, uintmax_t offset);
|
||||
int vmmcache_syncvnode(vnode_t *vnode, uintmax_t startoffset, size_t size);
|
||||
int vmmcache_pushpage(vnode_t *vnode, uintmax_t offset, page_t *page);
|
||||
int vmmcache_sync();
|
||||
int vmmcache_evict(page_t *page);
|
||||
|
||||
|
||||
@@ -191,6 +191,27 @@ int vmmcache_getpage(vnode_t *vnode, uintmax_t offset, page_t **res) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// adds a page to the cache in a specific offset if its not already there
|
||||
int vmmcache_pushpage(vnode_t *vnode, uintmax_t offset, page_t *page) {
|
||||
__assert((offset % PAGE_SIZE) == 0);
|
||||
HOLD_LOCK();
|
||||
|
||||
page_t *pagetest = findpage(vnode, offset);
|
||||
if (pagetest) {
|
||||
RELEASE_LOCK();
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
page->backing = vnode;
|
||||
page->offset = offset;
|
||||
page->flags |= PAGE_FLAGS_READY;
|
||||
|
||||
putpage(page);
|
||||
|
||||
RELEASE_LOCK();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// removes a page from the cache AND turns it into anonymous memory
|
||||
int vmmcache_evict(page_t *page) {
|
||||
HOLD_LOCK();
|
||||
|
||||
Reference in New Issue
Block a user