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
76cf581c
Commit
76cf581c
authored
Dec 17, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
15e625a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
43 deletions
+85
-43
bigfile/_file_zodb.pyx
bigfile/_file_zodb.pyx
+84
-3
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+1
-40
No files found.
bigfile/_file_zodb.pyx
View file @
76cf581c
...
...
@@ -40,14 +40,14 @@ cdef extern from *:
#include <wendelin/bigfile/file.h>
#include <wendelin/bigfile/virtmem.h>
struct
CXX
PyBigFile {
struct
cxx
PyBigFile {
PyObject pyobj;
BigFile file;
};
"""
struct
CXX
PyBigFile
:
struct
cxx
PyBigFile
:
pass
ctypedef
extern
class
wendelin
.
bigfile
.
_bigfile
.
BigFile
[
object
CXX
PyBigFile
]:
ctypedef
extern
class
wendelin
.
bigfile
.
_bigfile
.
BigFile
[
object
cxx
PyBigFile
]:
pass
from
wcfs.internal
cimport
_wcfs
as
wcfs
...
...
@@ -83,3 +83,84 @@ cdef class _ZBigFile(BigFile):
def
loadblk
(
self
,
blk
,
buf
):
return
self
.
zself
.
loadblk
(
blk
,
buf
)
def
storeblk
(
self
,
blk
,
buf
):
return
self
.
zself
.
storeblk
(
blk
,
buf
)
#def blkmmapper(self): return self.zself.blkmmapper()
# blkmapper serves PyBigFile and gives it XXX ...
#
# it is called from PyBigFile.fileh_open(mmap_overlay=True) and .zfile
# should be already associaed with jar and have oid.
def
blkmapper
(
_ZBigFile
zf
):
if
zf
.
wconn
==
nil
:
zconn
=
zf
.
zself
.
_p_jar
assert
zconn
is
not
None
# XXX locking? or rely on that ZODB objects for must be used from under 1 thread only?
zf
.
foid
=
u64
(
zf
.
zself
.
_p_oid
)
# XXX join zconn to wconn
pywconn
=
pywconnOf
(
zconn
)
zf
.
wconn
=
pywconn
.
XXX
# functions that we give to virtmem bigfile_ops .mmap*
cdef
nogil
:
void
*
virt_mmap_setup_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
)
{
FileH
fileh
;
# XXX = ... somehow from file
Mapping
mmap
;
error
err
;
tie
(
mmap
,
err
)
=
fileh
->
mmap
(
blk
,
blklen
,
vma
);
if
(
err
!=
nil
)
panic
(
"TODO"
);
# XXX
mmap
->
incref
();
# vma->mmap_overlay_server is keeping ref to mmap
vma
->
mmap_overlay_server
=
mmap
.
_ptr
();
# XXX here? -> in fileh->mmap? don't set at all here?
vma
->
addr_start
=
(
uintptr_t
)
mmap
->
mem_start
;
vma
->
addr_stop
=
(
uintptr_t
)
mmap
->
mem_stop
;
return
(
void
*
)
vma
->
addr_start
;
//
XXX
kill
if
we
set
vma
->
addr_
*
}
int
virt_remmap_blk_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
)
{
_Mapping
*
mmap
=
static_cast
<
_Mapping
*>
(
vma
->
mmap_overlay_server
);
//
XXX
use
file
?
mmap
->
remmap_blk
(
blk
);
//
XXX
err
return
0
;
}
void
virt_munmap
(
VMA
*
vma
,
BigFile
*
file
)
{
Mapping
mmap
=
adoptref
(
static_cast
<
_Mapping
*>
(
vma
->
mmap_overlay_server
));
//
NOTE
taking
1
ref
back
vma
->
mmap_overlay_server
=
NULL
;
mmap
->
unmap
();
//
XXX
close
mmap
->
fileh
}
# pywconnOf establishes and returns (py) wcfs.Conn associated with zconn.
# XXX wconn is maintained and kept in sync with zconn.
# XXX simultaneous call?
# XXX move -> .py ?
cdef
pywconnOf
(
zconn
):
assert
isinstance
(
zconn
,
zodbConnection
)
assert
zconn
.
opened
# XXX needed
# XXX locking
wconn
=
getattr
(
zconn
,
'_wcfs_wconn'
,
None
)
if
wconn
is
not
None
:
return
wconn
# zconn is not yet associated with wconn
zstor
=
zconn
.
db
().
storage
zurl
=
wcfs
.
zstor_2zurl
(
zstor
)
wc
=
wcfs
.
join
(
zurl
)
wconn
=
wc
.
connect
(
zconn_at
(
zconn
))
zconn
.
_wcfs_wconn
=
wconn
return
wconn
wcfs/internal/wcfs_virtmem.cpp
View file @
76cf581c
...
...
@@ -356,45 +356,6 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
return
make_pair
(
mmap
,
nil
);
}
// functions that we give to virtmem bigfile_ops .mmap*
void
*
virt_mmap_setup_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
,
size_t
blklen
)
{
FileH
fileh
;
// XXX = ... somehow from file
Mapping
mmap
;
error
err
;
tie
(
mmap
,
err
)
=
fileh
->
mmap
(
blk
,
blklen
,
vma
);
if
(
err
!=
nil
)
panic
(
"TODO"
);
// XXX
mmap
->
incref
();
// vma->mmap_overlay_server is keeping ref to mmap
vma
->
mmap_overlay_server
=
mmap
.
_ptr
();
// XXX here? -> in fileh->mmap? don't set at all here?
vma
->
addr_start
=
(
uintptr_t
)
mmap
->
mem_start
;
vma
->
addr_stop
=
(
uintptr_t
)
mmap
->
mem_stop
;
return
(
void
*
)
vma
->
addr_start
;
// XXX kill if we set vma->addr_*
}
int
virt_remmap_blk_read
(
VMA
*
vma
,
BigFile
*
file
,
blk_t
blk
)
{
_Mapping
*
mmap
=
static_cast
<
_Mapping
*>
(
vma
->
mmap_overlay_server
);
// XXX use file?
mmap
->
remmap_blk
(
blk
);
// XXX err
return
0
;
}
void
virt_munmap
(
VMA
*
vma
,
BigFile
*
file
)
{
Mapping
mmap
=
adoptref
(
static_cast
<
_Mapping
*>
(
vma
->
mmap_overlay_server
));
// NOTE taking 1 ref back
vma
->
mmap_overlay_server
=
NULL
;
mmap
->
unmap
();
// XXX close mmap->fileh
}
// resync resyncs connection and its mappings onto different database view.
error
_Conn
::
resync
(
zodb
::
Tid
at
)
{
_Conn
&
wconn
=
*
this
;
...
...
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