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

.

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