Commit fed7c147 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 74d170c6
......@@ -87,29 +87,6 @@ class WCFS(_WCFS):
# ._proc wcfs process if it was opened by this WCFS | None
pass
"""
# remmap_blk remmaps file[blk] in its place again.
# virtmem calls this to remmap a block after RW dirty page was e.g. discarded.
@func(_Mapping)
def remmap_blk(mmap, blk):
# XXX locking
assert (mmap.blk_start <= blk < mmap.blk_stop)
blkrev = mmap.pinned.get(blk, None) # rev | @head
mmap._remmapblk(blk, blkrev)
# unmap is removes mapping memory from address space.
# virtmem calls this when VMA is unmapped.
@func(_Mapping)
def unmap(mmap):
# XXX locking
mm.unmap(mmap.mem)
mmap.mem = None
f = mmap.file
f.mmaps.remove(mmap)
"""
# ---- WCFS raw file access ----
......
......@@ -173,6 +173,14 @@ error map_into(void *addr, size_t size, int prot, int flags, os::File f, off_t o
return nil;
}
// unmap unmaps [addr +size) memory previously mapped with map & co.
error unmap(void *addr, size_t size) {
int err = ::munmap(addr, size);
if (err != 0)
return os::_pathError("munmap", "<memory>" /*XXX ok?*/, errno);
return nil;
}
} // mm::
......
......@@ -122,7 +122,7 @@ tuple<File, error> open(const string &path, int flags = O_RDONLY,
namespace mm {
tuple<uint8_t*, error> map(int prot, int flags, os::File f, off_t offset, size_t size);
error map_into(void *addr, size_t size, int prot, int flags, os::File f, off_t offset);
// XXX unmap
error unmap(void *addr, size_t size);
} // mm::
......
......@@ -87,6 +87,7 @@ struct _Mapping {
error _remmapblk(int64_t blk, zodb::Tid at);
void remmap_blk(int64_t blk);
void unmap();
};
......@@ -481,7 +482,21 @@ void _Mapping::remmap_blk(int64_t blk) {
mmap._remmapblk(blk, blkrev); // XXX err
}
// XXX _Mapping::unmap
// unmap removes mapping memory from address space.
// virtmem calls this when VMA is unmapped.
void _Mapping::unmap() {
_Mapping* mmap = this;
// XXX locking
mm::unmap(mmap->mem_start, mmap->mem_stop - mmap->mem_start); // XXX err?
mmap->mem_start = NULL;
mmap->mem_stop = NULL;
// XXX clear other fields?
_File *f = mmap->file;
//f->mmaps.remove(mmap);
std::remove(f->mmaps.begin(), f->mmaps.end(), mmap); // XXX keep mmaps sorted
}
// ---- WCFS raw file access ----
......
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