vmmcache: pushpage

This commit is contained in:
Matheus
2024-07-16 20:48:46 -03:00
parent 645e1e2809
commit f3e09527c9
2 changed files with 22 additions and 0 deletions
+1
View File
@@ -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);
+21
View File
@@ -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();