Commit 50de9920 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fd48a55a
......@@ -198,9 +198,9 @@ class tDB:
t._wc_zheadfh = open(t.wc.mountpoint + "/.wcfs/zhead")
t._wc_zheadv = []
# when head/ ZBigFile(s) blocks were last accessed via wcfs.
# whether head/ ZBigFile(s) blocks were ever accessed via wcfs.
# this is updated only explicitly via ._blkheadaccess() .
t._blkAccessedAtHead = {} # ZBigFile -> {} blk -> head(when accessed)
t._blkaccessedViaHead = {} # ZBigFile -> set(blk)
# tracked opened tFiles & tWatches
t._files = set()
......@@ -317,11 +317,11 @@ class tDB:
# _blkheadaccess marks head/zf[blk] accessed.
def _blkheadaccess(t, zf, blk):
# XXX locking needed? or we do everything serially?
t._headOfAccess(zf)[blk] = t.head
t._blkaccessed(zf).add(blk)
# _headOfAccess returns {} describing when head/zf blocks were accessed.
def _headOfAccess(t, zf): # {} blk -> head-when-accessed
return t._blkAccessedAtHead.setdefault(zf, {})
# _blkaccessed returns set describing whether head/zf blocks were ever accessed.
def _blkaccessed(t, zf): # set(blk)
return t._blkaccessedViaHead.setdefault(zf, set())
# _path returns path for object on wcfs.
# - str: wcfs root + obj;
......@@ -892,8 +892,8 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
at_from = '(%s ->) ' % t.hat(at_prev)
print('\nC: setup watch f<%s> %s%s' % (h(zf._p_oid), at_from, t.hat(at)))
headOfAccess = t._headOfAccess(zf) # XXX we only use keys
lastRevOf = lambda blk: t._blkRevAt(zf, blk, t.head)
accessed = t._blkaccessed(zf)
lastRevOf = lambda blk: t._blkRevAt(zf, blk, t.head)
pin_prev = {}
if at_prev is not None:
......@@ -917,13 +917,13 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
# blk ∈ pin -> blk is tracked; has rev > at
# (see criteria in _pinnedAt)
assert blk in headOfAccess
assert blk in accessed
assert at < lastRevOf(blk)
# blk ∈ pin_prev, blk ∉ pin -> unpin to head
elif blk in pin_prev and blk not in pin:
# blk ∈ pin_prev -> blk is tracked; has rev > at_prev
assert blk in headOfAccess
assert blk in accessed
assert at_prev < lastRevOf(blk)
# blk ∉ pin -> last blk revision is ≤ at
......@@ -934,7 +934,7 @@ def watch(twlink, zf, at, pinok=None): # -> tWatch
# blk ∈ pin_prev, blk ∈ pin -> if rev different: use pin
elif blk in pin_prev and blk in pin:
# blk ∈ pin_prev, pin -> blk is tracked; has rev > at_prev, at
assert blk in headOfAccess
assert blk in accessed
assert at_prev < lastRevOf(blk)
assert at < lastRevOf(blk)
......@@ -1159,7 +1159,7 @@ def _pinnedAt(t, zf, at): # -> pin = {} blk -> rev
else:
pinrev = blkhistoryat[-1]
assert pinrev <= at
if blk in t._headOfAccess(zf):
if blk in t._blkaccessed(zf):
pin[blk] = pinrev
return pin
......
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