Commit dcfde02d authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f046f723
......@@ -120,6 +120,10 @@ struct PyBigFileH {
PyObject *in_weakreflist;
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;
......@@ -968,6 +972,7 @@ out:
static const struct bigfile_ops pybigfile_ops = {
.loadblk = pybigfile_loadblk,
.storeblk = pybigfile_storeblk,
// XXX .mmap*
//.release =
};
......@@ -983,9 +988,13 @@ pyfileh_open(PyObject *pyfile0, PyObject *args)
int err;
if (!PyArg_ParseTuple(args, ""))
if (!PyArg_ParseTuple(args, "")) // XXX parse mmap_overlay=None (True/False)
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);
if (!pyfileh)
return NULL;
......
......@@ -642,6 +642,12 @@ class ZBigFile(LivePersistent):
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
# that is given to user for mmap.
......@@ -763,7 +769,9 @@ class _ZBigFileH(object):
def __init__(self, zfile, wcfileh):
self.zfile = zfile
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
# before first commit)
......
......@@ -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
if (vma != NULL) {
vma->mmap_overlay_server = mmap._ptr(); // XXX +giveref
}
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.
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