2021-02-09 23:45:00 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
#include "eden/fs/nfs/NfsServer.h"
|
2021-06-29 19:44:22 +03:00
|
|
|
|
2021-03-29 19:19:29 +03:00
|
|
|
#include <folly/executors/thread_factory/NamedThreadFactory.h>
|
2021-02-09 23:45:00 +03:00
|
|
|
#include "eden/fs/nfs/Nfsd3.h"
|
2021-06-29 19:44:22 +03:00
|
|
|
#include "eden/fs/utils/EdenTaskQueue.h"
|
2021-02-09 23:45:00 +03:00
|
|
|
|
|
|
|
namespace facebook::eden {
|
|
|
|
|
2021-03-29 19:19:29 +03:00
|
|
|
NfsServer::NfsServer(
|
|
|
|
folly::EventBase* evb,
|
|
|
|
uint64_t numServicingThreads,
|
|
|
|
uint64_t maxInflightRequests)
|
|
|
|
: evb_(evb),
|
|
|
|
threadPool_(std::make_shared<folly::CPUThreadPoolExecutor>(
|
|
|
|
numServicingThreads,
|
2021-06-29 19:44:22 +03:00
|
|
|
std::make_unique<EdenTaskQueue>(maxInflightRequests),
|
2021-03-29 19:19:29 +03:00
|
|
|
std::make_unique<folly::NamedThreadFactory>("NfsThreadPool"))),
|
2021-05-12 23:05:50 +03:00
|
|
|
mountd_(evb_, threadPool_) {}
|
|
|
|
|
|
|
|
void NfsServer::initialize(
|
|
|
|
folly::SocketAddress addr,
|
|
|
|
bool registerMountdWithRpcbind) {
|
|
|
|
mountd_.initialize(addr, registerMountdWithRpcbind);
|
|
|
|
}
|
2021-03-29 19:19:29 +03:00
|
|
|
|
2021-11-18 04:09:58 +03:00
|
|
|
void NfsServer::initialize(folly::File&& socket) {
|
|
|
|
mountd_.initialize(std::move(socket));
|
|
|
|
}
|
|
|
|
|
2021-02-09 23:45:00 +03:00
|
|
|
NfsServer::NfsMountInfo NfsServer::registerMount(
|
|
|
|
AbsolutePathPiece path,
|
2021-02-09 23:45:00 +03:00
|
|
|
InodeNumber rootIno,
|
2021-02-18 10:29:21 +03:00
|
|
|
std::unique_ptr<NfsDispatcher> dispatcher,
|
2021-02-09 23:45:00 +03:00
|
|
|
const folly::Logger* straceLogger,
|
|
|
|
std::shared_ptr<ProcessNameCache> processNameCache,
|
2021-09-10 02:28:29 +03:00
|
|
|
std::shared_ptr<FsEventLogger> fsEventLogger,
|
2021-02-09 23:45:00 +03:00
|
|
|
folly::Duration requestTimeout,
|
2021-02-22 19:41:55 +03:00
|
|
|
Notifications* FOLLY_NULLABLE notifications,
|
2021-04-20 23:07:31 +03:00
|
|
|
CaseSensitivity caseSensitive,
|
2021-04-07 00:16:09 +03:00
|
|
|
uint32_t iosize) {
|
2021-02-09 23:45:00 +03:00
|
|
|
auto nfsd = std::make_unique<Nfsd3>(
|
|
|
|
evb_,
|
2021-03-29 19:19:29 +03:00
|
|
|
threadPool_,
|
2021-02-18 10:29:21 +03:00
|
|
|
std::move(dispatcher),
|
2021-02-09 23:45:00 +03:00
|
|
|
straceLogger,
|
|
|
|
std::move(processNameCache),
|
2021-09-10 02:28:29 +03:00
|
|
|
std::move(fsEventLogger),
|
2021-02-09 23:45:00 +03:00
|
|
|
requestTimeout,
|
2021-02-22 19:41:55 +03:00
|
|
|
notifications,
|
2021-04-07 00:16:09 +03:00
|
|
|
caseSensitive,
|
|
|
|
iosize);
|
2021-02-09 23:45:00 +03:00
|
|
|
mountd_.registerMount(path, rootIno);
|
|
|
|
|
2021-05-12 23:05:50 +03:00
|
|
|
return {std::move(nfsd), mountd_.getAddr()};
|
2021-02-09 23:45:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void NfsServer::unregisterMount(AbsolutePathPiece path) {
|
|
|
|
mountd_.unregisterMount(path);
|
|
|
|
}
|
|
|
|
|
2021-11-18 04:09:58 +03:00
|
|
|
folly::SemiFuture<folly::File> NfsServer::takeoverStop() {
|
|
|
|
return mountd_.takeoverStop();
|
|
|
|
}
|
|
|
|
|
2021-02-09 23:45:00 +03:00
|
|
|
} // namespace facebook::eden
|
|
|
|
|
|
|
|
#endif
|