Commit 76cf581c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 15e625a4
......@@ -40,14 +40,14 @@ cdef extern from *:
#include <wendelin/bigfile/file.h>
#include <wendelin/bigfile/virtmem.h>
struct CXXPyBigFile {
struct cxxPyBigFile {
PyObject pyobj;
BigFile file;
};
"""
struct CXXPyBigFile:
struct cxxPyBigFile:
pass
ctypedef extern class wendelin.bigfile._bigfile.BigFile[object CXXPyBigFile]:
ctypedef extern class wendelin.bigfile._bigfile.BigFile[object cxxPyBigFile]:
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
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment