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
4f8b5511
Commit
4f8b5511
authored
Dec 03, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
18ad4bdd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
17 deletions
+35
-17
wcfs/internal/wcfs.h
wcfs/internal/wcfs.h
+3
-3
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+32
-14
No files found.
wcfs/internal/wcfs.h
View file @
4f8b5511
...
...
@@ -33,8 +33,8 @@ using std::pair;
#include "wcfs_misc.h"
struct
Conn
;
struct
_WatchLink
;
class
_
Conn
;
class
_WatchLink
;
// WCFS represents filesystem-level connection to wcfs server.
...
...
@@ -42,7 +42,7 @@ struct _WatchLink;
struct
WCFS
{
string
mountpoint
;
tuple
<
Conn
*
,
error
>
connect
(
zodb
::
Tid
at
);
tuple
<
refptr
<
_Conn
>
,
error
>
connect
(
zodb
::
Tid
at
);
string
_path
(
const
string
&
obj
);
tuple
<
os
::
File
,
error
>
_open
(
const
string
&
path
,
int
flags
=
O_RDONLY
);
pair
<
refptr
<
_WatchLink
>
,
error
>
_openwatch
();
...
...
wcfs/internal/wcfs_virtmem.cpp
View file @
4f8b5511
...
...
@@ -50,7 +50,6 @@ static string h(uint64_t v); // v -> 016x hex representation
static
error
mmap_zero_into_ro
(
void
*
addr
,
size_t
size
);
static
error
mmap_into_ro
(
void
*
addr
,
size_t
size
,
const
os
::
File
&
f
,
off_t
offset
);
struct
Conn
;
struct
_File
;
struct
_Mapping
;
struct
PinReq
;
...
...
@@ -58,15 +57,34 @@ struct PinReq;
// Conn represents logical connection that provides view of data on wcfs
// filesystem as of particular database state.
//
// XXX doc
struct
Conn
{
// It uses /head/bigfile/* and notifications received from /head/watch to
// maintain isolated database view while at the same time sharing most of data
// cache in OS pagecache of /head/bigfile/*.
//
// Use WCFS.connect(at) to create Conn.
// Use .mmap to create new Mappings.
// Use .resync to resync Conn onto different database view.
//
// Conn logically mirrors ZODB.Connection .
typedef
refptr
<
class
_Conn
>
Conn
;
class
_Conn
{
WCFS
*
_wc
;
zodb
::
Tid
at
;
WatchLink
_wlink
;
WatchLink
_wlink
;
// watch/receive pins for created mappings
sync
::
Mutex
_filemu
;
dict
<
zodb
::
Oid
,
_File
*>
_filetab
;
// {} foid -> _file
// XXX ._pinWG, ._pinCancel
// don't new - create via WCFS.connect
private:
_Conn
();
~
_Conn
();
friend
tuple
<
Conn
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
);
public:
void
decref
();
public:
error
close
();
error
resync
(
zodb
::
Tid
at
);
...
...
@@ -79,9 +97,10 @@ private:
// _File represent isolated file view under Conn.
//
// XXX doc XXX naming -> _FileView ?
// XXX -> refptr ?
struct
_File
{
Conn
*
wconn
;
zodb
::
Oid
foid
;
//
hex of
ZBigFile root object ID
Conn
wconn
;
zodb
::
Oid
foid
;
// ZBigFile root object ID
size_t
blksize
;
// block size of this file XXX -> off_t ?
os
::
File
headf
;
// file object of head/file
off_t
headfsize
;
// head/file size is known to be at least headfsize (size ↑=)
...
...
@@ -91,6 +110,7 @@ struct _File {
};
// _Mapping represents one mapping of _File.
// XXX -> refptr ?
struct
_Mapping
{
_File
*
file
;
int
blk_start
;
// offset of this mapping in file
...
...
@@ -110,29 +130,27 @@ struct _Mapping {
// connect creates new Conn viewing WCFS state as of @at.
tuple
<
Conn
*
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
)
{
tuple
<
Conn
,
error
>
WCFS
::
connect
(
zodb
::
Tid
at
)
{
WCFS
*
wc
=
this
;
// XXX err ctx
// TODO support !isolated mode
WatchLink
wlink
;
error
err
;
tie
(
wlink
,
err
)
=
wc
->
_openwatch
();
if
(
err
!=
nil
)
return
make_tuple
(
(
Conn
*
)
NULL
,
err
);
return
make_tuple
(
nil
,
err
);
Conn
*
wconn
=
new
Conn
();
// TODO support !isolated mode
Conn
wconn
=
adoptref
(
new
_Conn
());
wconn
->
_wc
=
wc
;
wconn
->
at
=
at
;
wconn
->
_wlink
=
wlink
;
// XXX reenable
#if 0
pinCtx
,
wconn
.
_pinCancel
=
context
.
with_cancel
(
context
.
background
())
wconn
.
_pinWG
=
sync
.
WorkGroup
(
pinCtx
)
wconn
.
_pinWG
.
go
(
wconn
.
_pinner
)
#endif
return
make_tuple
(
wconn
,
nil
);
}
...
...
@@ -163,7 +181,7 @@ error Conn::close() { // XXX error -> void?
for
(
auto
_
:
wconn
.
_filetab
)
{
auto
f
=
_
.
second
;
f
->
headf
->
close
();
// XXX err
//f->headf = None
f
->
headf
=
nil
;
// XXX stop watching f
}
...
...
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