Commit effad023 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 93b8fbed
...@@ -82,7 +82,9 @@ class WCFS(object): ...@@ -82,7 +82,9 @@ class WCFS(object):
# maintain isolated database view while at the same time sharing most of data # maintain isolated database view while at the same time sharing most of data
# cache in OS pagecache of /head/bigfile/*. # cache in OS pagecache of /head/bigfile/*.
# #
# Use WCFS.connect(at) to create Conn.
# Use .mmap to create new Mappings. # Use .mmap to create new Mappings.
# Use .resync to resync Conn onto different database view.
# #
# Conn logically mirrors ZODB.Connection . # Conn logically mirrors ZODB.Connection .
class Conn(object): class Conn(object):
...@@ -163,7 +165,6 @@ def close(wconn): ...@@ -163,7 +165,6 @@ def close(wconn):
wconn._filetab = None wconn._filetab = None
# _pinner receives pin messages from wcfs and adjusts wconn mappings. # _pinner receives pin messages from wcfs and adjusts wconn mappings.
# #
# XXX must be running without GIL: access to wcfs mmaped memory could come from # XXX must be running without GIL: access to wcfs mmaped memory could come from
...@@ -227,7 +228,7 @@ def _pin1(wconn, req): ...@@ -227,7 +228,7 @@ def _pin1(wconn, req):
if not (mmap.blk_start <= req.blk < mmap.blk_stop): if not (mmap.blk_start <= req.blk < mmap.blk_stop):
continue # blk ∉ mmap continue # blk ∉ mmap
trace('\tremmapblk %d @%s' % (req.blk, h(req.at))) trace('\tremmapblk %d @%s' % (req.blk, (h(req.at) if req.at else "head")))
# FIXME check if virtmem did not mapped RW page into this block already # FIXME check if virtmem did not mapped RW page into this block already
mmap._remmapblk(req.blk, req.at) mmap._remmapblk(req.blk, req.at)
trace('\t-> remmaped') trace('\t-> remmaped')
...@@ -239,6 +240,25 @@ def _pin1(wconn, req): ...@@ -239,6 +240,25 @@ def _pin1(wconn, req):
f.pinned[req.blk] = req.at f.pinned[req.blk] = req.at
# resync resyncs connection onto different database view.
# XXX place=?
@func(Conn)
def resync(wconn, at):
# XXX locking
for foid in wconn._filetab:
# XXX if file was has no mappings and was not used during whole prev
# cycle - forget and stop watching it
_ = wconn._wlink.sendReq(context.background(), b"watch %s @%s" % (h(foid), h(at)))
if _ != "ok":
# XXX unregister f from _filetab
# XXX vvv -> errctx?
raise RuntimeError("resync @%s -> @%s: f<%s>: %s" % (h(wconn.at), h(at), h(foid), _))
wconn.at = at
# mmap creates file mapping representing file[blk_start +blk_len) data as of wconn.at database state. # mmap creates file mapping representing file[blk_start +blk_len) data as of wconn.at database state.
@func(Conn) @func(Conn)
def mmap(wconn, foid, blk_start, blk_len): # -> Mapping def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
...@@ -261,7 +281,7 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping ...@@ -261,7 +281,7 @@ def mmap(wconn, foid, blk_start, blk_len): # -> Mapping
if _ != "ok": if _ != "ok":
# XXX unregister f from _filetab # XXX unregister f from _filetab
# XXX vvv -> errctx? # XXX vvv -> errctx?
raise RuntimeError("mmap f<%s>[%d +%d): %s" % (h(foid), blk_start, blk_len, _)) raise RuntimeError("@%s: mmap f<%s>[%d +%d): %s" % (h(wconn.at), h(foid), blk_start, blk_len, _))
# XXX relock wconn -> f ? # XXX relock wconn -> f ?
......
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