Commit 7a2b1dad authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f4e73727
...@@ -120,6 +120,7 @@ error _Conn::close() { ...@@ -120,6 +120,7 @@ error _Conn::close() {
_Conn& wconn = *this; _Conn& wconn = *this;
xerr::Contextf E("wcfs %s: close conn @%s", v(wconn._wc->mountpoint), v(wconn.at)); xerr::Contextf E("wcfs %s: close conn @%s", v(wconn._wc->mountpoint), v(wconn.at));
// XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself? // XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself?
// (or ._wlink._f.fd() ?)
error err, eret; error err, eret;
auto reterr1 = [&eret](error err) { auto reterr1 = [&eret](error err) {
...@@ -241,6 +242,7 @@ error _Conn::__pin1(PinReq *req) { ...@@ -241,6 +242,7 @@ error _Conn::__pin1(PinReq *req) {
FileH f; FileH f;
bool ok; bool ok;
// XXX deadlock wrt Conn.open which locks wconn.filehmu and starts initial "watch"
wconn._filehmu.lock(); wconn._filehmu.lock();
// 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 ?
tie(f, ok) = wconn._filehtab.get_(req->foid); tie(f, ok) = wconn._filehtab.get_(req->foid);
...@@ -252,7 +254,7 @@ error _Conn::__pin1(PinReq *req) { ...@@ -252,7 +254,7 @@ error _Conn::__pin1(PinReq *req) {
// XXX relock wconn -> f // XXX relock wconn -> f
for (auto mmap : f->_mmaps) { // XXX use ↑blk_start for binary search for (auto mmap : f->_mmaps) { // TODO use ↑blk_start for binary search
if (!(mmap->blk_start <= req->blk && req->blk < mmap->blk_stop())) if (!(mmap->blk_start <= req->blk && req->blk < mmap->blk_stop()))
continue; // blk ∉ mmap continue; // blk ∉ mmap
...@@ -365,6 +367,8 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) { ...@@ -365,6 +367,8 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
}); });
// start watching f // start watching f
// XXX if we start watching with holding either wconn.filehMu or f.Mu, then
// the pinner will deadlock, trying to take wconn.filehMu or f.Mu
string ack; string ack;
tie(ack, err) = wconn._wlink->sendReq(context::background(), fmt::sprintf("watch %s @%s", v(foid), v(wconn.at))); tie(ack, err) = wconn._wlink->sendReq(context::background(), fmt::sprintf("watch %s @%s", v(foid), v(wconn.at)));
if (err != nil) if (err != nil)
...@@ -385,6 +389,8 @@ error _FileH::close() { ...@@ -385,6 +389,8 @@ error _FileH::close() {
Conn wconn = fileh.wconn; Conn wconn = fileh.wconn;
xerr::Contextf E("wcfs %s: conn @%s: close f<%s>", v(wconn->_wc->mountpoint), v(wconn->at), v(fileh.foid)); xerr::Contextf E("wcfs %s: conn @%s: close f<%s>", v(wconn->_wc->mountpoint), v(wconn->at), v(fileh.foid));
// XXX change all fileh.mmaps to cause EFAULT on any access after fileh.close
// remove fileh from wconn._filehtab // remove fileh from wconn._filehtab
// fileh.close can be called several times and after first call another // fileh.close can be called several times and after first call another
// fileh could be opened for the same foid. Be careful not to erase it. // fileh could be opened for the same foid. Be careful not to erase it.
......
...@@ -224,6 +224,7 @@ struct _FileH : object { ...@@ -224,6 +224,7 @@ struct _FileH : object {
zodb::Oid foid; // ZBigFile root object ID (does not change after fileh open) zodb::Oid foid; // ZBigFile root object ID (does not change after fileh open)
size_t blksize; // block size of this file (does not change after fileh open) size_t blksize; // block size of this file (does not change after fileh open)
os::File _headf; // file object of head/file os::File _headf; // file object of head/file
off_t _headfsize; // head/file size is known to be at least headfsize (size ↑=) off_t _headfsize; // head/file size is known to be at least headfsize (size ↑=)
dict<int64_t, zodb::Tid> _pinned; // {} blk -> rev that wcfs already sent us for this file dict<int64_t, zodb::Tid> _pinned; // {} blk -> rev that wcfs already sent us for this file
......
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