summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/gofer/file.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-01-25 17:22:04 -0800
committerShentubot <shentubot@google.com>2019-01-25 17:23:07 -0800
commit55e8eb775b422a7485d6d1dc4f8e4c8fd32096da (patch)
tree7dff5a374ff29f6bffb3c543c0a37b1657f36ea0 /pkg/sentry/fs/gofer/file.go
parentc6facd0358ae61849786dbbc0f4f5a07a25cb6f1 (diff)
Make cacheRemoteRevalidating detect changes to file size
When file size changes outside the sandbox, page cache was not refreshing file size which is required for cacheRemoteRevalidating. In fact, cacheRemoteRevalidating should be skipping the cache completely since it's not really benefiting from it. The cache is cache is already bypassed for unstable attributes (see cachePolicy.cacheUAttrs). And althought the cache is called to map pages, they will always miss the cache and map directly from the host. Created a HostMappable struct that maps directly to the host and use it for files with cacheRemoteRevalidating. Closes #124 PiperOrigin-RevId: 230998440 Change-Id: Ic5f632eabe33b47241e05e98c95e9b2090ae08fc
Diffstat (limited to 'pkg/sentry/fs/gofer/file.go')
-rw-r--r--pkg/sentry/fs/gofer/file.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/pkg/sentry/fs/gofer/file.go b/pkg/sentry/fs/gofer/file.go
index 3578b07a0..2181ddc68 100644
--- a/pkg/sentry/fs/gofer/file.go
+++ b/pkg/sentry/fs/gofer/file.go
@@ -204,7 +204,7 @@ func (f *fileOperations) Write(ctx context.Context, file *fs.File, src usermem.I
return 0, syserror.EISDIR
}
cp := f.inodeOperations.session().cachePolicy
- if cp.usePageCache(file.Dirent.Inode) {
+ if cp.useCachingInodeOps(file.Dirent.Inode) {
n, err := f.inodeOperations.cachingInodeOps.Write(ctx, src, offset)
if err != nil {
return n, err
@@ -225,7 +225,7 @@ func (f *fileOperations) Read(ctx context.Context, file *fs.File, dst usermem.IO
return 0, syserror.EISDIR
}
- if f.inodeOperations.session().cachePolicy.usePageCache(file.Dirent.Inode) {
+ if f.inodeOperations.session().cachePolicy.useCachingInodeOps(file.Dirent.Inode) {
return f.inodeOperations.cachingInodeOps.Read(ctx, file, dst, offset)
}
return dst.CopyOutFrom(ctx, f.handles.readWriterAt(ctx, offset))
@@ -267,10 +267,7 @@ func (f *fileOperations) Flush(ctx context.Context, file *fs.File) error {
// ConfigureMMap implements fs.FileOperations.ConfigureMMap.
func (f *fileOperations) ConfigureMMap(ctx context.Context, file *fs.File, opts *memmap.MMapOpts) error {
- if !f.inodeOperations.session().cachePolicy.usePageCache(file.Dirent.Inode) {
- return syserror.ENODEV
- }
- return fsutil.GenericConfigureMMap(file, f.inodeOperations.cachingInodeOps, opts)
+ return f.inodeOperations.configureMMap(file, opts)
}
// Seek implements fs.FileOperations.Seek.