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
83ef7688
Commit
83ef7688
authored
Feb 13, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e48a8eaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
28 deletions
+25
-28
wcfs/client/_wcfs.pyx
wcfs/client/_wcfs.pyx
+0
-2
wcfs/client/wcfs.cpp
wcfs/client/wcfs.cpp
+10
-11
wcfs/client/wcfs.h
wcfs/client/wcfs.h
+15
-15
No files found.
wcfs/client/_wcfs.pyx
View file @
83ef7688
...
...
@@ -263,8 +263,6 @@ def _tpywlinkwrite(PyWatchLink pywlink, bytes pypkt):
# pyerr converts error into python error.
cdef
object
pyerr
(
error
err
):
if
err
==
nil
:
return
None
return
pyerror
.
from_error
(
err
)
...
...
wcfs/client/wcfs.cpp
View file @
83ef7688
...
...
@@ -79,7 +79,7 @@ static error mmap_into_ro(void *addr, size_t size, os::File f, off_t offset);
// connect creates new Conn viewing WCFS state as of @at.
pair
<
Conn
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
)
{
WCFS
*
wc
=
this
;
xerr
::
Contextf
E
(
"
connect @%s"
,
v
(
at
));
// XXX +wc path?
xerr
::
Contextf
E
(
"
wcfs %s: connect @%s"
,
v
(
wc
->
mountpoint
),
v
(
at
));
// TODO support !isolated mode
...
...
@@ -112,7 +112,6 @@ static global<error> errConnClosed = errors::New("connection closed");
// opened fileh and mappings becomes invalid to use except close and unmap.
error
_Conn
::
close
()
{
_Conn
&
wconn
=
*
this
;
//xerr::Contextf E("close conn @%s", v(wconn.at));
xerr
::
Contextf
E
(
"wcfs %s: close conn @%s"
,
v
(
wconn
.
_wc
->
mountpoint
),
v
(
wconn
.
at
));
// XXX + conn # e.g. from wconn._wlink.id? or wlink.close should include its id itself?
...
...
@@ -296,7 +295,7 @@ error _Conn::__pin1(PinReq *req) {
pair
<
FileH
,
error
>
_Conn
::
open
(
zodb
::
Oid
foid
)
{
_Conn
&
wconn
=
*
this
;
error
err
;
xerr
::
Contextf
E
(
"
conn @%s: open f<%s>"
,
v
(
wconn
.
at
),
v
(
foid
));
xerr
::
Contextf
E
(
"
wcfs %s: conn @%s: open f<%s>"
,
v
(
wconn
.
_wc
->
mountpoint
)
,
v
(
wconn
.
at
),
v
(
foid
));
wconn
.
_filehmu
.
lock
();
defer
([
&
]()
{
...
...
@@ -354,7 +353,7 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
error
_FileH
::
close
()
{
_FileH
&
fileh
=
*
this
;
Conn
wconn
=
fileh
.
wconn
;
xerr
::
Contextf
E
(
"
conn @%s: close f<%s>"
,
v
(
wconn
->
at
),
v
(
fileh
.
foid
));
// XXX + wcfs path?
xerr
::
Contextf
E
(
"
wcfs %s: conn @%s: close f<%s>"
,
v
(
wconn
->
_wc
->
mountpoint
),
v
(
wconn
->
at
),
v
(
fileh
.
foid
));
// remove fileh from wconn._filehtab
// fileh.close can be called several times and after first call another
...
...
@@ -373,8 +372,8 @@ error _FileH::close() {
// If vma != nil, created mapping is associated with that vma of user-space virtual memory manager.
pair
<
Mapping
,
error
>
_FileH
::
mmap
(
int64_t
blk_start
,
int64_t
blk_len
,
VMA
*
vma
)
{
_FileH
&
f
=
*
this
;
xerr
::
Contextf
E
(
"conn @%s: mmap f<%s> [blk%ld +blk%ld)"
,
v
(
f
.
wconn
->
at
),
v
(
f
.
foid
),
blk_start
,
blk_len
);
// XXX +wcfs path?
xerr
::
Contextf
E
(
"
wcfs %s:
conn @%s: mmap f<%s> [blk%ld +blk%ld)"
,
v
(
f
.
wconn
->
_wc
->
mountpoint
),
v
(
f
.
wconn
->
at
),
v
(
f
.
foid
),
blk_start
,
blk_len
);
// XXX (blk_start + blk_len) * blk_size overflow
error
err
;
...
...
@@ -432,7 +431,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
// resync resyncs connection and its mappings onto different database view.
error
_Conn
::
resync
(
zodb
::
Tid
at
)
{
_Conn
&
wconn
=
*
this
;
xerr
::
Contextf
E
(
"
conn @%s: resync -> @%s"
,
v
(
wconn
.
at
),
v
(
at
));
// XXX +wcfs path?
xerr
::
Contextf
E
(
"
wcfs %s: conn @%s: resync -> @%s"
,
v
(
wconn
.
_wc
->
mountpoint
),
v
(
wconn
.
at
),
v
(
at
));
// XXX locking
error
err
;
...
...
@@ -500,13 +499,13 @@ error _Conn::resync(zodb::Tid at) {
// at=TidHead means unpin to head/ .
// NOTE this does not check whether virtmem already mapped blk as RW.
error
_Mapping
::
_remmapblk
(
int64_t
blk
,
zodb
::
Tid
at
)
{
// XXX err context? blk #<blk> @<at>
_Mapping
*
mmap
=
this
;
xerr
::
Contextf
E
(
"conn @%s: f<%s>: remmapblk #%ld @%s"
,
v
(
mmap
->
fileh
->
wconn
->
at
),
v
(
mmap
->
fileh
->
foid
),
blk
,
v
(
at
));
// XXX +wcfs path?
FileH
f
=
mmap
->
fileh
;
xerr
::
Contextf
E
(
"wcfs %s: conn @%s: f<%s>: remmapblk #%ld @%s"
,
v
(
f
->
wconn
->
_wc
->
mountpoint
),
v
(
f
->
wconn
->
at
),
v
(
f
->
foid
),
blk
,
v
(
at
));
ASSERT
(
mmap
->
blk_start
<=
blk
&&
blk
<
mmap
->
blk_stop
());
FileH
f
=
mmap
->
fileh
;
error
err
;
uint8_t
*
blkmem
=
mmap
->
mem_start
+
(
blk
-
mmap
->
blk_start
)
*
f
->
blksize
;
...
...
wcfs/client/wcfs.h
View file @
83ef7688
...
...
@@ -42,14 +42,14 @@
// ─── ───── ────────────────────────── ───── /head/bigfile/X
//
// where @revR mmaps are being dynamically added/removed by this client package
// to maintain X@at data view according to WCFS i
nvalid
ation protocol(*).
// to maintain X@at data view according to WCFS i
sol
ation protocol(*).
//
//
// Integration with wendelin.core virtmem layer
//
// This client package can be used standalone, but additionally provides
// integration with wendelin.core userspace virtual memory manager: when a
// Mapping is created it can be associated as serving base layer for a
// Mapping is created
,
it can be associated as serving base layer for a
// particular virtmem VMA via FileH.mmap(vma=...). In that case, since virtmem
// itself adds another layer of dirty pages over read-only base provided by
// Mapping(+)
...
...
@@ -67,7 +67,7 @@
// ─── ───── ────────────────────────── ───── /head/bigfile/X
//
// the Mapping will interact with virtmem layer to coordinate
//
mapping memory updates
.
//
updates to mapping virtual memory
.
//
//
// API overview
...
...
@@ -99,18 +99,9 @@
#include <golang/libgolang.h>
#include <golang/cxx.h>
#include <golang/sync.h>
using
namespace
golang
;
using
cxx
::
dict
;
using
cxx
::
set
;
#include <string>
using
std
::
string
;
#include <tuple>
using
std
::
tuple
;
#include <utility>
using
std
::
pair
;
#include "wcfs_misc.h"
#include <wendelin/bug.h>
...
...
@@ -124,6 +115,13 @@ struct VMA;
// wcfs::
namespace
wcfs
{
using
namespace
golang
;
using
cxx
::
dict
;
using
cxx
::
set
;
using
std
::
tuple
;
using
std
::
pair
;
typedef
refptr
<
struct
_Conn
>
Conn
;
typedef
refptr
<
struct
_Mapping
>
Mapping
;
typedef
refptr
<
struct
_FileH
>
FileH
;
...
...
@@ -176,8 +174,8 @@ struct _Conn : object {
sync
::
Mutex
_filehmu
;
dict
<
zodb
::
Oid
,
FileH
>
_filehtab
;
// {} foid -> fileh
sync
::
WorkGroup
_pinWG
;
func
<
void
()
>
_pinCancel
;
sync
::
WorkGroup
_pinWG
;
// pin/unpin messages from wcfs are served by _pinner
func
<
void
()
>
_pinCancel
;
// spawned under _pinWG.
// don't new - create via WCFS.connect
private:
...
...
@@ -203,7 +201,7 @@ private:
//
// The file view is maintained to be as of @Conn.at database state even in the
// presence of simultaneous database changes. The file view uses
// /head/<file>/data primarily and @revX/<file>/data pin overrides.
// /head/<file>/data primarily and
/
@revX/<file>/data pin overrides.
//
// Use .mmap to map file view into memory.
typedef
refptr
<
struct
_FileH
>
FileH
;
...
...
@@ -231,6 +229,8 @@ public:
};
// Mapping represents one memory mapping of FileH.
//
// The mapped memory is [.mem_start, .mem_stop)
typedef
refptr
<
struct
_Mapping
>
Mapping
;
struct
_Mapping
:
object
{
FileH
fileh
;
...
...
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