Commit dbaf1db9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

No related merge requests found
......@@ -311,11 +311,11 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
// Left fileh mappings become invalid to use.
error _FileH::close() {
_FileH& fileh = *this;
// XXX err ctx
xerr::Contextf E("conn @%s: close f<%s>", v(fileh.wconn->at), v(fileh.foid)); // XXX + wcfs path?
// XXX remove fileh from .wconn._filehtab ?
return fileh._headf->close();
return E(fileh._headf->close());
}
// mmap creates file mapping representing file[blk_start +blk_len) data as of wconn.at database state.
......@@ -323,7 +323,9 @@ error _FileH::close() {
// If vma != nil, created mapping is associated with that vma of user-space virtual memory manager.
pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma) {
_FileH& f = *this;
// XXX err ctx
xerr::Contextf E("conn @%s: mmap f<%s> [blk%ld +blk%ld)",
v(f.wconn->at), v(f.foid), blk_start, blk_len); // XXX +wcfs path?
// XXX (blk_start + blk_len) * blk_size overflow
error err;
......@@ -342,7 +344,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
uint8_t *mem_start, *mem_stop;
tie(mem_start, err) = mmap_ro(f._headf, start, blk_len*f.blksize);
if (err != nil)
return make_pair(nil, err);
return make_pair(nil, E(err));
mem_stop = mem_start + blk_len*f.blksize;
int64_t stop = blk_stop*f.blksize;
......@@ -350,7 +352,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
uint8_t *zmem_start = mem_start + (max(f._headfsize/*XXX -1 ?*/, start) - start);
err = mmap_zero_into_ro(zmem_start, mem_stop - zmem_start);
if (err != nil)
return make_pair(nil, err);
return make_pair(nil, E(err));
}
Mapping mmap = adoptref(new _Mapping());
......@@ -380,7 +382,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
// resync resyncs connection and its mappings onto different database view.
error _Conn::resync(zodb::Tid at) {
_Conn& wconn = *this;
// XXX err ctx
xerr::Contextf E("conn @%s: resync -> @%s", v(wconn.at), v(at)); // XXX +wcfs path?
// XXX locking
......@@ -395,15 +397,15 @@ error _Conn::resync(zodb::Tid at) {
struct stat st;
error err = f->_headf->stat(&st);
if (err != nil)
return err;
return E(err);
if ((size_t)st.st_blksize != f->blksize) // blksize must not change
return fmt::errorf("wcfs bug: blksize changed: %zd -> %ld", f->blksize, st.st_blksize);
return E(fmt::errorf("wcfs bug: blksize changed: %zd -> %ld", f->blksize, st.st_blksize));
auto headfsize = st.st_size;
if (!(f->_headfsize <= headfsize)) // head/file size ↑=
return fmt::errorf("wcfs bug: head/file size not ↑=");
return E(fmt::errorf("wcfs bug: head/file size not ↑="));
if (!(headfsize % f->blksize == 0))
return fmt::errorf("wcfs bug: head/file size %% blksize != 0");
return E(fmt::errorf("wcfs bug: head/file size %% blksize != 0"));
for (auto mmap : f->_mmaps) {
printf(" resync -> %s: unzero [%lu:%lu)", v(at), f->_headfsize/f->blksize, headfsize/f->blksize);
......@@ -415,7 +417,7 @@ error _Conn::resync(zodb::Tid at) {
if (mem_unzero_stop - mem_unzero_start > 0) {
err = mmap_into_ro(mem_unzero_start, mem_unzero_stop-mem_unzero_start, f->_headf, f->_headfsize);
if (err != nil)
return err;
return E(err);
}
}
......@@ -425,11 +427,10 @@ error _Conn::resync(zodb::Tid at) {
string ack;
tie(ack, err) = wconn._wlink->sendReq(context::background(), fmt::sprintf("watch %s @%s", v(foid), v(at)));
if (err != nil)
return err;
return E(err);
if (ack != "ok") {
// XXX unregister f from _filehtab
// XXX vvv -> errctx?
return fmt::errorf("resync @%s -> @%s: f<%s>: %s", v(wconn.at), v(at), v(foid), v(ack));
return E(fmt::errorf("%s", v(ack)));
}
}
......
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