diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-02-01 17:50:32 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-02-01 17:51:48 -0800 |
commit | 2d20b121d710fda3ad3382b66cd6c936e20a1119 (patch) | |
tree | 04f51106fe354275dc151a188550c2fd1ad1f36a /pkg/sentry/fs/gofer/inode.go | |
parent | 92e85623a0cd7b2043a79b757e1874a67796dea9 (diff) |
CachingInodeOperations was over-dirtying cached attributes
Dirty should be set only when the attribute is changed in the cache
only. Instances where the change was also sent to the backing file
doesn't need to dirty the attribute.
Also remove size update during WriteOut as writing dirty page would
naturaly grow the file if needed.
RELNOTES: relnotes is needed for the parent CL.
PiperOrigin-RevId: 232068978
Change-Id: I00ba54693a2c7adc06efa9e030faf8f2e8e7f188
Diffstat (limited to 'pkg/sentry/fs/gofer/inode.go')
-rw-r--r-- | pkg/sentry/fs/gofer/inode.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pkg/sentry/fs/gofer/inode.go b/pkg/sentry/fs/gofer/inode.go index 1dc0ca0db..16435169a 100644 --- a/pkg/sentry/fs/gofer/inode.go +++ b/pkg/sentry/fs/gofer/inode.go @@ -247,6 +247,7 @@ func (i *inodeFileState) SetMaskedAttributes(ctx context.Context, mask fs.AttrMa // skipSetAttr checks if attribute change can be skipped. It can be skipped // when: // - Mask is empty +// - Mask contains only attributes that cannot be set in the gofer // - Mask contains only atime and/or mtime, and host FD exists // // Updates to atime and mtime can be skipped because cached value will be @@ -254,15 +255,22 @@ func (i *inodeFileState) SetMaskedAttributes(ctx context.Context, mask fs.AttrMa // Skipping atime updates is particularly important to reduce the number of // operations sent to the Gofer for readonly files. func (i *inodeFileState) skipSetAttr(mask fs.AttrMask) bool { - if mask.Empty() { + // First remove attributes that cannot be updated. + cpy := mask + cpy.Type = false + cpy.DeviceID = false + cpy.InodeID = false + cpy.BlockSize = false + cpy.Usage = false + cpy.Links = false + if cpy.Empty() { return true } - cpy := mask + // Then check if more than just atime and mtime is being set. cpy.AccessTime = false cpy.ModificationTime = false if !cpy.Empty() { - // More than just atime and mtime is being set. return false } |