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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
821d3909
Commit
821d3909
authored
Jul 16, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
cd8d9105
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
17 deletions
+41
-17
wcfs/__init__.py
wcfs/__init__.py
+41
-17
No files found.
wcfs/__init__.py
View file @
821d3909
...
...
@@ -94,16 +94,19 @@ class Conn(object):
# _File represent isolated file view under Conn.
class
_File
(
object
):
# .wconn Conn
# .foid hex of ZBigFile root object ID
# .headf file object of head/file
# .pin
{} blk -> rev that wcfs already sent us for this file
# .pin
ned
{} 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
# .
file _File
# .blk_start offset of this mapping in file
# .mem mmaped memory
pass
# XXX property .blk_stop = blk_start + len(mem) // blksize & assert len(mem) % blksize == 0
...
...
@@ -130,31 +133,52 @@ def _pinner(wconn, ctx):
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
# FIXME check if virtmem did not mapped RW page into this block already
mmap
.
pin
(
req
.
blk
,
req
.
at
)
# update .pinned
if
req
.
at
is
None
:
fsfile
=
f
.
headf
f
.
pinned
.
pop
(
req
.
blk
,
None
)
# = delete(f.pinned, req.blk) -- unpin to @head
else
:
# TODO share @rev fd until Conn is recynced?
fsfile
=
wconn
.
_wc
.
_open
(
"@%s/%s"
%
(
ashex
(
req
.
at
),
ashex
(
req
.
foid
))):
# FIXME check if virtmem did not mapped RW page into this block already
mm
.
mmap_into_ro
(
mmap
.
mem
[(
req
.
blk
-
mmap
.
blk_start
)
*
blksize
:][:
blksize
],
fsfile
.
fileno
(),
req
.
blk
*
blksize
)
f
.
pinned
[
req
.
blk
]
=
req
.
at
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
# pin remmaps mapping memory for [blk] to be viewing database as of @at state.
#
# at=None means unpin to head/ .
# NOTE this does not check wrt virtmem already mapped blk as RW XXX ok?
@
func
(
_Mapping
)
def
pin
(
mmap
,
blk
,
at
):
f
=
mmap
.
file
if
at
is
None
:
fsfile
=
f
.
headf
else
:
f
.
pin
[
req
.
blk
]
=
req
.
at
# TODO share @rev fd until wconn is recynced?
fsfile
=
f
.
wconn
.
_wc
.
_open
(
"@%s/%s"
%
(
ashex
(
at
),
ashex
(
f
.
foid
)),
"rb"
)
defer
(
fsfile
.
close
)
mm
.
mmap_into_ro
(
mmap
.
mem
[(
blk
-
mmap
.
blk_start
)
*
blksize
:][:
blksize
],
fsfile
.
fileno
(),
blk
*
blksize
)
# 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
with
wconn
.
_filemu
:
f
=
wconn
.
_filetab
.
get
(
foid
)
if
f
is
None
:
headf
=
wconn
.
_wc
.
_open
(
"head/%s"
%
(
ashex
(
foid
),),
"rb"
)
f
=
File
(
headf
)
wconn
.
_filetab
[
foid
]
=
f
# XXX relock wconn -> f ?
# create memory with head/f mapping and applied pins
mem
=
mm
.
mmap_ro
(
f
.
headf
.
fileno
(),
offset
,
size
)
for
blk
,
rev
in
f
.
pin
.
items
():
# XXX keep f.pin ↑blk and use binary search?
if
not
(
blk_start
<=
blk
&&
blk
<
blk_stop
):
continue
# blk out of this mapping
mm
.
mmap_into_ro
(
mem
[(
blk
-
blk_start
)
*
blksize
:][:
blksize
],
# XXX Watch
...
...
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