Commit 3470a1d5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e6ce8953
...@@ -102,13 +102,13 @@ class Conn(object): ...@@ -102,13 +102,13 @@ class Conn(object):
# _File represent isolated file view under Conn. # _File represent isolated file view under Conn.
class _File(object): class _File(object):
# .wconn Conn # .wconn Conn
# .foid hex of ZBigFile root object ID # .foid hex of ZBigFile root object ID
# .size size of this file # .blksize block size of this file
# .blksize block size of this file # .headf file object of head/file
# .headf file object of head/file # .headfsize head/file size is known to be at least headfsize (size ↑=)
# .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
pass pass
...@@ -250,7 +250,7 @@ def resync(wconn, at): ...@@ -250,7 +250,7 @@ def resync(wconn, at):
# XXX locking # XXX locking
for foid in wconn._filetab: for foid in wconn._filetab:
# XXX if file was has no mappings and was not used during whole prev # XXX if file has no mappings and was not used during whole prev
# cycle - forget and stop watching it # cycle - forget and stop watching it
_ = wconn._wlink.sendReq(context.background(), b"watch %s @%s" % (h(foid), h(at))) _ = wconn._wlink.sendReq(context.background(), b"watch %s @%s" % (h(foid), h(at)))
if _ != "ok": if _ != "ok":
...@@ -258,6 +258,9 @@ def resync(wconn, at): ...@@ -258,6 +258,9 @@ def resync(wconn, at):
# XXX vvv -> errctx? # XXX vvv -> errctx?
raise RuntimeError("resync @%s -> @%s: f<%s>: %s" % (h(wconn.at), h(at), h(foid), _)) raise RuntimeError("resync @%s -> @%s: f<%s>: %s" % (h(wconn.at), h(at), h(foid), _))
# XXX update f.headfsize
# XXX remmap appended data after old f.headfsize
wconn.at = at wconn.at = at
...@@ -277,8 +280,8 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping ...@@ -277,8 +280,8 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
f.mmaps = [] f.mmaps = []
_ = os.fstat(f.headf.fileno()) _ = os.fstat(f.headf.fileno())
f.size = _.st_size
f.blksize = _.st_blksize f.blksize = _.st_blksize
f.headfsize = _.st_size
wconn._filetab[foid] = f wconn._filetab[foid] = f
...@@ -295,7 +298,7 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping ...@@ -295,7 +298,7 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
# mmap-in zeros after f.size (else access to memory after file.size will raise SIGBUS) # mmap-in zeros after f.size (else access to memory after file.size will raise SIGBUS)
start = blk_start*f.blksize start = blk_start*f.blksize
mem = mm.map_ro(f.headf.fileno(), start, blk_len*f.blksize) mem = mm.map_ro(f.headf.fileno(), start, blk_len*f.blksize)
zmemtail = mem[max(f.size, start) - start:] zmemtail = mem[max(f.headfsize, start) - start:]
if len(zmemtail) != 0: if len(zmemtail) != 0:
mm.map_zero_into_ro(zmemtail) mm.map_zero_into_ro(zmemtail)
mmap = _Mapping() mmap = _Mapping()
......
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