mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Make tmpfs respect MountNoATime now that fs.Handle is gone.
PiperOrigin-RevId: 236752802 Change-Id: I9e50600b2ae25d5f2ac632c4405a7a185bdc3c92
This commit is contained in:
committed by
Shentubot
parent
662da3350c
commit
0d683c9961
@@ -44,7 +44,7 @@ type regularFileOperations struct {
|
||||
|
||||
// Read implements fs.FileOperations.Read.
|
||||
func (r *regularFileOperations) Read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error) {
|
||||
return r.iops.read(ctx, dst, offset)
|
||||
return r.iops.read(ctx, file, dst, offset)
|
||||
}
|
||||
|
||||
// Write implements fs.FileOperations.Write.
|
||||
|
||||
@@ -250,7 +250,7 @@ func (*fileInodeOperations) StatFS(context.Context) (fs.Info, error) {
|
||||
return fsInfo, nil
|
||||
}
|
||||
|
||||
func (f *fileInodeOperations) read(ctx context.Context, dst usermem.IOSequence, offset int64) (int64, error) {
|
||||
func (f *fileInodeOperations) read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error) {
|
||||
var start time.Time
|
||||
if fs.RecordWaitTime {
|
||||
start = time.Now()
|
||||
@@ -280,10 +280,12 @@ func (f *fileInodeOperations) read(ctx context.Context, dst usermem.IOSequence,
|
||||
}
|
||||
|
||||
n, err := dst.CopyOutFrom(ctx, &fileReadWriter{f, offset})
|
||||
// Compare Linux's mm/filemap.c:do_generic_file_read() => file_accessed().
|
||||
f.attrMu.Lock()
|
||||
f.attr.AccessTime = ktime.NowFromContext(ctx)
|
||||
f.attrMu.Unlock()
|
||||
if !file.Dirent.Inode.MountSource.Flags.NoAtime {
|
||||
// Compare Linux's mm/filemap.c:do_generic_file_read() => file_accessed().
|
||||
f.attrMu.Lock()
|
||||
f.attr.AccessTime = ktime.NowFromContext(ctx)
|
||||
f.attrMu.Unlock()
|
||||
}
|
||||
fs.IncrementWait(readWait, start)
|
||||
return n, err
|
||||
}
|
||||
|
||||
@@ -250,9 +250,7 @@ PosixErrorOr<absl::Time> ATime(absl::string_view file) {
|
||||
return absl::TimeFromTimespec(s.st_atim);
|
||||
}
|
||||
|
||||
// FIXME: Disabled until tmpfs stops using Handle, as only the gofer
|
||||
// and host file system respect the MS_NOATIME flag.
|
||||
TEST(MountTest, DISABLED_MountNoAtime) {
|
||||
TEST(MountTest, MountNoAtime) {
|
||||
SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_ADMIN)));
|
||||
|
||||
auto const dir = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateDir());
|
||||
|
||||
Reference in New Issue
Block a user