Commit a1a06fea authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 3310888d
......@@ -45,6 +45,9 @@
// Mapping FileH
//
// XXX locking -> explain atMu + slaves and refer to "Locking" in wcfs.go
#include "wcfs_misc.h"
#include "wcfs.h"
#include "wcfs_watchlink.h"
......@@ -297,6 +300,9 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
error err;
xerr::Contextf E("wcfs %s: conn @%s: open f<%s>", v(wconn._wc->mountpoint), v(wconn.at), v(foid));
// XXX wconn._atMu.RLock()
// XXX defer wconn._atMu.RUnlock()
wconn._filehmu.lock();
defer([&]() {
wconn._filehmu.unlock();
......@@ -401,6 +407,9 @@ 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;
// XXX wconn.atMu.RLock()
// XXX defer wconn.atMu.RUnlock()
// XXX f locking?
// create memory with head/f mapping and applied pins
......@@ -459,6 +468,9 @@ error _Conn::resync(zodb::Tid at) {
xerr::Contextf E("wcfs %s: conn @%s: resync -> @%s", v(wconn._wc->mountpoint), v(wconn.at), v(at));
// XXX locking
// wconn.atMu.Lock()
// defer wconn.atMu.Unlock()
error err;
wconn._downMu.lock();
......@@ -517,7 +529,6 @@ error _Conn::resync(zodb::Tid at) {
if (err != nil)
return E(err);
if (ack != "ok") {
// XXX unregister f from _filehtab ?
return E(fmt::errorf("%s", v(ack)));
}
}
......@@ -617,10 +628,9 @@ error _Mapping::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);
if (err != nil)
return E(err);
mmap->mem_start = NULL;
mmap->mem_stop = NULL;
// XXX clear other fields?
......@@ -632,7 +642,7 @@ error _Mapping::unmap() {
std::remove(f->_mmaps.begin(), f->_mmaps.end(), mmap),
f->_mmaps.end());
return nil;
return E(err);
}
......
......@@ -167,14 +167,23 @@ struct WCFS {
typedef refptr<struct _Conn> Conn;
struct _Conn : object {
WCFS *_wc;
zodb::Tid at; // XXX -> under mu
WatchLink _wlink; // watch/receive pins for mappings created under this conn
// atMu protects .at.
// While it is rlocked, .at is guaranteed to stay unchanged and Conn
// viewing the database at particular state. .resync write-locks this and
// knows noone is using the connection for reading simultaneously.
//
// XXX deadlock with pinner?
//
// sync::RWMutex _atMu
zodb::Tid at;
// XXX kill downMu? (move under filehmu so that e.g. .open() can check downErr without race)
sync::Mutex _downMu;
error _downErr; // !nil if connection is closed or no longer operational
sync::Mutex _filehmu;
sync::Mutex _filehmu; // _atMu.W | _atMu.R + _filehMu
dict<zodb::Oid, FileH> _filehtab; // {} foid -> fileh
sync::WorkGroup _pinWG; // pin/unpin messages from wcfs are served by _pinner
......
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