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

.

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