Update comments about tmpfs size.

- Removed old TODO from VFS1. We will not support this option on VFS1.
- Enhanced comments about how tmpfs pages are accounted for by write(2)s.

PiperOrigin-RevId: 446072121
This commit is contained in:
Ayush Ranjan
2022-05-02 17:39:26 -07:00
committed by gVisor bot
parent 4ee0a226fe
commit ea45573148
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ var fsInfo = fs.Info{
// of 0. To work around this, claim to have a very large but non-zero size,
// chosen to ensure that BlockSize * Blocks does not overflow int64 (which
// applications may also handle incorrectly).
// TODO(b/29637826): allow configuring a tmpfs size and enforce it.
// NOTE(b/29637826): Support for configurable tmpfs size was added to VFS2.
TotalBlocks: math.MaxInt64 / hostarch.PageSize,
FreeBlocks: math.MaxInt64 / hostarch.PageSize,
}
+9 -1
View File
@@ -453,6 +453,10 @@ func (fd *regularFileFD) pwrite(ctx context.Context, src usermem.IOSequence, off
if err != nil {
return 0, offset, err
}
// Reserve enough space assuming the entire write was successful. The
// corresponding update to f.size is done in WriteFromBlocks() which is
// called via src.CopyInTo() below.
maybeSizeInc := false
src = src.TakeFirst64(srclen)
if uint64(end) > f.size.Load() {
@@ -461,9 +465,13 @@ func (fd *regularFileFD) pwrite(ctx context.Context, src usermem.IOSequence, off
return 0, 0, err
}
}
// Perform the write.
rw := getRegularFileReadWriter(f, offset)
n, err := src.CopyInTo(ctx, rw)
if unwritten := srclen - n; maybeSizeInc && unwritten != 0 {
// Correct page accounting if this was a partial write.
if maybeSizeInc && srclen-n != 0 {
if err := f.inode.fs.updatePagesUsed(uint64(end), f.size.Load()); err != nil {
return 0, 0, err
}