inodes: pass caseSensitive to channel constructor

Summary:
By passing the argument to the channel, we can make it so that the NFS code
correctly replies to whether it is case sensitive or not.

Reviewed By: kmancini

Differential Revision: D26500112

fbshipit-source-id: 2988eae403ff3648b50a1a8f0c978be2828ba568
This commit is contained in:
Xavier Deguillard 2021-02-22 08:41:55 -08:00 committed by Facebook GitHub Bot
parent c590205cc3
commit dab46d37c6
10 changed files with 53 additions and 33 deletions

View File

@ -773,7 +773,8 @@ FuseChannel::FuseChannel(
const folly::Logger* straceLogger,
std::shared_ptr<ProcessNameCache> processNameCache,
folly::Duration requestTimeout,
Notifications* notifications)
Notifications* notifications,
bool caseSensitive)
: bufferSize_(std::max(size_t(getpagesize()) + 0x1000, MIN_BUFSIZE)),
numThreads_(numThreads),
dispatcher_(std::move(dispatcher)),
@ -781,6 +782,7 @@ FuseChannel::FuseChannel(
mountPath_(mountPath),
requestTimeout_(requestTimeout),
notifications_(notifications),
caseSensitive_(caseSensitive),
fuseDevice_(std::move(fuseDevice)),
processAccessLog_(std::move(processNameCache)),
traceDetailedArguments_(std::make_shared<std::atomic<size_t>>(0)),
@ -816,15 +818,14 @@ FuseChannel::~FuseChannel() {
<< "This shared_ptr should not be copied; see attached comment.";
}
Future<FuseChannel::StopFuture> FuseChannel::initialize(bool caseSensitive) {
Future<FuseChannel::StopFuture> FuseChannel::initialize() {
// Start one worker thread which will perform the initialization,
// and will then start the remaining worker threads and signal success
// once initialization completes.
return folly::makeFutureWith([&] {
auto state = state_.wlock();
state->workerThreads.reserve(numThreads_);
state->workerThreads.emplace_back(
[this, caseSensitive] { initWorkerThread(caseSensitive); });
state->workerThreads.emplace_back([this] { initWorkerThread(); });
return initPromise_.getFuture();
});
}
@ -1162,13 +1163,13 @@ void FuseChannel::setThreadSigmask() {
folly::checkPosixError(pthread_sigmask(SIG_UNBLOCK, &sigset, &oldset));
}
void FuseChannel::initWorkerThread(bool caseSensitive) noexcept {
void FuseChannel::initWorkerThread() noexcept {
try {
setThreadSigmask();
setThreadName(to<std::string>("fuse", mountPath_.basename()));
// Read the INIT packet
readInitPacket(caseSensitive);
readInitPacket();
// Start the other FUSE worker threads.
startWorkerThreads();
@ -1277,7 +1278,7 @@ void FuseChannel::stopInvalidationThread() {
invalidationThread_.join();
}
void FuseChannel::readInitPacket(bool caseSensitive) {
void FuseChannel::readInitPacket() {
struct {
fuse_in_header header;
fuse_init_in init;
@ -1402,11 +1403,11 @@ void FuseChannel::readInitPacket(bool caseSensitive) {
want |= FUSE_NO_OPENDIR_SUPPORT;
#endif
#ifdef FUSE_CASE_INSENSITIVE
if (!caseSensitive) {
if (!caseSensitive_) {
want |= FUSE_CASE_INSENSITIVE;
}
#else
(void)caseSensitive;
(void)caseSensitive_;
#endif
// Only return the capabilities the kernel supports.

View File

@ -205,8 +205,9 @@ class FuseChannel {
std::unique_ptr<FuseDispatcher> dispatcher,
const folly::Logger* straceLogger,
std::shared_ptr<ProcessNameCache> processNameCache,
folly::Duration requestTimeout = std::chrono::seconds(60),
Notifications* FOLLY_NULLABLE notifications = nullptr);
folly::Duration requestTimeout,
Notifications* FOLLY_NULLABLE notifications,
bool caseSensitive);
/**
* Destroy the FuseChannel.
@ -246,8 +247,7 @@ class FuseChannel {
* Callers should normally use via() to perform any additional work in
* another executor thread.
*/
FOLLY_NODISCARD folly::Future<StopFuture> initialize(
bool caseSensitive = true);
FOLLY_NODISCARD folly::Future<StopFuture> initialize();
/**
* Initialize the FuseChannel when taking over an existing FuseDevice.
@ -662,14 +662,14 @@ class FuseChannel {
private:
void setThreadSigmask();
void initWorkerThread(bool caseSensitive) noexcept;
void initWorkerThread() noexcept;
void fuseWorkerThread() noexcept;
void invalidationThread() noexcept;
void stopInvalidationThread();
void sendInvalidation(InvalidationEntry& entry);
void sendInvalidateInode(InodeNumber ino, int64_t off, int64_t len);
void sendInvalidateEntry(InodeNumber parent, PathComponentPiece name);
void readInitPacket(bool caseSensitive);
void readInitPacket();
void startWorkerThreads();
/**
@ -719,6 +719,7 @@ class FuseChannel {
const AbsolutePath mountPath_;
const folly::Duration requestTimeout_;
Notifications* const notifications_;
bool caseSensitive_;
/*
* connInfo_ is modified during the initialization process,

View File

@ -130,7 +130,10 @@ int main(int argc, char** argv) {
FLAGS_numFuseThreads,
std::move(dispatcher),
&straceLogger,
std::make_shared<ProcessNameCache>()));
std::make_shared<ProcessNameCache>(),
std::chrono::seconds(60),
nullptr,
true));
XLOG(INFO) << "Starting FUSE...";
auto completionFuture = channel->initialize().get();

View File

@ -74,7 +74,10 @@ class FuseChannelTest : public ::testing::Test {
numThreads,
std::move(testDispatcher),
&straceLogger,
std::make_shared<ProcessNameCache>()));
std::make_shared<ProcessNameCache>(),
std::chrono::seconds(60),
nullptr,
true));
}
FuseChannel::StopFuture performInit(

View File

@ -1236,7 +1236,8 @@ FuseChannel* makeFuseChannel(EdenMount* mount, folly::File fuseFd) {
->getReloadableConfig()
.getEdenConfig()
->fuseRequestTimeout.getValue()),
mount->getServerState()->getNotifications());
mount->getServerState()->getNotifications(),
mount->getConfig()->getCaseSensitive());
}
} // namespace
#endif
@ -1301,7 +1302,8 @@ folly::Future<folly::Unit> EdenMount::channelMount(bool readOnly) {
serverState_->getReloadableConfig()
.getEdenConfig()
->prjfsRequestTimeout.getValue()),
serverState_->getNotifications());
serverState_->getNotifications(),
config_->getCaseSensitive());
});
return std::move(fut).thenValue(
[this,
@ -1394,8 +1396,8 @@ folly::Future<folly::Unit> EdenMount::startChannel(bool readOnly) {
#ifdef _WIN32
channelInitSuccessful(channel_->getStopFuture());
#else
return channel_->initialize(config_->getCaseSensitive())
.thenValue([this](FuseChannel::StopFuture&& fuseCompleteFuture) {
return channel_->initialize().thenValue(
[this](FuseChannel::StopFuture&& fuseCompleteFuture) {
channelInitSuccessful(std::move(fuseCompleteFuture));
});
#endif

View File

@ -49,7 +49,8 @@ int main(int argc, char** argv) {
nullptr,
nullptr,
std::chrono::duration_cast<folly::Duration>(std::chrono::seconds(0)),
nullptr);
nullptr,
true);
XLOG(INFO) << "Started NfsServer, mountdport=" << mountdport
<< ", nfsdport=" << nfsdport;

View File

@ -19,7 +19,8 @@ NfsServer::NfsMountInfo NfsServer::registerMount(
const folly::Logger* straceLogger,
std::shared_ptr<ProcessNameCache> processNameCache,
folly::Duration requestTimeout,
Notifications* FOLLY_NULLABLE notifications) {
Notifications* FOLLY_NULLABLE notifications,
bool caseSensitive) {
auto nfsd = std::make_unique<Nfsd3>(
false,
evb_,
@ -27,7 +28,8 @@ NfsServer::NfsMountInfo NfsServer::registerMount(
straceLogger,
std::move(processNameCache),
requestTimeout,
notifications);
notifications,
caseSensitive);
mountd_.registerMount(path, rootIno);
auto nfsdPort = nfsd->getPort();

View File

@ -60,7 +60,8 @@ class NfsServer {
const folly::Logger* straceLogger,
std::shared_ptr<ProcessNameCache> processNameCache,
folly::Duration requestTimeout,
Notifications* FOLLY_NULLABLE notifications);
Notifications* FOLLY_NULLABLE notifications,
bool caseSensitive);
/**
* Unregister the mount point matching the path.

View File

@ -20,8 +20,11 @@ class Nfsd3ServerProcessor final : public RpcServerProcessor {
public:
explicit Nfsd3ServerProcessor(
std::unique_ptr<NfsDispatcher> dispatcher,
const folly::Logger* straceLogger)
: dispatcher_(std::move(dispatcher)), straceLogger_(straceLogger) {}
const folly::Logger* straceLogger,
bool caseSensitive)
: dispatcher_(std::move(dispatcher)),
straceLogger_(straceLogger),
caseSensitive_(caseSensitive) {}
Nfsd3ServerProcessor(const Nfsd3ServerProcessor&) = delete;
Nfsd3ServerProcessor(Nfsd3ServerProcessor&&) = delete;
@ -84,6 +87,7 @@ class Nfsd3ServerProcessor final : public RpcServerProcessor {
private:
std::unique_ptr<NfsDispatcher> dispatcher_;
const folly::Logger* straceLogger_;
bool caseSensitive_;
};
folly::Future<folly::Unit> Nfsd3ServerProcessor::null(
@ -366,14 +370,13 @@ folly::Future<folly::Unit> Nfsd3ServerProcessor::pathconf(
PATHCONF3res res{
{nfsstat3::NFS3_OK,
PATHCONF3resok{
// TODO(xavierd): fill up the post_op_attr and make case_insensitive
// depends on the configured value for that mount.
// TODO(xavierd): fill up the post_op_attr
post_op_attr{},
/*linkmax=*/0,
/*name_max=*/NAME_MAX,
/*no_trunc=*/true,
/*chown_restricted=*/true,
/*case_insensitive=*/false,
/*case_insensitive=*/!caseSensitive_,
/*case_preserving=*/true,
}}};
@ -493,11 +496,13 @@ Nfsd3::Nfsd3(
const folly::Logger* straceLogger,
std::shared_ptr<ProcessNameCache> /*processNameCache*/,
folly::Duration /*requestTimeout*/,
Notifications* /*notifications*/)
Notifications* /*notifications*/,
bool caseSensitive)
: server_(
std::make_shared<Nfsd3ServerProcessor>(
std::move(dispatcher),
straceLogger),
straceLogger,
caseSensitive),
evb) {
if (registerWithRpcbind) {
server_.registerService(kNfsdProgNumber, kNfsd3ProgVersion);

View File

@ -45,7 +45,8 @@ class Nfsd3 {
const folly::Logger* straceLogger,
std::shared_ptr<ProcessNameCache> processNameCache,
folly::Duration requestTimeout,
Notifications* FOLLY_NULLABLE notifications);
Notifications* FOLLY_NULLABLE notifications,
bool caseSensitive);
/**
* Obtain the TCP port that this NFSv3 program is listening on.