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
03aa7ebd
Commit
03aa7ebd
authored
Apr 14, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ef0de564
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
25 deletions
+35
-25
bigfile/_bigfile.c
bigfile/_bigfile.c
+1
-1
bigfile/file_zodb.cpp
bigfile/file_zodb.cpp
+7
-4
bigfile/tests/test_virtmem.c
bigfile/tests/test_virtmem.c
+7
-4
bigfile/virtmem.c
bigfile/virtmem.c
+11
-10
include/wendelin/bigfile/file.h
include/wendelin/bigfile/file.h
+9
-6
No files found.
bigfile/_bigfile.c
View file @
03aa7ebd
...
...
@@ -920,7 +920,7 @@ out:
/* PyBigFile: mmap methods.
* They redirect op X to type.blkmmapper.X without going to Python level */
static
void
*
static
int
pybigfile_mmap_setup_read
(
VMA
*
vma
,
BigFile
*
file0
,
blk_t
blk
,
size_t
blklen
)
{
PyBigFile
*
file
=
container_of
(
file0
,
PyBigFile
,
file
);
...
...
bigfile/file_zodb.cpp
View file @
03aa7ebd
...
...
@@ -27,7 +27,7 @@
#include "bigfile/_file_zodb.h"
#include <ccan/container_of/container_of.h>
static
void
*
zfile_mmap_setup_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
)
{
static
int
zfile_mmap_setup_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
)
{
_ZBigFile
*
_zfile
=
container_of
(
file
,
_ZBigFile
,
__pyx_base
.
file
);
wcfs
::
FileH
fileh
=
_zfile
->
wfileh
;
...
...
@@ -38,10 +38,13 @@ static void* zfile_mmap_setup_read(VMA *vma, BigFile *file, blk_t blk, size_t bl
panic
(
"BUG: zfile_mmap_setup_read: ZBigFile.fileh_open did not set .wfileh"
);
tie
(
mmap
,
err
)
=
fileh
->
mmap
(
blk
,
blklen
,
vma
);
if
(
err
!=
nil
)
panic
(
v
(
err
));
// XXX
if
(
err
!=
nil
)
{
// XXX no way to return error details to virtmem
log
::
Errorf
(
"%s: mmap_setup_read #[%d +%d): %s"
,
v
(
fileh
),
blk
,
blklen
,
v
(
err
));
return
-
1
;
}
return
(
void
*
)
vma
->
addr_start
;
// XXX (?) kill - we set vma->addr_*
return
0
;
}
static
int
zfile_remmap_blk_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
)
{
...
...
bigfile/tests/test_virtmem.c
View file @
03aa7ebd
...
...
@@ -1161,15 +1161,18 @@ int mmapfile_storeblk(BigFile *file, blk_t blk, const void *buf) {
return
0
;
}
void
*
mmapfile_mmap_setup_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
)
{
int
mmapfile_mmap_setup_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
)
{
BigFileMMap
*
f
=
upcast
(
BigFileMMap
*
,
file
);
size_t
len
=
blklen
*
f
->
blksize
;
void
*
addr
;
addr
=
mmap
(
NULL
,
blklen
*
f
->
blksize
,
PROT_READ
,
MAP_SHARED
,
f
->
fd
,
blk
*
f
->
blksize
);
addr
=
mmap
(
NULL
,
len
,
PROT_READ
,
MAP_SHARED
,
f
->
fd
,
blk
*
f
->
blksize
);
if
(
addr
==
MAP_FAILED
)
addr
=
NULL
;
return
-
1
;
return
addr
;
vma
->
addr_start
=
(
uintptr_t
)
addr
;
vma
->
addr_stop
=
vma
->
addr_start
+
len
;
return
0
;
}
int
mmapfile_remmap_blk_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
)
{
...
...
bigfile/virtmem.c
View file @
03aa7ebd
...
...
@@ -240,7 +240,6 @@ void fileh_close(BigFileH *fileh)
int
fileh_mmap
(
VMA
*
vma
,
BigFileH
*
fileh
,
pgoff_t
pgoffset
,
pgoff_t
pglen
)
{
void
*
addr
;
size_t
len
=
pglen
*
fileh
->
ramh
->
ram
->
pagesize
;
BigFile
*
file
=
fileh
->
file
;
const
bigfile_ops
*
fops
=
file
->
file_ops
;
...
...
@@ -261,19 +260,21 @@ int fileh_mmap(VMA *vma, BigFileH *fileh, pgoff_t pgoffset, pgoff_t pglen)
goto
fail
;
if
(
fileh
->
mmap_overlay
)
{
/* wcfs: mmap(base, READ) */
/* wcfs: mmap(base, READ)
* vma->addr_{start,stop} are initialized by mmap_setup_read */
TODO
(
file
->
blksize
!=
fileh
->
ramh
->
ram
->
pagesize
);
addr
=
fops
->
mmap_setup_read
(
vma
,
file
,
pgoffset
,
pglen
);
err
=
fops
->
mmap_setup_read
(
vma
,
file
,
pgoffset
,
pglen
);
if
(
err
)
goto
fail
;
}
else
{
/* !wcfs: allocate address space somewhere */
addr
=
mem_valloc
(
NULL
,
len
);
void
*
addr
=
mem_valloc
(
NULL
,
len
);
if
(
!
addr
)
goto
fail
;
/* vma address range known */
vma
->
addr_start
=
(
uintptr_t
)
addr
;
vma
->
addr_stop
=
vma
->
addr_start
+
len
;
}
if
(
!
addr
)
goto
fail
;
/* vma address range known */
vma
->
addr_start
=
(
uintptr_t
)
addr
;
vma
->
addr_stop
=
vma
->
addr_start
+
len
;
/* wcfs: mmap(fileh->dirty_pages) over base */
if
(
fileh
->
mmap_overlay
)
{
...
...
include/wendelin/bigfile/file.h
View file @
03aa7ebd
...
...
@@ -46,7 +46,7 @@ typedef struct VMA VMA;
/* BigFile base class
*
* BigFile is a file of fixed size blocks. It knows how to load/store blocks
* to/from memory. It can be also optionally m
emory mmaped
.
* to/from memory. It can be also optionally m
maped into memory
.
*
* Concrete file implementations subclass BigFile and define their file_ops.
*/
...
...
@@ -106,7 +106,7 @@ struct bigfile_ops {
*
* The functions to setup memory mappings are:
*
* - mmap_setup_read(vma, file[blk +blklen))
-> addr
setup initial read-only mmap to serve vma
* - mmap_setup_read(vma, file[blk +blklen)) setup initial read-only mmap to serve vma
* - remmap_blk_read(vma, file[blk]) remmap blk into vma again, after e.g.
* RW dirty page was discarded
* - munmap(vma) before VMA is unmapped
...
...
@@ -137,17 +137,20 @@ struct bigfile_ops {
* }
* virt_unlock()
*
* mmap_setup_read must set vma.addr_start and vma.addr_stop according to
* created memory mapping.
*
* mmap_setup_read can use vma.mmap_overlay_server to associate vma with
* object pointer specific to serving created mapping.
*
* Called under virtmem lock.
XXX
easy to rework to call with !virt_lock
* Called under virtmem lock.
TODO
easy to rework to call with !virt_lock
*
* NOTE blk and blklen are in blocks, not pages.
*
* @addr NULL - mmap at anywhere, !NULL - mmap exactly at addr.
* @return
!NULL - mapped there, NULL - error.
* @return
0 - ok !0 - fail
*/
void
*
(
*
mmap_setup_read
)
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
);
int
(
*
mmap_setup_read
)
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
);
/* remmap_blk_read is called to remmap a block into vma again, after e.g.
...
...
@@ -161,7 +164,7 @@ struct bigfile_ops {
/* munmap is called when vma set up via mmap_setup_read is going to be unmapped.
*
* Called under virtmem lock.
XXX
easy to rework to call with !virt_lock
* Called under virtmem lock.
TODO
easy to rework to call with !virt_lock
* Must not fail.
*/
void
(
*
munmap
)
(
VMA
*
vma
,
BigFile
*
file
);
...
...
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