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
f9efdbc0
Commit
f9efdbc0
authored
Jan 08, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
5d67756e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
wcfs/internal/wcfs.cpp
wcfs/internal/wcfs.cpp
+21
-21
wcfs/internal/wcfs.h
wcfs/internal/wcfs.h
+4
-4
No files found.
wcfs/internal/wcfs.cpp
View file @
f9efdbc0
...
...
@@ -215,7 +215,7 @@ error _Conn::__pin1(PinReq *req) {
if
(
mmap
->
vma
!=
NULL
)
{
virt_lock
();
BigFileH
*
virt_fileh
=
mmap
->
vma
->
fileh
;
TODO
(
mmap
->
fileh
->
_
blksize
!=
virt_fileh
->
ramh
->
ram
->
pagesize
);
TODO
(
mmap
->
fileh
->
blksize
!=
virt_fileh
->
ramh
->
ram
->
pagesize
);
do_pin
=
!
__fileh_page_isdirty
(
virt_fileh
,
req
->
blk
);
}
...
...
@@ -264,7 +264,7 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
f
=
adoptref
(
new
_FileH
());
f
->
wconn
=
newref
(
&
wconn
);
// XXX newref -> simpler?
f
->
_foid
=
foid
;
f
->
foid
=
foid
;
tie
(
f
->
_headf
,
err
)
=
wconn
.
_wc
->
_open
(
fmt
::
sprintf
(
"head/bigfile/%s"
,
h_
(
foid
)));
if
(
err
!=
nil
)
...
...
@@ -274,9 +274,9 @@ pair<FileH, error> _Conn::open(zodb::Oid foid) {
err
=
f
->
_headf
->
stat
(
&
st
);
if
(
err
!=
nil
)
return
make_pair
(
nil
,
err
);
f
->
_blksize
=
st
.
st_blksize
;
f
->
blksize
=
st
.
st_blksize
;
f
->
_headfsize
=
st
.
st_size
;
if
(
!
(
f
->
_headfsize
%
f
->
_
blksize
==
0
))
if
(
!
(
f
->
_headfsize
%
f
->
blksize
==
0
))
return
make_pair
(
nil
,
fmt
::
errorf
(
"wcfs bug: head/file size %% blksize != 0"
));
wconn
.
_filehtab
[
foid
]
=
f
;
...
...
@@ -315,14 +315,14 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
// create memory with head/f mapping and applied pins
// mmap-in zeros after f.size (else access to memory after file.size will raise SIGBUS)
int64_t
start
=
blk_start
*
f
.
_
blksize
;
int64_t
start
=
blk_start
*
f
.
blksize
;
uint8_t
*
mem_start
,
*
mem_stop
;
tie
(
mem_start
,
err
)
=
mmap_ro
(
f
.
_headf
,
start
,
blk_len
*
f
.
_
blksize
);
tie
(
mem_start
,
err
)
=
mmap_ro
(
f
.
_headf
,
start
,
blk_len
*
f
.
blksize
);
if
(
err
!=
nil
)
return
make_pair
(
nil
,
err
);
mem_stop
=
mem_start
+
blk_len
*
f
.
_
blksize
;
mem_stop
=
mem_start
+
blk_len
*
f
.
blksize
;
int64_t
stop
=
blk_stop
*
f
.
_
blksize
;
int64_t
stop
=
blk_stop
*
f
.
blksize
;
if
(
stop
>
f
.
_headfsize
)
{
uint8_t
*
zmem_start
=
mem_start
+
(
max
(
f
.
_headfsize
/*XXX -1 ?*/
,
start
)
-
start
);
err
=
mmap_zero_into_ro
(
zmem_start
,
mem_stop
-
zmem_start
);
...
...
@@ -374,20 +374,20 @@ error _Conn::resync(zodb::Tid at) {
if
(
err
!=
nil
)
return
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
);
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
);
auto
headfsize
=
st
.
st_size
;
if
(
!
(
f
->
_headfsize
<=
headfsize
))
// head/file size ↑=
return
fmt
::
errorf
(
"wcfs bug: head/file size not ↑="
);
if
(
!
(
headfsize
%
f
->
_
blksize
==
0
))
if
(
!
(
headfsize
%
f
->
blksize
==
0
))
return
fmt
::
errorf
(
"wcfs bug: head/file size %% blksize != 0"
);
for
(
auto
mmap
:
f
->
_mmaps
)
{
printf
(
" resync -> %s: unzero [%lu:%lu)"
,
h_
(
at
),
f
->
_headfsize
/
f
->
_blksize
,
headfsize
/
f
->
_
blksize
);
printf
(
" resync -> %s: unzero [%lu:%lu)"
,
h_
(
at
),
f
->
_headfsize
/
f
->
blksize
,
headfsize
/
f
->
blksize
);
uint8_t
*
mem_unzero_start
=
min
(
mmap
->
mem_stop
,
mmap
->
mem_start
+
(
f
->
_headfsize
-
mmap
->
blk_start
*
f
->
_
blksize
));
mmap
->
mem_start
+
(
f
->
_headfsize
-
mmap
->
blk_start
*
f
->
blksize
));
uint8_t
*
mem_unzero_stop
=
min
(
mmap
->
mem_stop
,
mmap
->
mem_start
+
(
headfsize
-
mmap
->
blk_start
*
f
->
_
blksize
));
mmap
->
mem_start
+
(
headfsize
-
mmap
->
blk_start
*
f
->
blksize
));
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
);
...
...
@@ -426,7 +426,7 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
FileH
f
=
mmap
->
fileh
;
error
err
;
uint8_t
*
blkmem
=
mmap
->
mem_start
+
(
blk
-
mmap
->
blk_start
)
*
f
->
_
blksize
;
uint8_t
*
blkmem
=
mmap
->
mem_start
+
(
blk
-
mmap
->
blk_start
)
*
f
->
blksize
;
os
::
File
fsfile
;
bool
fclose
=
false
;
if
(
at
==
TidHead
)
{
...
...
@@ -435,7 +435,7 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
else
{
// TODO share @rev fd until wconn is resynced?
tie
(
fsfile
,
err
)
=
f
->
wconn
->
_wc
->
_open
(
fmt
::
sprintf
(
"@%s/bigfile/%s"
,
h_
(
at
),
h_
(
f
->
_
foid
)));
fmt
::
sprintf
(
"@%s/bigfile/%s"
,
h_
(
at
),
h_
(
f
->
foid
)));
if
(
err
!=
nil
)
return
err
;
fclose
=
true
;
...
...
@@ -449,19 +449,19 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
err
=
fsfile
->
stat
(
&
st
);
if
(
err
!=
nil
)
return
err
;
if
((
size_t
)
st
.
st_blksize
!=
f
->
_
blksize
)
return
fmt
::
errorf
(
"wcfs bug: blksize changed: %zd -> %ld"
,
f
->
_
blksize
,
st
.
st_blksize
);
if
((
size_t
)
st
.
st_blksize
!=
f
->
blksize
)
return
fmt
::
errorf
(
"wcfs bug: blksize changed: %zd -> %ld"
,
f
->
blksize
,
st
.
st_blksize
);
// block is beyond file size - mmap with zeros - else access to memory
// after file.size will raise SIGBUS. (assumes head/f size ↑=)
if
((
blk
+
1
)
*
f
->
_
blksize
>
(
size_t
)
st
.
st_size
)
{
err
=
mmap_zero_into_ro
(
blkmem
,
1
*
f
->
_
blksize
);
if
((
blk
+
1
)
*
f
->
blksize
>
(
size_t
)
st
.
st_size
)
{
err
=
mmap_zero_into_ro
(
blkmem
,
1
*
f
->
blksize
);
if
(
err
!=
nil
)
return
err
;
}
// block is inside file - mmap file data
else
{
err
=
mmap_into_ro
(
blkmem
,
1
*
f
->
_blksize
,
fsfile
,
blk
*
f
->
_
blksize
);
err
=
mmap_into_ro
(
blkmem
,
1
*
f
->
blksize
,
fsfile
,
blk
*
f
->
blksize
);
if
(
err
!=
nil
)
return
err
;
}
...
...
wcfs/internal/wcfs.h
View file @
f9efdbc0
...
...
@@ -138,8 +138,8 @@ private:
typedef
refptr
<
struct
_FileH
>
FileH
;
struct
_FileH
:
object
{
Conn
wconn
;
zodb
::
Oid
_foid
;
// ZBigFile root object ID
size_t
_blksize
;
// block size of this file XXX -> off_t ?
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 ↑=)
...
...
@@ -169,8 +169,8 @@ struct _Mapping : object {
VMA
*
vma
;
// mmapped under this virtmem VMA | nil if created standalone from virtmem
int64_t
blk_stop
()
const
{
ASSERT
((
mem_stop
-
mem_start
)
%
fileh
->
_
blksize
==
0
);
return
blk_start
+
(
mem_stop
-
mem_start
)
/
fileh
->
_
blksize
;
ASSERT
((
mem_stop
-
mem_start
)
%
fileh
->
blksize
==
0
);
return
blk_start
+
(
mem_stop
-
mem_start
)
/
fileh
->
blksize
;
}
error
_remmapblk
(
int64_t
blk
,
zodb
::
Tid
at
);
...
...
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