libfsdriver: clear VM cache only if used
As part of its built-in mmap emulation support for "none" file system services, libfsdriver clears the VM cache upon exit. However, for trivial file systems which do not even support reading from files, the the VM cache need to be cleared either. With this patch, the VM cache is cleared only when modified, so that such trivial file systems need not be given CLEARCACHE permission. Change-Id: I518c092443455302b9b9728f10a3f894d2c8036b
This commit is contained in:
parent
3f30eb69f0
commit
0a2a08739e
1 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,8 @@
|
||||||
#include <minix/ds.h>
|
#include <minix/ds.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
static int fsdriver_vmcache; /* have we used the VM cache? */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process a READSUPER request from VFS.
|
* Process a READSUPER request from VFS.
|
||||||
*/
|
*/
|
||||||
|
@ -59,6 +61,7 @@ fsdriver_readsuper(const struct fsdriver * __restrict fdp,
|
||||||
fsdriver_mounted = TRUE;
|
fsdriver_mounted = TRUE;
|
||||||
fsdriver_device = dev;
|
fsdriver_device = dev;
|
||||||
fsdriver_root = root_node.fn_ino_nr;
|
fsdriver_root = root_node.fn_ino_nr;
|
||||||
|
fsdriver_vmcache = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
@ -77,7 +80,7 @@ fsdriver_unmount(const struct fsdriver * __restrict fdp,
|
||||||
fdp->fdr_unmount();
|
fdp->fdr_unmount();
|
||||||
|
|
||||||
/* If we used mmap emulation, clear any cached blocks from VM. */
|
/* If we used mmap emulation, clear any cached blocks from VM. */
|
||||||
if (fdp->fdr_peek == NULL && major(fsdriver_device) == NONE_MAJOR)
|
if (fsdriver_vmcache)
|
||||||
vm_clear_cache(fsdriver_device);
|
vm_clear_cache(fsdriver_device);
|
||||||
|
|
||||||
/* Update library-local state. */
|
/* Update library-local state. */
|
||||||
|
@ -256,6 +259,8 @@ builtin_peek(const struct fsdriver * __restrict fdp, ino_t ino_nr,
|
||||||
pos, &flags, nbytes, VMSF_ONCE);
|
pos, &flags, nbytes, VMSF_ONCE);
|
||||||
|
|
||||||
if (r == OK) {
|
if (r == OK) {
|
||||||
|
fsdriver_vmcache = TRUE;
|
||||||
|
|
||||||
dev_off += nbytes;
|
dev_off += nbytes;
|
||||||
|
|
||||||
r = nbytes;
|
r = nbytes;
|
||||||
|
|
Loading…
Reference in a new issue