Commit 02fa982f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d5011053
......@@ -81,7 +81,7 @@ natural to also use "2" here.
# FIXME ^^^ doc is horrible - add top-level up->down overview.
from wendelin.bigfile import BigFile, WRITEOUT_STORE, WRITEOUT_MARKSTORED
from wendelin import wcfs # XXX -> wendelin.bigfile.wcfs ?
from wendelin import wcfs
from wendelin.lib.mem import bzero, memcpy
from wendelin.lib.zodb import deactivate_btree
......
......@@ -96,6 +96,7 @@ class Conn(object):
class _File(object):
# .wconn Conn
# .foid hex of ZBigFile root object ID
# .blksize block size of this file
# .headf file object of head/file
# .pinned {} blk -> rev that wcfs already sent us for this file
# .mmaps []_Mapping ↑blk_start mappings of this file
......@@ -169,7 +170,7 @@ def _pinner(wconn, ctx):
# mmap creates file mapping representing file data as of wconn.at database state.
@func(Conn)
def mmap(wconn, foid, offset, size): # -> Mapping XXX offset, size -> blkoff, blksize ?
def mmap(wconn, foid, blk, blklen): # -> Mapping
with wconn._filemu:
f = wconn._filetab.get(foid)
if f is None:
......@@ -177,6 +178,7 @@ def mmap(wconn, foid, offset, size): # -> Mapping XXX offset, size -> blko
f.wconn = wconn
f.foid = foid
f.headf = wconn._wc._open("head/bigfile/%s" % (ashex(foid),), "rb")
f.blksize = os.fstat(f.headf.fileno()).st_blksize
f.pinned = {}
f.mmaps = []
wconn._filetab[foid] = f
......@@ -184,7 +186,7 @@ def mmap(wconn, foid, offset, size): # -> Mapping XXX offset, size -> blko
# XXX relock wconn -> f ?
# create memory with head/f mapping and applied pins
mem = mm.map_ro(f.headf.fileno(), offset, size)
mem = mm.map_ro(f.headf.fileno(), blk*f.blksize, blklen*f.blksize)
mmap = _Mapping(f, blk_start, mem)
for blk, rev in f.pinned.items(): # XXX keep f.pinned ↑blk and use binary search?
if not (blk_start <= blk < blk_stop):
......@@ -210,6 +212,7 @@ def _remmapblk(mmap, blk, at):
# TODO share @rev fd until wconn is resynced?
fsfile = f.wconn._wc._open("@%s/bigfile/%s" % (ashex(at), ashex(f.foid)), "rb")
defer(fsfile.close)
assert os.fstat(fsfile.fileno()).st_blksize == f.blksize # FIXME assert
mm.map_into_ro(mmap.mem[(blk-mmap.blk_start)*blksize:][:blksize], fsfile.fileno(), blk*blksize)
......
......@@ -2190,8 +2190,8 @@ func (f *BigFile) GetAttr(out *fuse.Attr, _ nodefs.File, _ *fuse.Context) fuse.S
func (f *BigFile) getattr(out *fuse.Attr) {
out.Mode = fuse.S_IFREG | 0444
out.Size = uint64(f.size)
out.Blksize = uint32(f.blksize) // XXX 64 -> 32
// .Blocks
// .Blksize
mtime := f.rev.Time().Time
out.SetTimes(/*atime=*/nil, /*mtime=*/&mtime, /*ctime=*/&mtime)
......
......@@ -1074,6 +1074,10 @@ def test_wcfs_basic():
t.wc._stat("head/bigfile/%s" % h(t.nonzfile._p_oid))
assert exc.value.errno == EINVAL
# make sure that wcfs reports zf.blksize as preffered block size for IO
_ = t.wc._stat(zf)
assert _.st_blksize == zf.blksize
# >>> file initially empty
f = t.open(zf)
f.assertCache([])
......
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