summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/gofer/time.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-08-25 00:24:16 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-25 00:26:06 -0700
commitc61f6fcf6ab3178da3a297d3e3199379b188ce61 (patch)
tree392d0b82cc72125da55d78157b2641871f297e13 /pkg/sentry/fsimpl/gofer/time.go
parentf1821fdb6866e0d83cdf535e0bae349d1c1c237c (diff)
Fix deadlock in gofer direct IO.
Fixes several java runtime tests: java/nio/channels/FileChannel/directio/ReadDirect.java java/nio/channels/FileChannel/directio/PreadDirect.java Updates #3576. PiperOrigin-RevId: 328281849
Diffstat (limited to 'pkg/sentry/fsimpl/gofer/time.go')
-rw-r--r--pkg/sentry/fsimpl/gofer/time.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/sentry/fsimpl/gofer/time.go b/pkg/sentry/fsimpl/gofer/time.go
index 98733253d..7e825caae 100644
--- a/pkg/sentry/fsimpl/gofer/time.go
+++ b/pkg/sentry/fsimpl/gofer/time.go
@@ -52,6 +52,20 @@ func (d *dentry) touchAtime(mnt *vfs.Mount) {
mnt.EndWrite()
}
+// Preconditions: d.metadataMu is locked. d.cachedMetadataAuthoritative() == true.
+func (d *dentry) touchAtimeLocked(mnt *vfs.Mount) {
+ if mnt.Flags.NoATime || mnt.ReadOnly() {
+ return
+ }
+ if err := mnt.CheckBeginWrite(); err != nil {
+ return
+ }
+ now := d.fs.clock.Now().Nanoseconds()
+ atomic.StoreInt64(&d.atime, now)
+ atomic.StoreUint32(&d.atimeDirty, 1)
+ mnt.EndWrite()
+}
+
// Preconditions:
// * d.cachedMetadataAuthoritative() == true.
// * The caller has successfully called vfs.Mount.CheckBeginWrite().