Commit 67b28c2a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 207c7a2b
...@@ -1031,7 +1031,7 @@ static PyMemberDef pyfile_members[] = { ...@@ -1031,7 +1031,7 @@ static PyMemberDef pyfile_members[] = {
static /*const*/ PyMethodDef pyfile_methods[] = { static /*const*/ PyMethodDef pyfile_methods[] = {
// XXX should be separate BigFileH ctor or fileh_open function? // XXX should be separate BigFileH ctor or fileh_open function?
{"fileh_open", pyfileh_open, METH_VARARGS, "fileh_open(ram=None) -> new file handle"}, {"fileh_open", pyfileh_open, METH_VARARGS, "fileh_open(ram=None, mmap_overlay=None) -> new file handle"},
{NULL} {NULL}
}; };
......
...@@ -665,7 +665,8 @@ class _ZBigFileH(object): ...@@ -665,7 +665,8 @@ class _ZBigFileH(object):
if wcfileh is not None: if wcfileh is not None:
self.zfileh = wcfileh self.zfileh = wcfileh
else: else:
self.zfileh = zfile._v_file.fileh_open() # XXX
self.zfileh = zfile._v_file.fileh_open(mmap_overlay=_use_wcfs)
# 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)
......
...@@ -80,7 +80,7 @@ void bench_pagefault() { ...@@ -80,7 +80,7 @@ void bench_pagefault() {
}; };
/* setup f mapping */ /* setup f mapping */
err = fileh_open(fh, &f, ram); err = fileh_open(fh, &f, ram, DONT_MMAP_OVERLAY);
ok1(!err); ok1(!err);
err = fileh_mmap(vma, fh, 0, npage); err = fileh_mmap(vma, fh, 0, npage);
......
...@@ -393,7 +393,7 @@ void test_file_access_synthetic(void) ...@@ -393,7 +393,7 @@ void test_file_access_synthetic(void)
.file_ops = &x_ops, .file_ops = &x_ops,
}; };
err = fileh_open(fh, &fileid, ram); err = fileh_open(fh, &fileid, ram, DONT_MMAP_OVERLAY);
ok1(!err); ok1(!err);
ok1(list_empty(&fh->mmaps)); ok1(list_empty(&fh->mmaps));
...@@ -956,7 +956,7 @@ void test_file_access_pagefault() ...@@ -956,7 +956,7 @@ void test_file_access_pagefault()
.file_ops = &fileid_ops, .file_ops = &fileid_ops,
}; };
err = fileh_open(fh, &fileid, ram); err = fileh_open(fh, &fileid, ram, DONT_MMAP_OVERLAY);
ok1(!err); ok1(!err);
/* implicitly use fileh=fh */ /* implicitly use fileh=fh */
...@@ -1084,7 +1084,7 @@ void test_pagefault_savestate() ...@@ -1084,7 +1084,7 @@ void test_pagefault_savestate()
.file_ops = &badfile_ops, .file_ops = &badfile_ops,
}; };
err = fileh_open(fh, &f, ram); err = fileh_open(fh, &f, ram, DONT_MMAP_OVERLAY);
ok1(!err); ok1(!err);
err = fileh_mmap(vma, fh, 0, 1); err = fileh_mmap(vma, fh, 0, 1);
...@@ -1266,7 +1266,7 @@ void test_file_access_mmapbase(void) ...@@ -1266,7 +1266,7 @@ void test_file_access_mmapbase(void)
fstore(103, 103); fstore(103, 103);
err = fileh_open(fh, &file, ram); err = fileh_open(fh, &file, ram, MMAP_OVERLAY);
ok1(!err); ok1(!err);
/* implicitly use fileh=fh */ /* implicitly use fileh=fh */
......
...@@ -146,10 +146,26 @@ static void sigsegv_restore(const sigset_t *save_sigset) ...@@ -146,10 +146,26 @@ static void sigsegv_restore(const sigset_t *save_sigset)
* OPEN / CLOSE * * OPEN / CLOSE *
****************/ ****************/
int fileh_open(BigFileH *fileh, BigFile *file, RAM *ram) int fileh_open(BigFileH *fileh, BigFile *file, RAM *ram, FileHOpenFlags flags)
{ {
int err = 0; int err = 0;
sigset_t save_sigset; sigset_t save_sigset;
const bigfile_ops *fops = file->file_ops;
if (!(flags == 0 || flags == MMAP_OVERLAY || flags == DONT_MMAP_OVERLAY))
return -EINVAL;
if (flags == 0) {
flags = fops->mmap_setup_read ? MMAP_OVERLAY : DONT_MMAP_OVERLAY;
}
if (flags & MMAP_OVERLAY && flags & DONT_MMAP_OVERLAY)
return -EINVAL;
if (flags == MMAP_OVERLAY) {
ASSERT(fops->mmap_setup_read);
ASSERT(fops->remmap_blk_read);
}
if (flags == DONT_MMAP_OVERLAY) {
ASSERT(fops->loadblk);
}
sigsegv_block(&save_sigset); sigsegv_block(&save_sigset);
virt_lock(); virt_lock();
...@@ -167,8 +183,7 @@ int fileh_open(BigFileH *fileh, BigFile *file, RAM *ram) ...@@ -167,8 +183,7 @@ int fileh_open(BigFileH *fileh, BigFile *file, RAM *ram)
fileh->writeout_inprogress = 0; fileh->writeout_inprogress = 0;
pagemap_init(&fileh->pagemap, ilog2_exact(ram->pagesize)); pagemap_init(&fileh->pagemap, ilog2_exact(ram->pagesize));
// XXX hardcoded - allow user choice? fileh->mmap_overlay = (flags == MMAP_OVERLAY);
fileh->mmap_overlay = (file->file_ops->mmap_setup_read != NULL);
out: out:
virt_unlock(); virt_unlock();
......
...@@ -156,19 +156,34 @@ struct VMA { ...@@ -156,19 +156,34 @@ struct VMA {
* API for clients * * API for clients *
*****************************/ *****************************/
/* flags for fileh_open */
enum FileHOpenFlags {
/* use "mmap overlay" mode for base file data of all mappings created
* for this fileh.
*
* The file must have .mmap_setup_read & friends != NULL in file_ops.
*/
MMAP_OVERLAY = 1 << 0,
/* don't use "mmap overlay" mode */
DONT_MMAP_OVERLAY = 1 << 1,
/* NOTE: if both MMAP_OVERLAY and DONT_MMAP_OVERLAY are not given,
* the behaviour is to use mmap overlay if .mmap_* fops != NULL and
* regular loads otherwise. */
};
typedef enum FileHOpenFlags FileHOpenFlags;
/* open handle for a BigFile /* open handle for a BigFile
* *
* @fileh[out] BigFileH handle to initialize for this open * @fileh[out] BigFileH handle to initialize for this open
* @file * @file
* @ram RAM that will back created fileh mappings * @ram RAM that will back created fileh mappings
* @flags flags for this open - see FileHOpenFlags
* *
* @return 0 - ok, !0 - fail * @return 0 - ok, !0 - fail
*/ */
int fileh_open(BigFileH *fileh, BigFile *file, RAM *ram); int fileh_open(BigFileH *fileh, BigFile *file, RAM *ram, FileHOpenFlags flags);
// XXX + fileh_open_overlay(fileh, file, base, ram) ?
// here base is glued data from head/bigfile/file + revX/bigfile/file overwrites.
// file will be used only to storeblk (loadblk=BUG).
/* close fileh /* close fileh
......
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