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
dbaf1db9
Commit
dbaf1db9
authored
4 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
04b5d87b
t
josh_wip
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
wcfs/internal/wcfs.cpp
wcfs/internal/wcfs.cpp
+15
-14
No files found.
wcfs/internal/wcfs.cpp
View file @
dbaf1db9
...
...
@@ -311,11 +311,11 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
// Left fileh mappings become invalid to use.
error
_FileH
::
close
()
{
_FileH
&
fileh
=
*
this
;
// XXX err ctx
xerr
::
Contextf
E
(
"conn @%s: close f<%s>"
,
v
(
fileh
.
wconn
->
at
),
v
(
fileh
.
foid
));
// XXX + wcfs path?
// XXX remove fileh from .wconn._filehtab ?
return
fileh
.
_headf
->
close
(
);
return
E
(
fileh
.
_headf
->
close
()
);
}
// mmap creates file mapping representing file[blk_start +blk_len) data as of wconn.at database state.
...
...
@@ -323,7 +323,9 @@ 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
;
// XXX err ctx
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?
// XXX (blk_start + blk_len) * blk_size overflow
error
err
;
...
...
@@ -342,7 +344,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
uint8_t
*
mem_start
,
*
mem_stop
;
tie
(
mem_start
,
err
)
=
mmap_ro
(
f
.
_headf
,
start
,
blk_len
*
f
.
blksize
);
if
(
err
!=
nil
)
return
make_pair
(
nil
,
err
);
return
make_pair
(
nil
,
E
(
err
)
);
mem_stop
=
mem_start
+
blk_len
*
f
.
blksize
;
int64_t
stop
=
blk_stop
*
f
.
blksize
;
...
...
@@ -350,7 +352,7 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
uint8_t
*
zmem_start
=
mem_start
+
(
max
(
f
.
_headfsize
/*XXX -1 ?*/
,
start
)
-
start
);
err
=
mmap_zero_into_ro
(
zmem_start
,
mem_stop
-
zmem_start
);
if
(
err
!=
nil
)
return
make_pair
(
nil
,
err
);
return
make_pair
(
nil
,
E
(
err
)
);
}
Mapping
mmap
=
adoptref
(
new
_Mapping
());
...
...
@@ -380,7 +382,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
;
// XXX err ctx
xerr
::
Contextf
E
(
"conn @%s: resync -> @%s"
,
v
(
wconn
.
at
),
v
(
at
));
// XXX +wcfs path?
// XXX locking
...
...
@@ -395,15 +397,15 @@ error _Conn::resync(zodb::Tid at) {
struct
stat
st
;
error
err
=
f
->
_headf
->
stat
(
&
st
);
if
(
err
!=
nil
)
return
err
;
return
E
(
err
)
;
if
((
size_t
)
st
.
st_blksize
!=
f
->
blksize
)
// blksize must not change
return
fmt
::
errorf
(
"wcfs bug: blksize changed: %zd -> %ld"
,
f
->
blksize
,
st
.
st_blksize
);
return
E
(
fmt
::
errorf
(
"wcfs bug: blksize changed: %zd -> %ld"
,
f
->
blksize
,
st
.
st_blksize
)
);
auto
headfsize
=
st
.
st_size
;
if
(
!
(
f
->
_headfsize
<=
headfsize
))
// head/file size ↑=
return
fmt
::
errorf
(
"wcfs bug: head/file size not ↑="
);
return
E
(
fmt
::
errorf
(
"wcfs bug: head/file size not ↑="
)
);
if
(
!
(
headfsize
%
f
->
blksize
==
0
))
return
fmt
::
errorf
(
"wcfs bug: head/file size %% blksize != 0"
);
return
E
(
fmt
::
errorf
(
"wcfs bug: head/file size %% blksize != 0"
)
);
for
(
auto
mmap
:
f
->
_mmaps
)
{
printf
(
" resync -> %s: unzero [%lu:%lu)"
,
v
(
at
),
f
->
_headfsize
/
f
->
blksize
,
headfsize
/
f
->
blksize
);
...
...
@@ -415,7 +417,7 @@ error _Conn::resync(zodb::Tid at) {
if
(
mem_unzero_stop
-
mem_unzero_start
>
0
)
{
err
=
mmap_into_ro
(
mem_unzero_start
,
mem_unzero_stop
-
mem_unzero_start
,
f
->
_headf
,
f
->
_headfsize
);
if
(
err
!=
nil
)
return
err
;
return
E
(
err
)
;
}
}
...
...
@@ -425,11 +427,10 @@ error _Conn::resync(zodb::Tid at) {
string
ack
;
tie
(
ack
,
err
)
=
wconn
.
_wlink
->
sendReq
(
context
::
background
(),
fmt
::
sprintf
(
"watch %s @%s"
,
v
(
foid
),
v
(
at
)));
if
(
err
!=
nil
)
return
err
;
return
E
(
err
)
;
if
(
ack
!=
"ok"
)
{
// XXX unregister f from _filehtab
// XXX vvv -> errctx?
return
fmt
::
errorf
(
"resync @%s -> @%s: f<%s>: %s"
,
v
(
wconn
.
at
),
v
(
at
),
v
(
foid
),
v
(
ack
));
return
E
(
fmt
::
errorf
(
"%s"
,
v
(
ack
)));
}
}
...
...
This diff is collapsed.
Click to expand it.
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