Commit 50f78858 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 00894b04
......@@ -705,6 +705,7 @@ error _FileH::close() {
// XXX decref open count
// XXX fileh.close can be called several times and after first call another
// XXX fileh could be opened for the same foid. Be careful not to interfere with it.
// -> just return nil for second close
// XXX locking ok?
wconn->_atMu.RLock();
......@@ -740,6 +741,16 @@ error _FileH::close() {
// virtmem calls FileH::mmap under virtmem lock when virtmem fileh is mmapped into vma.
pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma) {
_FileH& f = *this;
// NOTE virtmem lock is held by virtmem caller
// XXX locking ok?
f.wconn->_atMu.RLock(); // e.g. f._headfsize
f._mu.lock(); // f._pinned, f._mmaps
defer([&]() {
f._mu.unlock();
f.wconn->_atMu.RUnlock();
});
xerr::Contextf E("%s: mmap f<%s> [blk%ld +blk%ld)", v(f.wconn), v(f.foid), blk_start, blk_len);
error err;
......@@ -758,10 +769,6 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
panic("(blk_start + blk_len)*f.blksize overflow int64");
int64_t start = blk_start*f.blksize;
// NOTE virtmem lock is held by virtmem caller
// XXX locking
// XXX + wconn.atMu.RLock() ? -> y (e.g. f.headfsize is used)
// f.mu.lock()
// create memory with head/f mapping and applied pins
// mmap-in zeros after f.size (else access to memory after file.size will raise SIGBUS)
......@@ -828,11 +835,17 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
error _Mapping::unmap() {
Mapping mmap = newref(this); // XXX newref for std::remove
FileH f = mmap->fileh;
xerr::Contextf E("%s: f<%s>: unmap", v(f->wconn), v(f->foid));
// NOTE virtmem lock is held by virtmem caller
// XXX locking
// wconn.atMu.RLock() + f.mu.lock()
// XXX locking ok?
f->wconn->_atMu.RLock();
f->_mu.lock(); // f._mmaps
defer([&]() {
f->_mu.unlock();
f->wconn->_atMu.RUnlock();
});
xerr::Contextf E("%s: f<%s>: unmap", v(f->wconn), v(f->foid));
if (mmap->vma != nil) {
mmap->_assertVMAOk();
......
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