SetPathObjectId should avoid mount-wise operations

Reviewed By: chadaustin

Differential Revision: D35104663

fbshipit-source-id: 0dd00e3a1a3f8af9869b7eca459bb622cab66992
This commit is contained in:
Yipu Miao 2022-04-07 16:15:41 -07:00 committed by Facebook GitHub Bot
parent 8c84ec8c2c
commit ffab8acc6a
4 changed files with 13 additions and 6 deletions

View File

@ -85,6 +85,10 @@ Future<vector<CheckoutConflict>> CheckoutContext::finish(RootId newSnapshot) {
// This allows any filesystem unlink() or rename() operations to proceed.
renameLock_.unlock();
return flush();
}
Future<vector<CheckoutConflict>> CheckoutContext::flush() {
if (!isDryRun()) {
// If we have a FUSE channel, flush all invalidations we sent to the kernel
// as part of the checkout operation. This will ensure that other processes

View File

@ -96,6 +96,13 @@ class CheckoutContext {
*/
folly::Future<std::vector<CheckoutConflict>> finish(RootId newSnapshot);
/**
* Flush the invalidation if needed.
*
* Return the list of conflicts and errors.
*/
folly::Future<std::vector<CheckoutConflict>> flush();
void addConflict(ConflictType type, RelativePathPiece path);
void
addConflict(ConflictType type, TreeInode* parent, PathComponentPiece name);

View File

@ -692,20 +692,17 @@ folly::Future<SetPathObjectIdResultAndTimes> EdenMount::setPathObjectId(
});
return collectSafe(getTargetTreeInodeFuture, getRootTreeFuture)
.thenValue([this, ctx, setPathObjectIdTime, stopWatch, rootId](
.thenValue([ctx, setPathObjectIdTime, stopWatch, rootId](
std::tuple<TreeInodePtr, shared_ptr<const Tree>> results) {
setPathObjectIdTime->didLookupTreesOrGetInodeByPath =
stopWatch.elapsed();
auto [targetTreeInode, incomingTree] = results;
targetTreeInode->unloadChildrenUnreferencedByFs();
// TODO(@yipu): Remove rename lock
ctx->start(this->acquireRenameLock(), {}, rootId, nullptr);
setPathObjectIdTime->didAcquireRenameLock = stopWatch.elapsed();
return targetTreeInode->checkout(ctx.get(), nullptr, incomingTree);
})
.thenValue([ctx, setPathObjectIdTime, stopWatch, rootId](auto&&) {
setPathObjectIdTime->didCheckout = stopWatch.elapsed();
return ctx->finish(rootId);
return ctx->flush();
})
.thenValue([ctx, setPathObjectIdTime, stopWatch](
std::vector<CheckoutConflict>&& conflicts) {

View File

@ -164,7 +164,6 @@ struct CheckoutTimes {
struct SetPathObjectIdTimes {
using duration = std::chrono::steady_clock::duration;
duration didLookupTreesOrGetInodeByPath{};
duration didAcquireRenameLock{};
duration didCheckout{};
duration didFinish{};
};