From 2bc398bfd8fbe38776a512329bd0c40c9c7a5cdf Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Wed, 17 Jul 2019 15:48:33 -0700 Subject: Separate O_DSYNC and O_SYNC. PiperOrigin-RevId: 258657913 --- pkg/sentry/fs/flags.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pkg/sentry/fs') diff --git a/pkg/sentry/fs/flags.go b/pkg/sentry/fs/flags.go index 1278f9c78..0fab876a9 100644 --- a/pkg/sentry/fs/flags.go +++ b/pkg/sentry/fs/flags.go @@ -28,7 +28,11 @@ type FileFlags struct { // NonBlocking indicates that I/O should not block. NonBlocking bool - // Sync indicates that any writes should be synchronous. + // DSync indicates that each write will flush data and metadata required to + // read the file's contents. + DSync bool + + // Sync indicates that each write will flush data and all file metadata. Sync bool // Append indicates this file is append only. @@ -96,6 +100,9 @@ func (f FileFlags) ToLinux() (mask uint) { if f.NonBlocking { mask |= linux.O_NONBLOCK } + if f.DSync { + mask |= linux.O_DSYNC + } if f.Sync { mask |= linux.O_SYNC } -- cgit v1.2.3 From 6f7e2bb388cb29a355dece8921671c0085f53ea9 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 17 Jul 2019 16:10:44 -0700 Subject: Take copyMu in Revalidate copyMu is required to read child.overlay.upper. PiperOrigin-RevId: 258662209 --- pkg/sentry/fs/mount_overlay.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'pkg/sentry/fs') diff --git a/pkg/sentry/fs/mount_overlay.go b/pkg/sentry/fs/mount_overlay.go index 4fcdd6c01..299712cd7 100644 --- a/pkg/sentry/fs/mount_overlay.go +++ b/pkg/sentry/fs/mount_overlay.go @@ -66,13 +66,17 @@ func (o *overlayMountSourceOperations) Revalidate(ctx context.Context, name stri panic("an overlay cannot revalidate file objects from the lower fs") } - // Do we have anything to revalidate? - if child.overlay.upper == nil { - return false + var revalidate bool + child.overlay.copyMu.RLock() + if child.overlay.upper != nil { + // Does the upper require revalidation? + revalidate = o.upper.Revalidate(ctx, name, parent.overlay.upper, child.overlay.upper) + } else { + // Nothing to revalidate. + revalidate = false } - - // Does the upper require revalidation? - return o.upper.Revalidate(ctx, name, parent.overlay.upper, child.overlay.upper) + child.overlay.copyMu.RUnlock() + return revalidate } // Keep implements MountSourceOperations by delegating to the upper -- cgit v1.2.3