From c61f6fcf6ab3178da3a297d3e3199379b188ce61 Mon Sep 17 00:00:00 2001 From: Dean Deng Date: Tue, 25 Aug 2020 00:24:16 -0700 Subject: 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 --- pkg/sentry/fsimpl/gofer/time.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pkg/sentry/fsimpl/gofer/time.go') 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(). -- cgit v1.2.3