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
a1a06fea
Commit
a1a06fea
authored
Feb 14, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3310888d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
wcfs/client/wcfs.cpp
wcfs/client/wcfs.cpp
+14
-4
wcfs/client/wcfs.h
wcfs/client/wcfs.h
+11
-2
No files found.
wcfs/client/wcfs.cpp
View file @
a1a06fea
...
@@ -45,6 +45,9 @@
...
@@ -45,6 +45,9 @@
// Mapping FileH
// Mapping FileH
//
//
// XXX locking -> explain atMu + slaves and refer to "Locking" in wcfs.go
#include "wcfs_misc.h"
#include "wcfs_misc.h"
#include "wcfs.h"
#include "wcfs.h"
#include "wcfs_watchlink.h"
#include "wcfs_watchlink.h"
...
@@ -297,6 +300,9 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
...
@@ -297,6 +300,9 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
error
err
;
error
err
;
xerr
::
Contextf
E
(
"wcfs %s: conn @%s: open f<%s>"
,
v
(
wconn
.
_wc
->
mountpoint
),
v
(
wconn
.
at
),
v
(
foid
));
xerr
::
Contextf
E
(
"wcfs %s: conn @%s: open f<%s>"
,
v
(
wconn
.
_wc
->
mountpoint
),
v
(
wconn
.
at
),
v
(
foid
));
// XXX wconn._atMu.RLock()
// XXX defer wconn._atMu.RUnlock()
wconn
.
_filehmu
.
lock
();
wconn
.
_filehmu
.
lock
();
defer
([
&
]()
{
defer
([
&
]()
{
wconn
.
_filehmu
.
unlock
();
wconn
.
_filehmu
.
unlock
();
...
@@ -401,6 +407,9 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
...
@@ -401,6 +407,9 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
panic
(
"(blk_start + blk_len)*f.blksize overflow int64"
);
panic
(
"(blk_start + blk_len)*f.blksize overflow int64"
);
int64_t
start
=
blk_start
*
f
.
blksize
;
int64_t
start
=
blk_start
*
f
.
blksize
;
// XXX wconn.atMu.RLock()
// XXX defer wconn.atMu.RUnlock()
// XXX f locking?
// XXX f locking?
// create memory with head/f mapping and applied pins
// create memory with head/f mapping and applied pins
...
@@ -459,6 +468,9 @@ error _Conn::resync(zodb::Tid at) {
...
@@ -459,6 +468,9 @@ error _Conn::resync(zodb::Tid at) {
xerr
::
Contextf
E
(
"wcfs %s: conn @%s: resync -> @%s"
,
v
(
wconn
.
_wc
->
mountpoint
),
v
(
wconn
.
at
),
v
(
at
));
xerr
::
Contextf
E
(
"wcfs %s: conn @%s: resync -> @%s"
,
v
(
wconn
.
_wc
->
mountpoint
),
v
(
wconn
.
at
),
v
(
at
));
// XXX locking
// XXX locking
// wconn.atMu.Lock()
// defer wconn.atMu.Unlock()
error
err
;
error
err
;
wconn
.
_downMu
.
lock
();
wconn
.
_downMu
.
lock
();
...
@@ -517,7 +529,6 @@ error _Conn::resync(zodb::Tid at) {
...
@@ -517,7 +529,6 @@ error _Conn::resync(zodb::Tid at) {
if
(
err
!=
nil
)
if
(
err
!=
nil
)
return
E
(
err
);
return
E
(
err
);
if
(
ack
!=
"ok"
)
{
if
(
ack
!=
"ok"
)
{
// XXX unregister f from _filehtab ?
return
E
(
fmt
::
errorf
(
"%s"
,
v
(
ack
)));
return
E
(
fmt
::
errorf
(
"%s"
,
v
(
ack
)));
}
}
}
}
...
@@ -617,10 +628,9 @@ error _Mapping::unmap() {
...
@@ -617,10 +628,9 @@ error _Mapping::unmap() {
v
(
f
->
wconn
->
_wc
->
mountpoint
),
v
(
f
->
wconn
->
at
),
v
(
f
->
foid
));
v
(
f
->
wconn
->
_wc
->
mountpoint
),
v
(
f
->
wconn
->
at
),
v
(
f
->
foid
));
// XXX locking
// XXX locking
// XXX make sure mmap cannot be XXX
error
err
=
mm
::
unmap
(
mmap
->
mem_start
,
mmap
->
mem_stop
-
mmap
->
mem_start
);
error
err
=
mm
::
unmap
(
mmap
->
mem_start
,
mmap
->
mem_stop
-
mmap
->
mem_start
);
if
(
err
!=
nil
)
return
E
(
err
);
mmap
->
mem_start
=
NULL
;
mmap
->
mem_start
=
NULL
;
mmap
->
mem_stop
=
NULL
;
mmap
->
mem_stop
=
NULL
;
// XXX clear other fields?
// XXX clear other fields?
...
@@ -632,7 +642,7 @@ error _Mapping::unmap() {
...
@@ -632,7 +642,7 @@ error _Mapping::unmap() {
std
::
remove
(
f
->
_mmaps
.
begin
(),
f
->
_mmaps
.
end
(),
mmap
),
std
::
remove
(
f
->
_mmaps
.
begin
(),
f
->
_mmaps
.
end
(),
mmap
),
f
->
_mmaps
.
end
());
f
->
_mmaps
.
end
());
return
nil
;
return
E
(
err
)
;
}
}
...
...
wcfs/client/wcfs.h
View file @
a1a06fea
...
@@ -167,14 +167,23 @@ struct WCFS {
...
@@ -167,14 +167,23 @@ struct WCFS {
typedef
refptr
<
struct
_Conn
>
Conn
;
typedef
refptr
<
struct
_Conn
>
Conn
;
struct
_Conn
:
object
{
struct
_Conn
:
object
{
WCFS
*
_wc
;
WCFS
*
_wc
;
zodb
::
Tid
at
;
// XXX -> under mu
WatchLink
_wlink
;
// watch/receive pins for mappings created under this conn
WatchLink
_wlink
;
// watch/receive pins for mappings created under this conn
// atMu protects .at.
// While it is rlocked, .at is guaranteed to stay unchanged and Conn
// viewing the database at particular state. .resync write-locks this and
// knows noone is using the connection for reading simultaneously.
//
// XXX deadlock with pinner?
//
// sync::RWMutex _atMu
zodb
::
Tid
at
;
// XXX kill downMu? (move under filehmu so that e.g. .open() can check downErr without race)
// XXX kill downMu? (move under filehmu so that e.g. .open() can check downErr without race)
sync
::
Mutex
_downMu
;
sync
::
Mutex
_downMu
;
error
_downErr
;
// !nil if connection is closed or no longer operational
error
_downErr
;
// !nil if connection is closed or no longer operational
sync
::
Mutex
_filehmu
;
sync
::
Mutex
_filehmu
;
// _atMu.W | _atMu.R + _filehMu
dict
<
zodb
::
Oid
,
FileH
>
_filehtab
;
// {} foid -> fileh
dict
<
zodb
::
Oid
,
FileH
>
_filehtab
;
// {} foid -> fileh
sync
::
WorkGroup
_pinWG
;
// pin/unpin messages from wcfs are served by _pinner
sync
::
WorkGroup
_pinWG
;
// pin/unpin messages from wcfs are served by _pinner
...
...
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