mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
fs/tmpfs: change regularFile.size atomically
PiperOrigin-RevId: 342221309
This commit is contained in:
@@ -565,7 +565,7 @@ func (rw *regularFileReadWriter) ReadToBlocks(dsts safemem.BlockSeq) (uint64, er
|
||||
|
||||
// WriteFromBlocks implements safemem.Writer.WriteFromBlocks.
|
||||
//
|
||||
// Preconditions: inode.mu must be held.
|
||||
// Preconditions: rw.file.inode.mu must be held.
|
||||
func (rw *regularFileReadWriter) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, error) {
|
||||
// Hold dataMu so we can modify size.
|
||||
rw.file.dataMu.Lock()
|
||||
@@ -657,7 +657,7 @@ exitLoop:
|
||||
// If the write ends beyond the file's previous size, it causes the
|
||||
// file to grow.
|
||||
if rw.off > rw.file.size {
|
||||
rw.file.size = rw.off
|
||||
atomic.StoreUint64(&rw.file.size, rw.off)
|
||||
}
|
||||
|
||||
return done, retErr
|
||||
|
||||
Reference in New Issue
Block a user