Commit 786cab49 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8d9067f0
......@@ -28,6 +28,9 @@ using std::string;
#include <tuple>
using std::tuple;
// nil is synonim for nullptr and NULL.
const nullptr_t nil = nullptr;
// error mimics error from Go.
struct error {
string err;
......
......@@ -123,7 +123,7 @@ struct _Mapping {
return blk_start + (mem_stop - mem_start) / file->blksize;
}
void _remmapblk(int64_t blk, Tid at);
error _remmapblk(int64_t blk, Tid at);
};
......@@ -211,7 +211,7 @@ void Conn::_pin1(SrvReq *req) {
virt_lock();
TODO (mmap->file->blksize != mmap->fileh->ramh->ram->pagesize);
if (!__fileh_page_isdirty(mmap->fileh, req->blk))
mmap->_remmapblk(req->blk, req->at);
mmap->_remmapblk(req->blk, req->at); // XXX err
virt_unlock();
//trace("\t-> remmaped"); XXX
}
......@@ -234,7 +234,7 @@ void Conn::_pin1(SrvReq *req) {
//
// at=None means unpin to head/ . XXX -> C
// NOTE this does not check wrt virtmem already mapped blk as RW.
void _Mapping::_remmapblk(int64_t blk, Tid at) {
error _Mapping::_remmapblk(int64_t blk, Tid at) {
// XXX err context?
_Mapping *mmap = this;
......@@ -248,8 +248,9 @@ void _Mapping::_remmapblk(int64_t blk, Tid at) {
}
else {
// TODO share @rev fd until wconn is resynced?
fsfile = f->wconn->_wc->_open("@%s/bigfile/%s" % (h(at), h(f->foid)), "rb")
defer(fsfile.close)
fsfile = f->wconn->_wc->_open("@%s/bigfile/%s" % (h(at), h(f->foid)), "rb");
// XXX err
defer(fsfile.close);
}
struct stat st;
......@@ -260,12 +261,14 @@ void _Mapping::_remmapblk(int64_t blk, Tid at) {
// block is beyond file size - mmap with zeros (assumes head/f size ↑=)
if ((blk+1)*f->blksize > st.st_size) {
mm.map_zero_into_ro(blkmem);
mm.map_zero_into_ro(blkmem); // XXX err
}
// block is inside file - mmap file data
else {
mm.map_into_ro(blkmem, fsfile.fd, blk*f->blksize);
mm.map_into_ro(blkmem, fsfile.fd, blk*f->blksize); // XXX err
}
return nil;
}
......
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