2019-12-11 01:04:02 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-06-08 22:42:36 +03:00
|
|
|
|
2019-12-11 01:04:02 +03:00
|
|
|
#include "folly/portability/Windows.h"
|
|
|
|
|
2020-09-23 19:40:09 +03:00
|
|
|
#include <ProjectedFSLib.h> // @manual
|
2020-09-22 19:08:07 +03:00
|
|
|
#include "eden/fs/utils/Guid.h"
|
2019-12-11 01:04:02 +03:00
|
|
|
#include "eden/fs/utils/PathFuncs.h"
|
2020-09-11 18:35:51 +03:00
|
|
|
#include "eden/fs/utils/ProcessAccessLog.h"
|
2020-09-29 04:13:05 +03:00
|
|
|
#include "folly/futures/Future.h"
|
2019-12-11 01:04:02 +03:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace eden {
|
|
|
|
class EdenMount;
|
2020-09-23 19:40:09 +03:00
|
|
|
class Dispatcher;
|
2019-12-11 01:04:02 +03:00
|
|
|
|
2020-09-29 04:13:05 +03:00
|
|
|
class PrjfsChannel {
|
2019-12-11 01:04:02 +03:00
|
|
|
public:
|
|
|
|
PrjfsChannel(const PrjfsChannel&) = delete;
|
|
|
|
PrjfsChannel& operator=(const PrjfsChannel&) = delete;
|
|
|
|
|
2020-04-14 22:44:01 +03:00
|
|
|
explicit PrjfsChannel() = delete;
|
2019-12-11 01:04:02 +03:00
|
|
|
|
2020-09-11 18:35:51 +03:00
|
|
|
PrjfsChannel(
|
|
|
|
AbsolutePathPiece mountPath,
|
2020-09-23 19:40:09 +03:00
|
|
|
Dispatcher* const dispatcher,
|
2020-10-20 19:32:22 +03:00
|
|
|
const folly::Logger* straceLogger,
|
2020-09-11 18:35:51 +03:00
|
|
|
std::shared_ptr<ProcessNameCache> processNameCache);
|
2019-12-11 01:04:02 +03:00
|
|
|
~PrjfsChannel();
|
2020-09-11 18:35:51 +03:00
|
|
|
|
|
|
|
void start(bool readOnly, bool useNegativePathCaching);
|
2019-12-11 01:04:02 +03:00
|
|
|
void stop();
|
|
|
|
|
2020-09-29 04:13:05 +03:00
|
|
|
struct StopData {};
|
|
|
|
folly::SemiFuture<StopData> getStopFuture();
|
2020-06-20 04:02:42 +03:00
|
|
|
|
2020-04-24 22:42:38 +03:00
|
|
|
/**
|
2020-10-16 03:26:53 +03:00
|
|
|
* Remove a file that has been cached on disk by ProjectedFS. This should be
|
|
|
|
* called when the content of a materialized file has changed, typically
|
|
|
|
* called during on an `update` operation.
|
|
|
|
*
|
|
|
|
* This can fail when the underlying file cannot be evicted from ProjectedFS,
|
|
|
|
* one example is when the user has locked the file.
|
2020-04-24 22:42:38 +03:00
|
|
|
*/
|
2020-10-16 03:26:53 +03:00
|
|
|
FOLLY_NODISCARD folly::Try<void> removeCachedFile(RelativePathPiece path);
|
2020-04-24 22:42:38 +03:00
|
|
|
|
2020-10-16 03:26:53 +03:00
|
|
|
/**
|
|
|
|
* Ensure that the directory is a placeholder so that ProjectedFS will always
|
|
|
|
* invoke the opendir/readdir callbacks when the user is listing files in it.
|
|
|
|
* This particularly matters for directories that were created by the user to
|
|
|
|
* later be committed.
|
|
|
|
*/
|
|
|
|
FOLLY_NODISCARD folly::Try<void> addDirectoryPlaceholder(
|
|
|
|
RelativePathPiece path);
|
inodes: invalidate more on Windows
Summary:
Cache invalidation is hard, and on Windows we avoided doing a lot of them. It
turns out, this was the wrong decision as it's fairly easy to find cases where
the filesystem view is different from the manifest state.
Since the Linux code is most likely correct in where the invalidation is done,
let's also do the same on Windows, removing a whole lot of #ifdef. It is very
likely that as a result of this diff we end up invalidating more than needed,
thus slowing down EdenFS, but at this point I'd prefer to err on the side of
correctness, performance will come later.
While invalidating files should use PrjDeleteFile, for directories, we simply
need to mark them as placeholder, as directories created by a user won't have a
placeholder, thus ProjectedFS would bypass EdenFS when listing in.
Reviewed By: chadaustin
Differential Revision: D22833202
fbshipit-source-id: d807557f5e44279c49ab701b7a797253ef1f0717
2020-08-03 21:24:55 +03:00
|
|
|
|
2020-09-29 04:13:05 +03:00
|
|
|
void flushNegativePathCache();
|
2020-08-15 03:33:49 +03:00
|
|
|
|
2020-09-23 19:40:09 +03:00
|
|
|
Dispatcher* getDispatcher() {
|
2020-09-11 18:35:51 +03:00
|
|
|
return dispatcher_;
|
|
|
|
}
|
|
|
|
|
2020-10-20 19:32:22 +03:00
|
|
|
const folly::Logger& getStraceLogger() const {
|
|
|
|
return *straceLogger_;
|
|
|
|
}
|
|
|
|
|
2020-09-11 18:35:51 +03:00
|
|
|
ProcessAccessLog& getProcessAccessLog() {
|
|
|
|
return processAccessLog_;
|
|
|
|
}
|
|
|
|
|
2020-09-17 04:55:52 +03:00
|
|
|
PRJ_NAMESPACE_VIRTUALIZATION_CONTEXT getMountChannelContext() const {
|
|
|
|
return mountChannel_;
|
|
|
|
}
|
|
|
|
|
2020-09-17 04:55:52 +03:00
|
|
|
void sendSuccess(
|
|
|
|
int32_t commandId,
|
|
|
|
PRJ_COMPLETE_COMMAND_EXTENDED_PARAMETERS* FOLLY_NULLABLE extra);
|
|
|
|
|
|
|
|
void sendError(int32_t commandId, HRESULT error);
|
|
|
|
|
2019-12-11 01:04:02 +03:00
|
|
|
private:
|
|
|
|
//
|
|
|
|
// Channel to talk to projectedFS.
|
|
|
|
//
|
|
|
|
PRJ_NAMESPACE_VIRTUALIZATION_CONTEXT mountChannel_{nullptr};
|
2019-12-11 01:04:02 +03:00
|
|
|
|
2020-09-11 18:35:51 +03:00
|
|
|
const AbsolutePath mountPath_;
|
2020-09-23 19:40:09 +03:00
|
|
|
Dispatcher* const dispatcher_{nullptr};
|
2020-10-20 19:32:22 +03:00
|
|
|
const folly::Logger* const straceLogger_{nullptr};
|
2019-12-11 01:04:02 +03:00
|
|
|
Guid mountId_;
|
|
|
|
bool isRunning_{false};
|
2020-08-15 03:33:49 +03:00
|
|
|
bool useNegativePathCaching_{true};
|
2020-09-29 04:13:05 +03:00
|
|
|
folly::Promise<StopData> stopPromise_;
|
2020-09-11 18:35:51 +03:00
|
|
|
|
|
|
|
ProcessAccessLog processAccessLog_;
|
2019-12-11 01:04:02 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|