Commit 516f4625 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/virtmem: fileh_mmap: Refactor a bit

Start preparing vma early, not after the call to mem_valloc.
This codeflow will be more convenient when we add mmap-through-wcfs codepath.
parent 4cbd819c
...@@ -219,9 +219,12 @@ int fileh_mmap(VMA *vma, BigFileH *fileh, pgoff_t pgoffset, pgoff_t pglen) ...@@ -219,9 +219,12 @@ int fileh_mmap(VMA *vma, BigFileH *fileh, pgoff_t pgoffset, pgoff_t pglen)
sigsegv_block(&save_sigset); sigsegv_block(&save_sigset);
virt_lock(); virt_lock();
/* alloc vma->page_ismappedv[] */ /* start preparing vma */
bzero(vma, sizeof(*vma)); bzero(vma, sizeof(*vma));
vma->fileh = fileh;
vma->f_pgoffset = pgoffset;
/* alloc vma->page_ismappedv[] */
vma->page_ismappedv = bitmap_alloc0(pglen); vma->page_ismappedv = bitmap_alloc0(pglen);
if (!vma->page_ismappedv) if (!vma->page_ismappedv)
goto fail; goto fail;
...@@ -235,8 +238,6 @@ int fileh_mmap(VMA *vma, BigFileH *fileh, pgoff_t pgoffset, pgoff_t pglen) ...@@ -235,8 +238,6 @@ int fileh_mmap(VMA *vma, BigFileH *fileh, pgoff_t pgoffset, pgoff_t pglen)
vma->addr_start = (uintptr_t)addr; vma->addr_start = (uintptr_t)addr;
vma->addr_stop = vma->addr_start + len; vma->addr_stop = vma->addr_start + len;
vma->fileh = fileh;
vma->f_pgoffset = pgoffset;
// XXX need to init vma->virt_list first? // XXX need to init vma->virt_list first?
/* hook vma to fileh->mmaps */ /* hook vma to fileh->mmaps */
...@@ -252,7 +253,7 @@ out: ...@@ -252,7 +253,7 @@ out:
fail: fail:
free(vma->page_ismappedv); free(vma->page_ismappedv);
vma->page_ismappedv = NULL; bzero(vma, sizeof(*vma));
err = -1; err = -1;
goto out; goto out;
} }
......
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