Commit cf77198f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a41fe05a
...@@ -145,11 +145,11 @@ ...@@ -145,11 +145,11 @@
// //
// XXX pinner takes the following locks (XXX recheck) // XXX pinner takes the following locks (XXX recheck)
// //
// - wconn.mu.W // - wconn.filehMu.W
// - wconn.mu.R // - wconn.filehMu.R
// //
// - wconn.atMu.R // - wconn.atMu.R
// - wconn.mu.R // - wconn.filehMu.R
// - fileh.mu (R:.mmaps W:.pinned) // - fileh.mu (R:.mmaps W:.pinned)
// //
// - virt_lock // - virt_lock
...@@ -264,7 +264,7 @@ error _Conn::close() { ...@@ -264,7 +264,7 @@ error _Conn::close() {
if (alreadyClosed) if (alreadyClosed)
return nil; return nil;
// close wlink and signal to pinner to stop outside of wconn.mu // close wlink and signal to pinner to stop outside of wconn.filehMu
err = wconn._wlink->close(); // XXX ok under atMu? err = wconn._wlink->close(); // XXX ok under atMu?
if (err != nil) if (err != nil)
reterr1(err); reterr1(err);
...@@ -317,7 +317,7 @@ error _Conn::_pinner(context::Context ctx) { ...@@ -317,7 +317,7 @@ error _Conn::_pinner(context::Context ctx) {
} }
// mark the connection non-operational if the pinner fails // mark the connection non-operational if the pinner fails
// XXX deadlock wrt resync? (who read-locks wconn.mu) // XXX deadlock wrt resync? (who read-locks wconn.filehMu)
// XXX -> mu -> downMu ? // XXX -> mu -> downMu ?
wconn._filehMu.Lock(); // XXX locking ok? -> merge into below where lock is held? wconn._filehMu.Lock(); // XXX locking ok? -> merge into below where lock is held?
if (wconn._downErr == nil) { if (wconn._downErr == nil) {
...@@ -387,7 +387,7 @@ error _Conn::__pin1(PinReq *req) { ...@@ -387,7 +387,7 @@ error _Conn::__pin1(PinReq *req) {
wconn._atMu.RUnlock(); wconn._atMu.RUnlock();
}); });
// XXX deadlock wrt Conn.resync which locks wconn.mu and does "watch" ? // XXX deadlock wrt Conn.resync which locks wconn.filehMu and does "watch" ?
wconn._filehMu.RLock(); wconn._filehMu.RLock();
// XXX +incref f, so that simultaneous close does not remove f from wconn.filehTab ? // XXX +incref f, so that simultaneous close does not remove f from wconn.filehTab ?
// XXX or just make FileH.close lock f too to synchronize with pinner? // XXX or just make FileH.close lock f too to synchronize with pinner?
...@@ -400,7 +400,7 @@ error _Conn::__pin1(PinReq *req) { ...@@ -400,7 +400,7 @@ error _Conn::__pin1(PinReq *req) {
// XXX <- f._openReady ? // XXX <- f._openReady ?
wconn._filehMu.RUnlock(); // XXX maybe `f.mu.lock() -> wconn.mu.unlock()` to avoid race with FileH close? wconn._filehMu.RUnlock(); // XXX maybe `f.mu.lock() -> wconn.filehMu.unlock()` to avoid race with FileH close?
f->_mu.lock(); f->_mu.lock();
defer([&]() { defer([&]() {
f->_mu.unlock(); f->_mu.unlock();
...@@ -511,7 +511,7 @@ error _Conn::resync(zodb::Tid at) { ...@@ -511,7 +511,7 @@ error _Conn::resync(zodb::Tid at) {
// set new wconn.at early, so that e.g. Conn.open running simultaneously // set new wconn.at early, so that e.g. Conn.open running simultaneously
// to second part of resync (see below) uses new at. // to second part of resync (see below) uses new at.
// XXX no need since wconn._filehMu is locked? -> no - it is *needed* after wconn.mu became RWMutex // XXX no need since wconn._filehMu is locked? -> no - it is *needed* after wconn.filehMu became RWMutex
wconn.at = at; wconn.at = at;
// go through all files opened under wconn and pre-adjust their mappings // go through all files opened under wconn and pre-adjust their mappings
...@@ -707,9 +707,9 @@ retry: ...@@ -707,9 +707,9 @@ retry:
// _open performs actual open of FileH marked as "in-flight-open" in wconn.filehTab. // _open performs actual open of FileH marked as "in-flight-open" in wconn.filehTab.
// //
// Called with: // Called with:
// - wconn.atMu held // - wconn.atMu held
// - wconn.mu not locked // - wconn.filehMu not locked
// - f.mu not locked // - f.mu not locked
error _FileH::_open() { error _FileH::_open() {
_FileH* f = this; _FileH* f = this;
Conn wconn = f->wconn; Conn wconn = f->wconn;
...@@ -737,7 +737,7 @@ error _FileH::_open() { ...@@ -737,7 +737,7 @@ error _FileH::_open() {
v(f->_headf->name()), f->_headfsize, f->blksize); v(f->_headf->name()), f->_headfsize, f->blksize);
// start watching f // start watching f
// NOTE we are _not_ holding wconn.mu nor f.mu - only wconn.atMu to rely on wconn.at being stable. // NOTE we are _not_ holding wconn.filehMu nor f.mu - only wconn.atMu to rely on wconn.at being stable.
// NOTE wcfs will reply "ok" only after wcfs/head/at ≥ wconn.at // NOTE wcfs will reply "ok" only after wcfs/head/at ≥ wconn.at
string ack; string ack;
// XXX f._watchMu.lock() + unlock ? // XXX f._watchMu.lock() + unlock ?
...@@ -783,7 +783,7 @@ error _FileH::close() { ...@@ -783,7 +783,7 @@ error _FileH::close() {
ASSERT(fileh._state == _FileHOpened); // there can be no open-in-progress, because ASSERT(fileh._state == _FileHOpened); // there can be no open-in-progress, because
fileh._state = _FileHClosing; // .close() can be called only on "opened" fileh fileh._state = _FileHClosing; // .close() can be called only on "opened" fileh
// unlock wconn.mu to stop watching outside of this lock. // unlock wconn._filehMu to stop watching outside of this lock.
// we'll relock it again before updating wconn.filehTab. // we'll relock it again before updating wconn.filehTab.
wconn->_filehMu.Unlock(); wconn->_filehMu.Unlock();
......
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