Commit deb52f9d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent dbaf1db9
......@@ -445,6 +445,8 @@ error _Conn::resync(zodb::Tid at) {
error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
// XXX err context? blk #<blk> @<at>
_Mapping *mmap = this;
xerr::Contextf E("conn @%s: f<%s>: remmapblk #%ld @%s",
v(mmap->fileh->wconn->at), v(mmap->fileh->foid), blk, v(at)); // XXX +wcfs path?
ASSERT(mmap->blk_start <= blk && blk < mmap->blk_stop());
FileH f = mmap->fileh;
......@@ -461,7 +463,7 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
tie(fsfile, err) = f->wconn->_wc->_open(
fmt::sprintf("@%s/bigfile/%s", v(at), v(f->foid)));
if (err != nil)
return err;
return E(err);
fclose = true;
}
defer([&]() {
......@@ -472,22 +474,22 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
struct stat st;
err = fsfile->stat(&st);
if (err != nil)
return err;
return E(err);
if ((size_t)st.st_blksize != f->blksize)
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));
// block is beyond file size - mmap with zeros - else access to memory
// after file.size will raise SIGBUS. (assumes head/f size ↑=)
if ((blk+1)*f->blksize > (size_t)st.st_size) {
err = mmap_zero_into_ro(blkmem, 1*f->blksize);
if (err != nil)
return err;
return E(err);
}
// block is inside file - mmap file data
else {
err = mmap_into_ro(blkmem, 1*f->blksize, fsfile, blk*f->blksize);
if (err != nil)
return err;
return E(err);
}
return nil;
......
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