Skip to content

Commit 9d559a2

Browse files
kavehahmadi60facebook-github-bot
authored andcommitted
add some logs for updating inode atime
Summary: inode atime is not accurate on macOS. NFS GC use atime for invalidation and only invalidate inodes if its atime is less than a cutoff. However, I found some conditions that inodes get invalidates which they are recently accessed. It means that we don't update atime correctly on NFS. I add some logs to the InodeBase and GC to find out when we skip updating atime. Reviewed By: taidaii Differential Revision: D75720812 fbshipit-source-id: 45d372b48ad01257e4d5b84de67655f74addf81b
1 parent 7d32bf7 commit 9d559a2

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

eden/fs/inodes/InodeBase.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,22 @@ InodeBase::InodeBase(
6060
#ifndef _WIN32
6161
mount_->getInodeMetadataTable()->populateIfNotSet(ino_, [&] {
6262
auto metadata = mount_->getInitialInodeMetadata(initialMode);
63+
auto now = getNow();
6364
if (initialTimestamps) {
6465
metadata.timestamps = *initialTimestamps;
66+
XLOGF(
67+
DBG9,
68+
"Setting initial timestamps for inode {} atime: {} while now time: {}",
69+
ino_,
70+
metadata.timestamps.atime.toTimespec().tv_sec,
71+
now.toTimespec().tv_sec);
72+
} else {
73+
XLOGF(
74+
DBG9,
75+
"Initial timestamps was NULL for inode {} then the atime remains unchanged. atime: {} while now time: {}",
76+
ino_,
77+
metadata.timestamps.atime.toTimespec().tv_sec,
78+
now.toTimespec().tv_sec);
6579
}
6680
return metadata;
6781
});
@@ -357,6 +371,11 @@ void InodeBase::updateAtime() {
357371
auto now = getNow();
358372
getMount()->getInodeMetadataTable()->modifyOrThrow(
359373
getNodeId(), [&](auto& metadata) { metadata.timestamps.atime = now; });
374+
XLOGF(
375+
DBG9,
376+
"Updated atime for inode {} to now: {}",
377+
ino_,
378+
now.toTimespec().tv_sec);
360379
#endif
361380
}
362381

eden/fs/inodes/TreeInode.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,6 +3973,14 @@ folly::Try<folly::Unit> TreeInode::nfsInvalidateCacheEntryForGC(
39733973
for (auto& entry : state.entries) {
39743974
auto ino = entry.second.getInodeNumber();
39753975
if (inodeMap->isInodeLoadedOrRemembered(ino)) {
3976+
XLOGF(
3977+
DBG5,
3978+
"GC invalidated inode {} with atime: {}",
3979+
ino,
3980+
entry.second.getInode()
3981+
->getMetadata()
3982+
.timestamps.atime.toTimespec()
3983+
.tv_sec);
39763984
inodeMap->decFsRefcount(ino);
39773985
}
39783986
}
@@ -4449,6 +4457,15 @@ ImmediateFuture<uint64_t> TreeInode::invalidateChildrenNotMaterialized(
44494457
.timestamps.atime.toTimespec()
44504458
.tv_sec);
44514459
shouldInvalidate = (atime < cutoff);
4460+
XLOGF(
4461+
DBG5,
4462+
"For path: {}, atime: {}, cutoff: {}, shouldInvalidate by GC is {}",
4463+
self->getPath().value().asString(),
4464+
self->getMetadataLocked(contents->entries)
4465+
.timestamps.atime.toTimespec()
4466+
.tv_sec,
4467+
cutoff.time_since_epoch().count(),
4468+
shouldInvalidate);
44524469
}
44534470
if (shouldInvalidate) {
44544471
// Attempt to invalidate the directory, and then delete all of its

0 commit comments

Comments
 (0)