Commit 10db71c2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 03aa7ebd
...@@ -39,8 +39,7 @@ static int zfile_mmap_setup_read(VMA *vma, BigFile *file, blk_t blk, size_t blkl ...@@ -39,8 +39,7 @@ static int zfile_mmap_setup_read(VMA *vma, BigFile *file, blk_t blk, size_t blkl
tie(mmap, err) = fileh->mmap(blk, blklen, vma); tie(mmap, err) = fileh->mmap(blk, blklen, vma);
if (err != nil) { if (err != nil) {
// XXX no way to return error details to virtmem log::Errorf("%s", v(err)); // XXX no way to return error details to virtmem
log::Errorf("%s: mmap_setup_read #[%d +%d): %s", v(fileh), blk, blklen, v(err));
return -1; return -1;
} }
...@@ -56,13 +55,16 @@ static int zfile_remmap_blk_read(VMA *vma, BigFile *file, blk_t blk) { ...@@ -56,13 +55,16 @@ static int zfile_remmap_blk_read(VMA *vma, BigFile *file, blk_t blk) {
error err; error err;
err = mmap->remmap_blk(blk); err = mmap->remmap_blk(blk);
if (err != nil) if (err != nil) {
panic(v(err)); // XXX log::Errorf("%s", v(err)); // XXX no way to return error details to virtmem
return -1;
}
return 0; return 0;
} }
static void zfile_munmap(VMA *vma, BigFile *file) { static int zfile_munmap(VMA *vma, BigFile *file) {
wcfs::_Mapping* mmap = static_cast<wcfs::_Mapping*>(vma->mmap_overlay_server); wcfs::_Mapping* mmap = static_cast<wcfs::_Mapping*>(vma->mmap_overlay_server);
_ZBigFile* _zfile = container_of(file, _ZBigFile, __pyx_base.file); _ZBigFile* _zfile = container_of(file, _ZBigFile, __pyx_base.file);
...@@ -71,8 +73,12 @@ static void zfile_munmap(VMA *vma, BigFile *file) { ...@@ -71,8 +73,12 @@ static void zfile_munmap(VMA *vma, BigFile *file) {
error err; error err;
err = mmap->unmap(); err = mmap->unmap();
if (err != nil) if (err != nil) {
panic(v(err)); // XXX log::Errorf("%s", v(err)); // XXX no way to return error details to virtmem
return -1;
}
return 0;
} }
......
...@@ -1191,12 +1191,13 @@ int mmapfile_remmap_blk_read(VMA *vma, BigFile *file, blk_t blk) { ...@@ -1191,12 +1191,13 @@ int mmapfile_remmap_blk_read(VMA *vma, BigFile *file, blk_t blk) {
return 0; return 0;
} }
void mmapfile_munmap(VMA *vma, BigFile *file) { int mmapfile_munmap(VMA *vma, BigFile *file) {
BigFileMMap *f = upcast(BigFileMMap*, file); BigFileMMap *f = upcast(BigFileMMap*, file);
size_t len = vma->addr_stop - vma->addr_start; size_t len = vma->addr_stop - vma->addr_start;
f->nmunmap++; f->nmunmap++;
xmunmap((void *)vma->addr_start, len); xmunmap((void *)vma->addr_start, len);
return 0;
} }
static const struct bigfile_ops mmapfile_ops = { static const struct bigfile_ops mmapfile_ops = {
......
...@@ -337,7 +337,8 @@ void vma_unmap(VMA *vma) ...@@ -337,7 +337,8 @@ void vma_unmap(VMA *vma)
/* unmap whole vma at once - the kernel unmaps each mapping in turn. /* unmap whole vma at once - the kernel unmaps each mapping in turn.
* NOTE error here would mean something is broken */ * NOTE error here would mean something is broken */
if (fileh->mmap_overlay) { if (fileh->mmap_overlay) {
fileh->file->file_ops->munmap(vma, fileh->file); int err = fileh->file->file_ops->munmap(vma, fileh->file);
BUG_ON(err);
} else { } else {
xmunmap((void *)vma->addr_start, len); xmunmap((void *)vma->addr_start, len);
} }
......
...@@ -157,17 +157,16 @@ struct bigfile_ops { ...@@ -157,17 +157,16 @@ struct bigfile_ops {
* RW dirty page was discarded. * RW dirty page was discarded.
* *
* Called under virtmem lock. XXX hard to rework to call with !virt_lock * Called under virtmem lock. XXX hard to rework to call with !virt_lock
* * Virtmem considers remmap_blk_read failure as fatal.
* XXX error -> bug (must not fail)
*/ */
int (*remmap_blk_read) (VMA *vma, BigFile *file, blk_t blk); int (*remmap_blk_read) (VMA *vma, BigFile *file, blk_t blk);
/* munmap is called when vma set up via mmap_setup_read is going to be unmapped. /* munmap is called when vma set up via mmap_setup_read is going to be unmapped.
* *
* Called under virtmem lock. TODO easy to rework to call with !virt_lock * Called under virtmem lock. TODO easy to rework to call with !virt_lock
* Must not fail. * Virtmem considers munmap failure as fatal.
*/ */
void (*munmap) (VMA *vma, BigFile *file); int (*munmap) (VMA *vma, BigFile *file);
}; };
typedef struct bigfile_ops bigfile_ops; typedef struct bigfile_ops bigfile_ops;
......
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