make mkdir explicit about kernel cache invalidation

Summary:
Avoid the cost of dynamically querying whether we are in a FUSE
request handler or not by passing a flag.

Reviewed By: kmancini

Differential Revision: D22710452

fbshipit-source-id: 818035b72b793fa895147d9df3bb668d5b9c55f3
This commit is contained in:
Chad Austin 2020-07-28 14:44:56 -07:00 committed by Facebook GitHub Bot
parent bfbd3bbb8e
commit 7cdb962d1d
6 changed files with 20 additions and 10 deletions

View File

@ -346,7 +346,7 @@ folly::Future<fuse_entry_out> EdenDispatcher::mkdir(
mode);
return inodeMap_->lookupTreeInode(parent).thenValue(
[childName = PathComponent{name}, mode](const TreeInodePtr& inode) {
auto child = inode->mkdir(childName, mode);
auto child = inode->mkdir(childName, mode, InvalidationRequired::No);
return child->stat(ObjectFetchContext::getNullContext())
.thenValue([child](struct stat st) {
child->incFuseRefcount();

View File

@ -379,8 +379,10 @@ folly::Future<folly::Unit> EdenMount::setupDotEden(TreeInodePtr root) {
if (lookupResult.hasValue()) {
dotEdenInode = *lookupResult;
} else {
dotEdenInode =
getRootInode()->mkdir(PathComponentPiece{kDotEdenName}, 0755);
dotEdenInode = getRootInode()->mkdir(
PathComponentPiece{kDotEdenName},
0755,
InvalidationRequired::Yes);
}
// Make sure all of the symlinks in the .eden directory exist and
@ -1442,7 +1444,7 @@ Future<Unit> ensureDirectoryExistsHelper(
contents.unlock();
TreeInodePtr child;
try {
child = parent->mkdir(childName, S_IFDIR | 0755);
child = parent->mkdir(childName, S_IFDIR | 0755, InvalidationRequired::Yes);
} catch (std::system_error& e) {
// If two threads are racing to create the subdirectory, that's fine,
// just try again.

View File

@ -1032,7 +1032,10 @@ FileInodePtr TreeInode::mknod(
}
}
TreeInodePtr TreeInode::mkdir(PathComponentPiece name, mode_t mode) {
TreeInodePtr TreeInode::mkdir(
PathComponentPiece name,
mode_t mode,
InvalidationRequired invalidate) {
#ifndef _WIN32
if (getNodeId() == getMount()->getDotEdenInodeNumber()) {
throw InodeError(EPERM, inodePtrFromThis(), name);
@ -1102,8 +1105,10 @@ TreeInodePtr TreeInode::mkdir(PathComponentPiece name, mode_t mode) {
}
#ifndef _WIN32
invalidateFuseEntryCacheIfRequired(name);
invalidateFuseInodeCacheIfRequired();
if (InvalidationRequired::Yes == invalidate) {
invalidateChannelEntryCache(name);
invalidateFuseInodeCache();
}
#endif
getMount()->getJournal().recordCreated(targetName);

View File

@ -168,7 +168,8 @@ class TreeInode final : public InodeBaseMetadata<DirContents> {
folly::StringPiece contents,
InvalidationRequired invalidate);
TreeInodePtr mkdir(PathComponentPiece name, mode_t mode);
TreeInodePtr
mkdir(PathComponentPiece name, mode_t mode, InvalidationRequired invalidate);
FOLLY_NODISCARD folly::Future<folly::Unit> unlink(
PathComponentPiece name,
InvalidationRequired invalidate);

View File

@ -525,7 +525,9 @@ void TestMount::mkdir(folly::StringPiece path) {
#endif
mode_t mode = 0755;
(void)treeInode->mkdir(relativePath.basename(), mode).get();
(void)treeInode
->mkdir(relativePath.basename(), mode, InvalidationRequired::No)
.get();
}
void TestMount::deleteFile(folly::StringPiece path) {

View File

@ -455,7 +455,7 @@ folly::Future<folly::Unit> createFile(
return mount.getInode(path.dirname()).thenValue([=](const InodePtr inode) {
auto treeInode = inode.asTreePtr();
if (isDirectory) {
treeInode->mkdir(path.basename(), _S_IFDIR);
treeInode->mkdir(path.basename(), _S_IFDIR, InvalidationRequired::No);
} else {
treeInode->mknod(path.basename(), _S_IFREG, 0, InvalidationRequired::No);
}