Commit dcfde02d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f046f723
...@@ -120,6 +120,10 @@ struct PyBigFileH { ...@@ -120,6 +120,10 @@ struct PyBigFileH {
PyObject *in_weakreflist; PyObject *in_weakreflist;
BigFileH; BigFileH;
/* if subclass, in addition to .loadblk/.storeblk, defines .mmapper XXX ... */
PyObject *pymmapper; // python object returned by .mmaper() that is holding virtmem_mapper pycapsule
//virt_mapper *virt_mmap_ops; // XXX ok?
}; };
typedef struct PyBigFileH PyBigFileH; typedef struct PyBigFileH PyBigFileH;
...@@ -968,6 +972,7 @@ out: ...@@ -968,6 +972,7 @@ out:
static const struct bigfile_ops pybigfile_ops = { static const struct bigfile_ops pybigfile_ops = {
.loadblk = pybigfile_loadblk, .loadblk = pybigfile_loadblk,
.storeblk = pybigfile_storeblk, .storeblk = pybigfile_storeblk,
// XXX .mmap*
//.release = //.release =
}; };
...@@ -983,9 +988,13 @@ pyfileh_open(PyObject *pyfile0, PyObject *args) ...@@ -983,9 +988,13 @@ pyfileh_open(PyObject *pyfile0, PyObject *args)
int err; int err;
if (!PyArg_ParseTuple(args, "")) if (!PyArg_ParseTuple(args, "")) // XXX parse mmap_overlay=None (True/False)
return NULL; return NULL;
// XXX verify if pyfile has .mmapper()
// if mmap_overlay or (mmap_overlay==None and has(pyfile.mmapper)):
// mmaper = pyfile.mmapper()
pyfileh = PyType_New(PyBigFileH, &PyBigFileH_Type, NULL); pyfileh = PyType_New(PyBigFileH, &PyBigFileH_Type, NULL);
if (!pyfileh) if (!pyfileh)
return NULL; return NULL;
......
...@@ -642,6 +642,12 @@ class ZBigFile(LivePersistent): ...@@ -642,6 +642,12 @@ class ZBigFile(LivePersistent):
fileh.invalidate_page(blk) # XXX assumes blksize == pagesize fileh.invalidate_page(blk) # XXX assumes blksize == pagesize
# mmaper complemnts loadblk/storeblk and returns object with pycapsule with .mmap*
# methods to be used by virtmem to mmap base overlay of the file data. XXX text
def mmaper(self):
# XXX return wcfileh (= zconn.wconn.open(self._p_oid))
1/0
# fileh_open is bigfile-like method that creates new file-handle object # fileh_open is bigfile-like method that creates new file-handle object
# that is given to user for mmap. # that is given to user for mmap.
...@@ -763,7 +769,9 @@ class _ZBigFileH(object): ...@@ -763,7 +769,9 @@ class _ZBigFileH(object):
def __init__(self, zfile, wcfileh): def __init__(self, zfile, wcfileh):
self.zfile = zfile self.zfile = zfile
self.wcfileh = wcfileh self.wcfileh = wcfileh
self.zfileh = zfile._v_file.fileh_open(wcfileh) # XXX pass wcfileh in #self.zfileh = zfile._v_file.fileh_open(wcfileh) # XXX pass wcfileh in
# XXX no - BigFile should fetch wcfileh itself from ZBigFile by calling ZBigFile.mmapper()
self.zfileh = zfile._v_file.fileh_open()
# FIXME zfile._p_jar could be None (ex. ZBigFile is newly created # FIXME zfile._p_jar could be None (ex. ZBigFile is newly created
# before first commit) # before first commit)
......
...@@ -349,9 +349,34 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma) ...@@ -349,9 +349,34 @@ pair<Mapping, error> _FileH::mmap(int64_t blk_start, int64_t blk_len, VMA *vma)
f._mmaps.push_back(mmap); // XXX keep f._mmaps ↑blk_start f._mmaps.push_back(mmap); // XXX keep f._mmaps ↑blk_start
if (vma != NULL) {
vma->mmap_overlay_server = mmap._ptr(); // XXX +giveref
}
return make_pair(mmap, nil); 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 = ...
Mapping mmap;
error err;
tie(mmap, err) = fileh->mmap(blk, blklen, vma);
if (err != nil)
panic("TODO"); // XXX
panic("TODO");
}
// XXX virt_remmap_blk_read(VMA *vma, BigFile *file, blk_t blk)
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();
}
// resync resyncs connection and its mappings onto different database view. // resync resyncs connection and its mappings onto different database view.
error _Conn::resync(zodb::Tid at) { error _Conn::resync(zodb::Tid at) {
_Conn& wconn = *this; _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