Commit e7b77669 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9836eede
......@@ -1125,6 +1125,7 @@ struct BigFileMMap {
BigFile;
int fd; /* fd of file to mmap */
int nstoreblk; /* number of times storeblk called */
int nmunmap; /* ----//---- munmap called */
};
typedef struct BigFileMMap BigFileMMap;
......@@ -1184,11 +1185,20 @@ int mmapfile_remmap_blk_read(BigFile *file, blk_t blk, VMA *vma) {
return 0;
}
void mmapfile_munmap(BigFile *file, VMA *vma) {
BigFileMMap *f = upcast(BigFileMMap*, file);
size_t len = vma->addr_stop - vma->addr_start;
f->nmunmap++;
xmunmap((void *)vma->addr_start, len);
}
static const struct bigfile_ops mmapfile_ops = {
.loadblk = NULL,
.storeblk = mmapfile_storeblk,
.mmap_setup_read = mmapfile_mmap_setup_read,
.remmap_blk_read = mmapfile_remmap_blk_read,
.storeblk = mmapfile_storeblk,
.munmap = mmapfile_munmap,
.release = mmapfile_release,
};
......@@ -1233,6 +1243,7 @@ void test_file_access_mmapbase(void)
.file_ops = &mmapfile_ops,
.fd = fd,
.nstoreblk = 0,
.nmunmap = 0,
};
/* fstore stores data into file[blk] */
......@@ -1609,7 +1620,10 @@ void test_file_access_mmapbase(void)
/* free resources */
file.nmunmap = 0;
vma_unmap(vma);
ok1(file.nmunmap == 1);
fileh_close(fh);
ram_close(ram);
free(ram);
......
......@@ -322,8 +322,11 @@ void vma_unmap(VMA *vma)
/* unmap whole vma at once - the kernel unmaps each mapping in turn.
* NOTE error here would mean something is broken */
// XXX overlay: -> notify_unmap
if (fileh->mmap_overlay) {
fileh->file->file_ops->munmap(fileh->file, vma);
} else {
xmunmap((void *)vma->addr_start, len);
}
/* scan through mapped-to-this-vma pages and release them */
for (i=0; i < pglen; ++i) {
......
......@@ -102,6 +102,13 @@ struct bigfile_ops {
// XXX error -> bug (must not fail)
int (*remmap_blk_read) (BigFile *file, blk_t, VMA *vma);
/* munmap is called when vma set up via mmap_setup_read is going to be unmapped.
*
* XXX called under virtmem lock?
* Must not fail.
*/
void (*munmap) (BigFile *file, VMA *vma);
......
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