Commit 7eed1725 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b1c009f9
...@@ -61,6 +61,8 @@ from six import reraise ...@@ -61,6 +61,8 @@ from six import reraise
# create base-layer mappings. See .open and Conn for details. # create base-layer mappings. See .open and Conn for details.
# #
# Raw files on wcfs can be accessed with ._path/._read/._stat/._open . # Raw files on wcfs can be accessed with ._path/._read/._stat/._open .
#
# XXX WCFS parallels ZODB.DB .
class WCFS(object): class WCFS(object):
# .mountpoint path to wcfs mountpoint # .mountpoint path to wcfs mountpoint
# ._fwcfs /.wcfs/zurl opened to keep the server from going away (at least cleanly) # ._fwcfs /.wcfs/zurl opened to keep the server from going away (at least cleanly)
...@@ -78,11 +80,82 @@ class WCFS(object): ...@@ -78,11 +80,82 @@ class WCFS(object):
# cache in OS pagecache of /head/bigfile/*. # cache in OS pagecache of /head/bigfile/*.
# #
# XXX wc conn <-> zconn # XXX wc conn <-> zconn
# XXX Conn parallels ZODB.Connection .
class Conn(object): class Conn(object):
# ._wc WCFS # ._wc WCFS
# .at Tid # .at Tid
# ._wlink WatchLink watch/receive pins for created mappings
# ._filemu threading.Lock
# ._filetab {} foid -> _File
def __init__(wconn):
# XXX wg.go(wconn._pinner, xxxctx)
# _File represent isolated file view under Conn.
class _File(object):
# .headf file object of head/file
# .pin {} blk -> rev that wcfs already sent us for this file
# .mmaps []_Mapping ↑blk_start mappings of this file
pass
# _Mapping represents one mapping of _File.
class _Mapping(object):
# .mem mmaped memory
# .blk_start offset of this mapping in file
pass pass
# XXX property .blk_stop = blk_start + len(mem) // blksize & assert len(mem) % blksize == 0
# _pinner receives pin messages from wcfs and adjusts wconn mappings.
@func(Conn)
def _pinner(wconn, ctx):
while 1:
req = wconn._wlink.recvReq(ctx)
if req is None:
return # XXX ok? (EOF - when wcfs closes wlink)
# we received request to pin/unpin file block. perform it
with wconn._filemu:
f = wconn._filetab.get(req.foid)
if f is None:
1/0 # XXX we are not watching the file - why wcfs sent us this update?
# XXX relock wconn -> f ?
for mmap in f.mmaps: # XXX use ↑blk_start for binary search
if not (mmap.blk_start <= req.blk && req.blk < mmap.blk_stop):
continue
# this mmap covers f[blk] - let's remmap it to @rev/f or head/f
if req.at is None:
fsfile = f.headf
else:
# TODO share @rev fd until Conn is recynced?
fsfile = wconn._wc._open("@%s/%s" % (ashex(req.at), ashex(req.foid))):
# XXX mmap
mm.mmap_into_ro(mmap.mem[(req.blk-mmap.blk_start)*blksize:][:blksize], fsfile.fileno(), req.blk*blksize)
if req.at is not None:
fsfile.close()
# update .pin
if req.at is None:
f.pin.pop(req.blk, None) # = delete(f.pin, req.blk) -- unpin to @head
else:
f.pin[req.blk] = req.at
# mmap creats file mapping representing file data as of wconn.at database state.
@func(Conn)
def mmap(wconn, foid, offset, size): # -> Mapping XXX offset, size -> blkoff, blksize ?
# XXX
# XXX Watch # XXX Watch
......
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