Commit e5e027cd authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2d2bc897
Subproject commit ce4660aa49404530a608a37754fae16fbb3fde02
Subproject commit 7aac849abf06ef469c2aad9a0dd6e3bb82ef1f96
......@@ -30,6 +30,7 @@
#include <wendelin/bug.h>
#include <ccan/minmax/minmax.h>
#include <ccan/bitmap/bitmap.h>
#include <sys/mman.h>
#include <errno.h>
......@@ -1153,6 +1154,23 @@ static void vma_page_ensure_notmappedrw(VMA *vma, Page *page)
xmprotect(vma_page_addr(vma, page), page_size(page), PROT_READ);
}
/* return whether fileh page is dirty or not.
*
* must be called under virtmem lock.
*/
bool __fileh_page_isdirty(BigFileH *fileh, pgoff_t pgoffset)
{
Page *page;
// XXX sigsegv_block ?
page = pagemap_get(&fileh->pagemap, pgoffset);
if (!page)
return false;
return (page->state == PAGE_DIRTY);
}
// XXX stub
void OOM(void)
......
......@@ -34,6 +34,7 @@
*/
#include <stdint.h>
#include <stdbool.h>
#include <wendelin/list.h>
#include <wendelin/bigfile/types.h>
#include <wendelin/bigfile/pagemap.h>
......@@ -360,6 +361,7 @@ typedef struct VirtGilHooks VirtGilHooks;
void virt_lock_hookgil(const VirtGilHooks *gilhooks);
bool __fileh_page_isdirty(BigFileH *fileh, pgoff_t pgoff);
// XXX is this needed? think more
/* what happens on out-of-memory */
......
......@@ -98,8 +98,10 @@ struct _File {
struct _Mapping {
_File *file;
int blk_start; // offset of this mapping in file
uint8_t *mem_start; // mmapped memory [mem_start, mem_stop)
uint8_t *mem_stop;
BigFileH *fileh; // mmapped under this file handle
uint8_t *mem_start; // mmapped memory [mem_start, mem_stop)
uint8_t *mem_stop;
int64_t blk_stop() const {
ASSERT((mem_stop - mem_start) % file->blksize == 0);
......@@ -190,7 +192,8 @@ void Conn::_pin1(SrvReq *req) {
//trace("\tremmapblk %d @%s" % (req->blk, (h(req.at) if req.at else "head")))
// check if virtmem did not dirtied page corresponding to this block already
virt_lock();
if (!fileh_blk_isdirty(mmap->fileh, req->blk))
TODO (mmap->file->blksize != mmap->filh->ramh->pagesize);
if (!__fileh_page_isdirty(mmap->fileh, req->blk))
mmap->_remmapblk(req.blk, req.at);
virt_unlock();
//trace("\t-> remmaped"); XXX
......
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