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
cd3f3f04
Commit
cd3f3f04
authored
Oct 21, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c6e0e48e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+38
-0
No files found.
wcfs/internal/wcfs_virtmem.cpp
View file @
cd3f3f04
...
...
@@ -46,6 +46,9 @@ using std::vector;
typedef
uint64_t
Tid
;
// XXX ok?
typedef
uint64_t
Oid
;
// XXX ok?
// TidHead is invalid Tid which is larged Tid value and means @head
const
Tid
TidHead
=
-
1ULL
;
// XXX ok?
struct
IContext
{
virtual
chan
<
structZ
>
done
()
=
0
;
...
...
@@ -108,6 +111,8 @@ struct _Mapping {
ASSERT
((
mem_stop
-
mem_start
)
%
file
->
blksize
==
0
);
return
blk_start
+
(
mem_stop
-
mem_start
)
/
file
->
blksize
;
}
void
_remmapblk
(
int64_t
blk
,
Tid
at
);
};
...
...
@@ -213,3 +218,36 @@ void Conn::_pin1(SrvReq *req) {
wconn
->
_filemu
.
unlock
();
}
// _remmapblk remmaps mapping memory for file[blk] to be viewing database as of @at state.
//
// at=None means unpin to head/ . XXX -> C
// NOTE this does not check wrt virtmem already mapped blk as RW.
void
_Mapping
::
_remmapblk
(
int64_t
blk
,
Tid
at
)
{
_Mapping
*
mmap
=
this
;
ASSERT
(
mmap
->
blk_start
<=
blk
&&
blk
<
mmap
->
blk_stop
());
_File
*
f
=
mmap
->
file
;
uint8_t
*
blkmem
=
mmap
->
mem_start
+
(
blk
-
mmap
->
blk_start
)
*
f
->
blksize
;
if
(
at
==
TidHead
)
{
fsfile
=
f
->
headf
;
}
else
{
// TODO share @rev fd until wconn is resynced?
fsfile
=
f
->
wconn
->
_wc
.
_open
(
"@%s/bigfile/%s"
%
(
h
(
at
),
h
(
f
->
foid
)),
"rb"
)
defer
(
fsfile
.
close
)
}
_
=
os
.
fstat
(
fsfile
.
fileno
());
ASSERT
(
_
.
st_blksize
==
f
->
blksize
);
// FIXME assert
// block is beyond file size - mmap with zeros (assumes head/f size ↑=)
if
((
blk
+
1
)
*
f
->
blksize
>
_
.
st_size
)
{
mm
.
map_zero_into_ro
(
blkmem
)
}
// block is inside file - mmap file data
else
{
mm
.
map_into_ro
(
blkmem
,
fsfile
.
fileno
(),
blk
*
f
->
blksize
)
}
}
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