Commit 51eed733 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cfb6df9a
...@@ -89,7 +89,14 @@ class Conn(object): ...@@ -89,7 +89,14 @@ class Conn(object):
# ._filemu threading.Lock # ._filemu threading.Lock
# ._filetab {} foid -> _File # ._filetab {} foid -> _File
def __init__(wconn): def __init__(wconn, wc, at):
# XXX support !isolated mode
wconn._wc = wc
wconn.at = at
wconn._wlink = WatchLink(wc)
wconn._filemu = threading.Lock()
wconn._filetab = {}
# XXX wg.go(wconn._pinner, xxxctx) # XXX wg.go(wconn._pinner, xxxctx)
# _File represent isolated file view under Conn. # _File represent isolated file view under Conn.
...@@ -112,6 +119,11 @@ class _Mapping(object): ...@@ -112,6 +119,11 @@ class _Mapping(object):
# XXX property .blk_stop = blk_start + len(mem) // blksize & assert len(mem) % blksize == 0 # XXX property .blk_stop = blk_start + len(mem) // blksize & assert len(mem) % blksize == 0
# connect creates new Conn viewing WCFS state as of @at.
@func(WCFS)
def connect(wc, at): # -> Conn
return Conn(wc, at)
# _pinner receives pin messages from wcfs and adjusts wconn mappings. # _pinner receives pin messages from wcfs and adjusts wconn mappings.
@func(Conn) @func(Conn)
def _pinner(wconn, ctx): def _pinner(wconn, ctx):
...@@ -134,7 +146,7 @@ def _pinner(wconn, ctx): ...@@ -134,7 +146,7 @@ def _pinner(wconn, ctx):
continue continue
# 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.pin(req.blk, req.at) mmap.mmapblk(req.blk, req.at)
# update f.pinned # update f.pinned
if req.at is None: if req.at is None:
...@@ -179,14 +191,30 @@ def mmap(wconn, foid, offset, size): # -> Mapping XXX offset, size -> blko ...@@ -179,14 +191,30 @@ def mmap(wconn, foid, offset, size): # -> Mapping XXX offset, size -> blko
for blk, rev in f.pin.items(): # XXX keep f.pin ↑blk and use binary search? for blk, rev in f.pin.items(): # XXX keep f.pin ↑blk and use binary search?
if not (blk_start <= blk && blk < blk_stop): if not (blk_start <= blk && blk < blk_stop):
continue # blk out of this mapping continue # blk out of this mapping
mmap.pin(blk, rev) mmap.mmapblk(blk, rev)
f.mmaps.append(mmap) # XXX keep f.mmaps ↑blk_start f.mmaps.append(mmap) # XXX keep f.mmaps ↑blk_start
return mmap return mmap
# remmap_blk remmapfs file[blk] in its place again.
# virtmem calls this to remmap a block after RW dirty page was e.g. discarded.
@func(_Mapping)
def remmap_blk(mmap, blk):
# XXX locking
assert (mmap.blk_start <= blk < mmap.blk_stop)
blkrev = mmap.pinned.get(blk, None) # rev | @head
mmap.mmapblk(blk, blkrev)
# unmap is removes mapping memory from address space.
# virtmem calls this when VMA is unmapped.
@func(_Mapping):
def unmap(mmap):
# XXX locking
mm.unmap(mmap.mem)
mmap.mem = None
# XXX Watch
# WatchLink represents /head/watch link opened on wcfs. # WatchLink represents /head/watch link opened on wcfs.
# #
...@@ -232,7 +260,6 @@ class WatchLink(object): ...@@ -232,7 +260,6 @@ class WatchLink(object):
# XXX back -> tWatchLink ? # XXX back -> tWatchLink ?
wlink._watching = {} # {} foid -> tWatch wlink._watching = {} # {} foid -> tWatch
# ---- WatchLink message IO ----
def _closeTX(wlink): def _closeTX(wlink):
if wlink._txclosed: if wlink._txclosed:
......
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