Update cached file size when cache is skipped

gofer.dentryReadWriter.WriteFromBlocks was not updating
gofer.dentry.size after a write operation that skips the
cache.

Updates #1198

PiperOrigin-RevId: 298708646
This commit is contained in:
Fabricio Voznika
2020-03-03 15:29:13 -08:00
committed by gVisor bot
parent 371abe00f0
commit 122d47aed1
+8 -1
View File
@@ -361,8 +361,15 @@ func (rw *dentryReadWriter) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, erro
rw.d.handleMu.RLock()
if (rw.d.handle.fd >= 0 && !rw.d.fs.opts.forcePageCache) || rw.d.fs.opts.interop == InteropModeShared || rw.direct {
n, err := rw.d.handle.writeFromBlocksAt(rw.ctx, srcs, rw.off)
rw.d.handleMu.RUnlock()
rw.off += n
rw.d.dataMu.Lock()
if rw.off > rw.d.size {
atomic.StoreUint64(&rw.d.size, rw.off)
// The remote file's size will implicitly be extended to the correct
// value when we write back to it.
}
rw.d.dataMu.Unlock()
rw.d.handleMu.RUnlock()
return n, err
}