mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
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
This commit is contained in:
parent
4fcdd44819
commit
7862d8fde0
@ -270,14 +270,6 @@ FOLLY_NODISCARD folly::Future<folly::Unit> EdenMount::initialize(
|
||||
});
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void EdenMount::stop() {
|
||||
transitionState(State::RUNNING, State::INITIALIZED);
|
||||
fsChannel_->stop();
|
||||
XLOGF(INFO, "Stopped EdenMount (0x{:x})", reinterpret_cast<uintptr_t>(this));
|
||||
}
|
||||
#endif
|
||||
|
||||
folly::Future<TreeInodePtr> EdenMount::createRootInode(
|
||||
const ParentCommits& parentCommits) {
|
||||
// Load the overlay, if present.
|
||||
@ -610,7 +602,6 @@ folly::SemiFuture<SerializedInodeMap> EdenMount::shutdownImpl(bool doTakeover) {
|
||||
});
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
folly::Future<folly::Unit> EdenMount::unmount() {
|
||||
return folly::makeFutureWith([this] {
|
||||
auto mountingUnmountingState = mountingUnmountingState_.wlock();
|
||||
@ -630,8 +621,13 @@ folly::Future<folly::Unit> 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<Unit> && result) noexcept->folly::Future<Unit> {
|
||||
auto mountingUnmountingState = mountingUnmountingState_.wlock();
|
||||
@ -646,8 +642,6 @@ folly::Future<folly::Unit> EdenMount::unmount() {
|
||||
});
|
||||
}
|
||||
|
||||
#endif // !_WIN32
|
||||
|
||||
const shared_ptr<UnboundedQueueExecutor>& EdenMount::getThreadPool() const {
|
||||
return serverState_->getThreadPool();
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -397,7 +397,6 @@ EdenServer::~EdenServer() {
|
||||
}
|
||||
|
||||
Future<Unit> EdenServer::unmountAll() {
|
||||
#ifndef _WIN32
|
||||
std::vector<Future<Unit>> futures;
|
||||
{
|
||||
const auto mountPoints = mountPoints_.wlock();
|
||||
@ -431,10 +430,6 @@ Future<Unit> 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<std::shared_ptr<EdenMount>> EdenServer::mount(
|
||||
}
|
||||
|
||||
Future<Unit> EdenServer::unmount(StringPiece mountPath) {
|
||||
#ifndef _WIN32
|
||||
const auto normalizedPath = normalizeMountPoint(mountPath);
|
||||
|
||||
return makeFutureWith([&] {
|
||||
auto future = Future<Unit>::makeEmpty();
|
||||
auto mount = std::shared_ptr<EdenMount>{};
|
||||
{
|
||||
const auto mountPoints = mountPoints_.wlock();
|
||||
const auto it = mountPoints->find(mountPath);
|
||||
const auto it = mountPoints->find(normalizedPath);
|
||||
if (it == mountPoints->end()) {
|
||||
return makeFuture<Unit>(
|
||||
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<Unit> 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<Unit>(std::move(ew));
|
||||
});
|
||||
#else
|
||||
NOT_IMPLEMENTED();
|
||||
#endif // !_WIN32
|
||||
}
|
||||
|
||||
void EdenServer::mountFinished(
|
||||
EdenMount* edenMount,
|
||||
std::optional<TakeoverData::MountInfo> takeover) {
|
||||
const auto mountPath = edenMount->getPath().stringPiece();
|
||||
const auto mountPath =
|
||||
normalizeMountPoint(edenMount->getPath().stringPiece());
|
||||
XLOG(INFO) << "mount point \"" << mountPath << "\" stopped";
|
||||
unregisterStats(edenMount);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user