From 7862d8fde0cf1aea99390982b275d64af46372df Mon Sep 17 00:00:00 2001 From: Xavier Deguillard Date: Fri, 19 Jun 2020 18:02:42 -0700 Subject: [PATCH] mount: enable unmount Summary: All the unification of the mount code lead to this point, where supporting unmount is merely just removing the various #ifdef. Reviewed By: fanzeyi Differential Revision: D21797078 fbshipit-source-id: 7602eb85e3fa276b72daebda36ae269ec38cde66 --- eden/fs/inodes/EdenMount.cpp | 16 +++++----------- eden/fs/inodes/EdenMount.h | 6 ------ eden/fs/service/EdenServer.cpp | 20 +++++++------------- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/eden/fs/inodes/EdenMount.cpp b/eden/fs/inodes/EdenMount.cpp index 09b4234d25..76ad9f8e20 100644 --- a/eden/fs/inodes/EdenMount.cpp +++ b/eden/fs/inodes/EdenMount.cpp @@ -270,14 +270,6 @@ FOLLY_NODISCARD folly::Future EdenMount::initialize( }); } -#ifdef _WIN32 -void EdenMount::stop() { - transitionState(State::RUNNING, State::INITIALIZED); - fsChannel_->stop(); - XLOGF(INFO, "Stopped EdenMount (0x{:x})", reinterpret_cast(this)); -} -#endif - folly::Future EdenMount::createRootInode( const ParentCommits& parentCommits) { // Load the overlay, if present. @@ -610,7 +602,6 @@ folly::SemiFuture EdenMount::shutdownImpl(bool doTakeover) { }); } -#ifndef _WIN32 folly::Future EdenMount::unmount() { return folly::makeFutureWith([this] { auto mountingUnmountingState = mountingUnmountingState_.wlock(); @@ -630,8 +621,13 @@ folly::Future EdenMount::unmount() { if (mountResult.hasException()) { return folly::makeFuture(); } +#ifdef _WIN32 + fsChannel_->stop(); + return folly::makeFuture(); +#else return serverState_->getPrivHelper()->fuseUnmount( getPath().stringPiece()); +#endif }) .thenTry([this](Try && result) noexcept->folly::Future { auto mountingUnmountingState = mountingUnmountingState_.wlock(); @@ -646,8 +642,6 @@ folly::Future EdenMount::unmount() { }); } -#endif // !_WIN32 - const shared_ptr& EdenMount::getThreadPool() const { return serverState_->getThreadPool(); } diff --git a/eden/fs/inodes/EdenMount.h b/eden/fs/inodes/EdenMount.h index 4606d7f8d1..e010d4c9e1 100644 --- a/eden/fs/inodes/EdenMount.h +++ b/eden/fs/inodes/EdenMount.h @@ -671,12 +671,6 @@ class EdenMount { TreeInodePtr treeInode); #ifdef _WIN32 - /** - * The following functions are to start and stop Eden Mount on Windows. They - * setup and destroy the ProjectedFS channel. - */ - void stop(); - /** * The following functions are to fetch and set information in the Inode * Tree. These are used by the ProjectedFS and TestMount for testing. diff --git a/eden/fs/service/EdenServer.cpp b/eden/fs/service/EdenServer.cpp index 1cd72fe0dc..c0705f5721 100644 --- a/eden/fs/service/EdenServer.cpp +++ b/eden/fs/service/EdenServer.cpp @@ -397,7 +397,6 @@ EdenServer::~EdenServer() { } Future EdenServer::unmountAll() { -#ifndef _WIN32 std::vector> futures; { const auto mountPoints = mountPoints_.wlock(); @@ -431,10 +430,6 @@ Future EdenServer::unmountAll() { result.throwIfFailed(); } }); -#else - // TODO: shut down any currently running mounts - return folly::makeFuture(); -#endif // !_WIN32 } #ifndef _WIN32 @@ -1323,16 +1318,17 @@ folly::Future> EdenServer::mount( } Future EdenServer::unmount(StringPiece mountPath) { -#ifndef _WIN32 + const auto normalizedPath = normalizeMountPoint(mountPath); + return makeFutureWith([&] { auto future = Future::makeEmpty(); auto mount = std::shared_ptr{}; { const auto mountPoints = mountPoints_.wlock(); - const auto it = mountPoints->find(mountPath); + const auto it = mountPoints->find(normalizedPath); if (it == mountPoints->end()) { return makeFuture( - std::out_of_range("no such mount point " + mountPath.str())); + std::out_of_range("no such mount point " + normalizedPath)); } future = it->second.unmountPromise.getFuture(); mount = it->second.edenMount; @@ -1345,20 +1341,18 @@ Future EdenServer::unmount(StringPiece mountPath) { return std::move(f); }); }) - .thenError([path = mountPath.str()](folly::exception_wrapper&& ew) { + .thenError([path = normalizedPath](folly::exception_wrapper&& ew) { XLOG(ERR) << "Failed to perform unmount for \"" << path << "\": " << folly::exceptionStr(ew); return makeFuture(std::move(ew)); }); -#else - NOT_IMPLEMENTED(); -#endif // !_WIN32 } void EdenServer::mountFinished( EdenMount* edenMount, std::optional takeover) { - const auto mountPath = edenMount->getPath().stringPiece(); + const auto mountPath = + normalizeMountPoint(edenMount->getPath().stringPiece()); XLOG(INFO) << "mount point \"" << mountPath << "\" stopped"; unregisterStats(edenMount);