summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/file.go
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2019-02-13 12:06:20 -0800
committerShentubot <shentubot@google.com>2019-02-13 12:07:34 -0800
commit7aaa6cf22594cfc7eff2070191c0077bfd58046a (patch)
treef67f13952444ba3f66ca61e7c5be2c672e03aa48 /pkg/sentry/fs/file.go
parent2c7488454e7fcbf98c00bcdceb70cb8e2fa98c96 (diff)
Internal change.
PiperOrigin-RevId: 233802562 Change-Id: I40e1b13fd571daaf241b00f8df4bcedd034dc3f1
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