mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Report ramdiskfs usage correctly
Updates #1035 PiperOrigin-RevId: 404072231
This commit is contained in:
committed by
gVisor bot
parent
832c309ce9
commit
fa56fbf44e
@@ -95,7 +95,7 @@ type regularFile struct {
|
||||
func (fs *filesystem) newRegularFile(kuid auth.KUID, kgid auth.KGID, mode linux.FileMode, parentDir *directory) *inode {
|
||||
file := ®ularFile{
|
||||
memFile: fs.mfp.MemoryFile(),
|
||||
memoryUsageKind: usage.Tmpfs,
|
||||
memoryUsageKind: fs.usage,
|
||||
seals: linux.F_SEAL_SEAL,
|
||||
}
|
||||
file.inode.init(file, fs, kuid, kgid, linux.S_IFREG|mode, parentDir)
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel/auth"
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel/time"
|
||||
"gvisor.dev/gvisor/pkg/sentry/pgalloc"
|
||||
"gvisor.dev/gvisor/pkg/sentry/usage"
|
||||
"gvisor.dev/gvisor/pkg/sentry/vfs"
|
||||
"gvisor.dev/gvisor/pkg/sentry/vfs/memxattr"
|
||||
"gvisor.dev/gvisor/pkg/sync"
|
||||
@@ -74,6 +75,10 @@ type filesystem struct {
|
||||
// filesystem. Immutable.
|
||||
mopts string
|
||||
|
||||
// usage is the memory accounting category under which pages backing
|
||||
// files in this filesystem are accounted.
|
||||
usage usage.MemoryKind
|
||||
|
||||
// mu serializes changes to the Dentry tree.
|
||||
mu sync.RWMutex `state:"nosave"`
|
||||
|
||||
@@ -106,6 +111,10 @@ type FilesystemOpts struct {
|
||||
// tmpfs filesystem. This allows tmpfs to "impersonate" other
|
||||
// filesystems, like ramdiskfs and cgroupfs.
|
||||
FilesystemType vfs.FilesystemType
|
||||
|
||||
// Usage is the memory accounting category under which pages backing files in
|
||||
// the filesystem are accounted.
|
||||
Usage *usage.MemoryKind
|
||||
}
|
||||
|
||||
// GetFilesystem implements vfs.FilesystemType.GetFilesystem.
|
||||
@@ -184,11 +193,16 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt
|
||||
return nil, nil, err
|
||||
}
|
||||
clock := time.RealtimeClockFromContext(ctx)
|
||||
memUsage := usage.Tmpfs
|
||||
if tmpfsOpts.Usage != nil {
|
||||
memUsage = *tmpfsOpts.Usage
|
||||
}
|
||||
fs := filesystem{
|
||||
mfp: mfp,
|
||||
clock: clock,
|
||||
devMinor: devMinor,
|
||||
mopts: opts.Data,
|
||||
usage: memUsage,
|
||||
}
|
||||
fs.vfsfs.Init(vfsObj, newFSType, &fs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user