Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
7eed1725
Commit
7eed1725
authored
Jul 16, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b1c009f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
2 deletions
+75
-2
wcfs/__init__.py
wcfs/__init__.py
+75
-2
No files found.
wcfs/__init__.py
View file @
7eed1725
...
...
@@ -61,6 +61,8 @@ from six import reraise
# create base-layer mappings. See .open and Conn for details.
#
# Raw files on wcfs can be accessed with ._path/._read/._stat/._open .
#
# XXX WCFS parallels ZODB.DB .
class
WCFS
(
object
):
# .mountpoint path to wcfs mountpoint
# ._fwcfs /.wcfs/zurl opened to keep the server from going away (at least cleanly)
...
...
@@ -78,12 +80,83 @@ class WCFS(object):
# cache in OS pagecache of /head/bigfile/*.
#
# XXX wc conn <-> zconn
# XXX Conn parallels ZODB.Connection .
class
Conn
(
object
):
# ._wc WCFS
# .at Tid
# ._wc WCFS
# .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
# 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
# WatchLink represents /head/watch link opened on wcfs.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment