Commit bc041be8 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d874ccae
......@@ -226,6 +226,7 @@ int fileh_mmap(VMA *vma, BigFileH *fileh, pgoff_t pgoffset, pgoff_t pglen)
goto fail;
/* allocate address space somewhere */
// XXX overlay: -> mmap(base, READ)
addr = mem_valloc(NULL, len);
if (!addr)
goto fail;
......@@ -382,6 +383,8 @@ int fileh_dirty_writeout(BigFileH *fileh, enum WriteoutFlags flags)
}
/* page.state -> PAGE_LOADED and correct mappings RW -> R */
// XXX adjust(wcfs): just remmap base file? (but it does not yet have stored changes)
// XXX -> vma_remove_readonly_overlay()?
if (flags & WRITEOUT_MARKSTORED) {
page->state = PAGE_LOADED;
list_del_init(&page->in_dirty);
......@@ -588,6 +591,8 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
/* continuing on_pagefault() - see (1) there ... */
// XXX overlay: assert write
/* (2) vma, addr -> fileh, pagen ;idx of fileh page covering addr */
fileh = vma->fileh;
pagen = vma_addr_fpgoffset(vma, addr);
......@@ -595,6 +600,8 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
/* (3) fileh, pagen -> page (via pagemap) */
page = pagemap_get(&fileh->pagemap, pagen);
// XXX overlay: assert !page
/* (4) no page found - allocate new from ram */
while (!page) {
page = ramh_alloc_page(fileh->ramh, pagen);
......@@ -663,6 +670,9 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
pageram = page_mmap(page, NULL, PROT_READ | PROT_WRITE);
TODO(!pageram); // XXX err
// XXX overlay: copy data from base image, page.state=DIRTY
// XXX overlay: goto inject_page
/* loadblk() -> pageram memory */
blk = page->f_pgoffset; // NOTE because blksize = pagesize
......@@ -732,6 +742,7 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
return VM_RETRY;
}
inject_page:
/* (6) page data ready. Mmap it atomically into vma address space, or mprotect
* appropriately if it was already mmaped. */
int prot = PROT_READ;
......@@ -741,6 +752,9 @@ VMFaultResult vma_on_pagefault(VMA *vma, uintptr_t addr, int write)
newstate = PAGE_DIRTY;
}
// XXX overlay: assert !vma->page_ismappedv[blk]
// XXX overlay: mmap page to all vma of this fileh.
if (!bitmap_test_bit(vma->page_ismappedv, page->f_pgoffset - vma->f_pgoffset)) {
// XXX err
page_mmap(page, vma_page_addr(vma, page), prot);
......@@ -939,6 +953,7 @@ static void vma_page_ensure_unmapped(VMA *vma, Page *page)
return;
/* mmap empty PROT_NONE address space instead of page memory */
// XXX overlay: remmap to base image
mem_xvalloc(vma_page_addr(vma, page), page_size(page));
bitmap_clear_bit(vma->page_ismappedv, page->f_pgoffset - vma->f_pgoffset);
......
......@@ -154,6 +154,10 @@ struct VMA {
*/
int fileh_open(BigFileH *fileh, BigFile *file, RAM *ram);
// XXX + fileh_open_overlay(fileh, file, base, ram) ?
// here base is glued data from head/bigfile/file + revX/bigfile/file overwrites.
// file will be used only to storeblk (loadblk=BUG).
/* close fileh
*
......
......@@ -1621,6 +1621,8 @@ func main() {
go root.zwatcher(ctx)
// TODO handle autoexit
// (exit when kernel forgets all our inodes - wcfs.py keeps .wcfs/zurl
// opened, so when all inodes has been forgotten - we know all wcfs.py clients exited)
_ = autoexit
// serve client requests
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment