Don't WriteOut to readonly mounts

When the file closes, it attempts to write dirty cached
attributes to the file. This should not be done when the
mount is readonly.

PiperOrigin-RevId: 315585058
This commit is contained in:
Fabricio Voznika 2020-06-09 16:34:42 -07:00 committed by gVisor bot
parent 0ae5bd24d7
commit 6722b1e56f
2 changed files with 4 additions and 1 deletions

View File

@ -640,7 +640,7 @@ func (i *inodeOperations) Allocate(ctx context.Context, inode *fs.Inode, offset,
// WriteOut implements fs.InodeOperations.WriteOut.
func (i *inodeOperations) WriteOut(ctx context.Context, inode *fs.Inode) error {
if !i.session().cachePolicy.cacheUAttrs(inode) {
if inode.MountSource.Flags.ReadOnly || !i.session().cachePolicy.cacheUAttrs(inode) {
return nil
}

View File

@ -368,6 +368,9 @@ func (i *inodeOperations) Allocate(ctx context.Context, inode *fs.Inode, offset,
// WriteOut implements fs.InodeOperations.WriteOut.
func (i *inodeOperations) WriteOut(ctx context.Context, inode *fs.Inode) error {
if inode.MountSource.Flags.ReadOnly {
return nil
}
// Have we been using host kernel metadata caches?
if !inode.MountSource.Flags.ForcePageCache || !canMap(inode) {
// Then the metadata is already up to date on the host.