summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/fs/file.go')
-rw-r--r--pkg/sentry/fs/file.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/sentry/fs/file.go b/pkg/sentry/fs/file.go
index d6752ed1b..b66d2f265 100644
--- a/pkg/sentry/fs/file.go
+++ b/pkg/sentry/fs/file.go
@@ -21,6 +21,7 @@ import (
"gvisor.googlesource.com/gvisor/pkg/amutex"
"gvisor.googlesource.com/gvisor/pkg/log"
+ "gvisor.googlesource.com/gvisor/pkg/metric"
"gvisor.googlesource.com/gvisor/pkg/refs"
"gvisor.googlesource.com/gvisor/pkg/sentry/context"
"gvisor.googlesource.com/gvisor/pkg/sentry/fs/lock"
@@ -32,6 +33,8 @@ import (
"gvisor.googlesource.com/gvisor/pkg/waiter"
)
+var reads = metric.MustCreateNewUint64Metric("/fs/reads", false /* sync */, "Number of file reads.")
+
// FileMaxOffset is the maximum possible file offset.
const FileMaxOffset = math.MaxInt64
@@ -237,6 +240,7 @@ func (f *File) Readv(ctx context.Context, dst usermem.IOSequence) (int64, error)
return 0, syserror.ErrInterrupted
}
+ reads.Increment()
n, err := f.FileOperations.Read(ctx, f, dst, f.offset)
if n > 0 {
atomic.AddInt64(&f.offset, n)
@@ -255,6 +259,7 @@ func (f *File) Preadv(ctx context.Context, dst usermem.IOSequence, offset int64)
return 0, syserror.ErrInterrupted
}
+ reads.Increment()
n, err := f.FileOperations.Read(ctx, f, dst, offset)
f.mu.Unlock()
return n, err