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
23ef1568
Commit
23ef1568
authored
Jul 11, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8a00147e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
12 deletions
+29
-12
bigfile/tests/test_virtmem.c
bigfile/tests/test_virtmem.c
+28
-11
bigfile/virtmem.c
bigfile/virtmem.c
+1
-1
No files found.
bigfile/tests/test_virtmem.c
View file @
23ef1568
...
...
@@ -1127,15 +1127,12 @@ struct BigFileMMap {
};
typedef
struct
BigFileMMap
BigFileMMap
;
void
*
mmapfile_mmap_setup_read
(
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
,
VMA
*
vma
)
{
void
mmapfile_release
(
BigFile
*
file
)
{
BigFileMMap
*
f
=
upcast
(
BigFileMMap
*
,
file
);
void
*
addr
;
addr
=
mmap
(
NULL
,
blklen
*
f
->
blksize
,
PROT_READ
,
MAP_SHARED
,
f
->
fd
,
blk
*
f
->
blksize
);
if
(
addr
==
MAP_FAILED
)
addr
=
NULL
;
int
err
;
return
addr
;
err
=
close
(
f
->
fd
);
BUG_ON
(
err
);
}
int
mmapfile_storeblk
(
BigFile
*
file
,
blk_t
blk
,
const
void
*
buf
)
{
...
...
@@ -1157,17 +1154,37 @@ int mmapfile_storeblk(BigFile *file, blk_t blk, const void *buf) {
return
0
;
}
void
mmapfile_release
(
BigFile
*
file
)
{
void
*
mmapfile_mmap_setup_read
(
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
,
VMA
*
vma
)
{
BigFileMMap
*
f
=
upcast
(
BigFileMMap
*
,
file
);
int
er
r
;
void
*
add
r
;
err
=
close
(
f
->
fd
);
BUG_ON
(
err
);
addr
=
mmap
(
NULL
,
blklen
*
f
->
blksize
,
PROT_READ
,
MAP_SHARED
,
f
->
fd
,
blk
*
f
->
blksize
);
if
(
addr
==
MAP_FAILED
)
addr
=
NULL
;
return
addr
;
}
int
mmapfile_remmap_blk_read
(
BigFile
*
file
,
blk_t
blk
,
VMA
*
vma
)
{
BigFileMMap
*
f
=
upcast
(
BigFileMMap
*
,
file
);
TODO
(
f
->
blksize
!=
vma
->
fileh
->
ramh
->
ram
->
pagesize
);
ASSERT
(
vma
->
f_pgoffset
<=
blk
&&
blk
<
vma_addr_fpgoffset
(
vma
,
vma
->
addr_stop
));
pgoff_t
pgoff_invma
=
blk
-
vma
->
f_pgoffset
;
uintptr_t
addr
=
vma
->
addr_start
+
pgoff_invma
*
f
->
blksize
;
void
*
mapped
;
mapped
=
mmap
((
void
*
)
addr
,
1
*
f
->
blksize
,
PROT_READ
,
MAP_SHARED
|
MAP_FIXED
,
f
->
fd
,
blk
*
f
->
blksize
);
if
(
mapped
==
MAP_FAILED
)
return
-
1
;
ASSERT
(
mapped
==
(
void
*
)
addr
);
return
0
;
}
static
const
struct
bigfile_ops
mmapfile_ops
=
{
.
loadblk
=
NULL
,
.
mmap_setup_read
=
mmapfile_mmap_setup_read
,
.
remmap_blk_read
=
mmapfile_remmap_blk_read
,
.
storeblk
=
mmapfile_storeblk
,
.
release
=
mmapfile_release
,
};
...
...
bigfile/virtmem.c
View file @
23ef1568
...
...
@@ -1068,7 +1068,7 @@ static void vma_page_ensure_unmapped(VMA *vma, Page *page)
int
err
;
TODO
(
file
->
blksize
!=
page_size
(
page
));
err
=
file
->
file_ops
->
remmap_blk_read
(
file
,
page
->
f_pgoffset
/* =blk */
,
vma
);
err
=
file
->
file_ops
->
remmap_blk_read
(
file
,
/* blk = */
page
->
f_pgoffset
,
vma
);
BUG_ON
(
err
);
/* must not fail */
}
else
{
...
...
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