Commit cfe546ee authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9637fdac
......@@ -467,6 +467,35 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
return make_pair(mmap, nil);
}
// unmap releases mapping memory from address space.
//
// After call to unmap the mapping must no longer be used.
// virtmem calls unmap when VMA is unmapped.
error _Mapping::unmap() {
Mapping mmap = newref(this); // XXX newref for std::remove
FileH f = mmap->fileh;
xerr::Contextf E("wcfs %s: conn @%s: f<%s>: unmap",
v(f->wconn->_wc->mountpoint), v(f->wconn->at), v(f->foid));
// XXX locking
// XXX make sure mmap cannot be XXX
error err = mm::unmap(mmap->mem_start, mmap->mem_stop - mmap->mem_start);
mmap->mem_start = NULL;
mmap->mem_stop = NULL;
// XXX clear other fields?
//f->_mmaps.remove(mmap);
// FIXME keep mmaps sorted
f->_mmaps.erase(
std::remove(f->_mmaps.begin(), f->_mmaps.end(), mmap),
f->_mmaps.end());
return E(err);
}
// resync resyncs connection and its mappings onto different database view.
error _Conn::resync(zodb::Tid at) {
_Conn& wconn = *this;
......@@ -543,35 +572,6 @@ error _Conn::resync(zodb::Tid at) {
return nil;
}
// unmap releases mapping memory from address space.
//
// After call to unmap the mapping must no longer be used.
// virtmem calls unmap when VMA is unmapped.
error _Mapping::unmap() {
Mapping mmap = newref(this); // XXX newref for std::remove
FileH f = mmap->fileh;
xerr::Contextf E("wcfs %s: conn @%s: f<%s>: unmap",
v(f->wconn->_wc->mountpoint), v(f->wconn->at), v(f->foid));
// XXX locking
// XXX make sure mmap cannot be XXX
error err = mm::unmap(mmap->mem_start, mmap->mem_stop - mmap->mem_start);
mmap->mem_start = NULL;
mmap->mem_stop = NULL;
// XXX clear other fields?
//f->_mmaps.remove(mmap);
// FIXME keep mmaps sorted
f->_mmaps.erase(
std::remove(f->_mmaps.begin(), f->_mmaps.end(), mmap),
f->_mmaps.end());
return E(err);
}
// _remmapblk remmaps mapping memory for file[blk] to be viewing database as of @at state.
//
// at=TidHead means unpin to head/ .
......
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