mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user