rename IOverlay to InodeCatalog

Summary: Having an `Overlay` object own a `IOverlay` object, as opposed to deriving from one, is a bit confusing, so this renames `IOverlay` to `InodeCatalog` as an attempt to clear up the class structure. `InodeCatalog` is meant to mean "InodeDatabase", but I find the word "database" to imply a heavyweight structure, which this class is not.

Reviewed By: chadaustin

Differential Revision: D40517958

fbshipit-source-id: a5873ab21a336da3c6823b91d7f51c4ae49a7f08
This commit is contained in:
Genevieve (Genna) Helsel 2022-10-31 09:56:13 -07:00 committed by Facebook GitHub Bot
parent caf5f4404f
commit 2a3778b616
7 changed files with 50 additions and 51 deletions

View File

@ -29,18 +29,18 @@ class IOBuf;
namespace facebook::eden {
/**
* Overlay interface for different overlay implementations.
* Interface for tracking inode relationships.
*/
class IOverlay {
class InodeCatalog {
public:
IOverlay() = default;
InodeCatalog() = default;
virtual ~IOverlay() = default;
virtual ~InodeCatalog() = default;
IOverlay(const IOverlay&) = delete;
IOverlay& operator=(const IOverlay&) = delete;
IOverlay(IOverlay&&) = delete;
IOverlay&& operator=(IOverlay&&) = delete;
InodeCatalog(const InodeCatalog&) = delete;
InodeCatalog& operator=(const InodeCatalog&) = delete;
InodeCatalog(InodeCatalog&&) = delete;
InodeCatalog&& operator=(InodeCatalog&&) = delete;
// Older overlay implementation only care about data storage but has little
// understanding of the content it stores. A set of methods are added to allow

View File

@ -38,7 +38,7 @@ namespace {
constexpr uint64_t ioCountMask = 0x7FFFFFFFFFFFFFFFull;
constexpr uint64_t ioClosedMask = 1ull << 63;
std::unique_ptr<IOverlay> makeTreeOverlay(
std::unique_ptr<InodeCatalog> makeInodeCatalog(
AbsolutePathPiece localDir,
Overlay::TreeOverlayType treeOverlayType,
const EdenConfig& config,
@ -121,14 +121,13 @@ Overlay::Overlay(
std::shared_ptr<StructuredLogger> logger,
const EdenConfig& config)
: fileContentStore_{makeFileContentStore(localDir)},
backingOverlay_{makeTreeOverlay(
inodeCatalog_{makeInodeCatalog(
localDir,
treeOverlayType,
config,
fileContentStore_ ? fileContentStore_.get() : nullptr)},
treeOverlayType_{treeOverlayType},
supportsSemanticOperations_{
backingOverlay_->supportsSemanticOperations()},
supportsSemanticOperations_{inodeCatalog_->supportsSemanticOperations()},
localDir_{localDir},
caseSensitive_{caseSensitive},
structuredLogger_{logger} {}
@ -149,7 +148,7 @@ void Overlay::close() {
// Make sure everything is shut down in reverse of construction order.
// Cleanup is not necessary if tree overlay was not initialized and either
// there is no file content store or the it was not initalized
if (!backingOverlay_->initialized() &&
if (!inodeCatalog_->initialized() &&
(!fileContentStore_ ||
(fileContentStore_ && !fileContentStore_->initialized()))) {
return;
@ -170,7 +169,7 @@ void Overlay::close() {
inodeMetadataTable_.reset();
#endif // !_WIN32
backingOverlay_->close(optNextInodeNumber);
inodeCatalog_->close(optNextInodeNumber);
if (fileContentStore_ && treeOverlayType_ != TreeOverlayType::Legacy) {
fileContentStore_->close();
}
@ -233,7 +232,7 @@ void Overlay::initOverlay(
FOLLY_MAYBE_UNUSED const OverlayChecker::ProgressCallback& progressCallback,
FOLLY_MAYBE_UNUSED OverlayChecker::LookupCallback& lookupCallback) {
IORequest req{this};
auto optNextInodeNumber = backingOverlay_->initOverlay(true);
auto optNextInodeNumber = inodeCatalog_->initOverlay(true);
if (fileContentStore_ && treeOverlayType_ != TreeOverlayType::Legacy) {
fileContentStore_->initialize(true);
}
@ -256,7 +255,7 @@ void Overlay::initOverlay(
// Therefore OverlayChecker must not exist longer than this initOverlay
// call.
OverlayChecker checker(
static_cast<FsOverlay*>(backingOverlay_.get()),
static_cast<FsOverlay*>(inodeCatalog_.get()),
static_cast<FileContentStore*>(fileContentStore_.get()),
std::nullopt,
lookupCallback);
@ -294,7 +293,7 @@ void Overlay::initOverlay(
// here to skip scanning in that case.
if (folly::kIsWindows && mountPath.has_value()) {
optNextInodeNumber =
dynamic_cast<TreeOverlay*>(backingOverlay_.get())
dynamic_cast<TreeOverlay*>(inodeCatalog_.get())
->scanLocalChanges(std::move(config), *mountPath, lookupCallback);
}
@ -331,7 +330,7 @@ InodeNumber Overlay::allocateInodeNumber() {
DirContents Overlay::loadOverlayDir(InodeNumber inodeNumber) {
DirContents result(caseSensitive_);
IORequest req{this};
auto dirData = backingOverlay_->loadOverlayDir(inodeNumber);
auto dirData = inodeCatalog_->loadOverlayDir(inodeNumber);
if (!dirData.has_value()) {
return result;
}
@ -416,7 +415,7 @@ overlay::OverlayDir Overlay::serializeOverlayDir(
}
void Overlay::saveOverlayDir(InodeNumber inodeNumber, const DirContents& dir) {
backingOverlay_->saveOverlayDir(
inodeCatalog_->saveOverlayDir(
inodeNumber, serializeOverlayDir(inodeNumber, dir));
}
@ -444,7 +443,7 @@ void Overlay::removeOverlayDir(InodeNumber inodeNumber) {
IORequest req{this};
freeInodeFromMetadataTable(inodeNumber);
backingOverlay_->removeOverlayDir(inodeNumber);
inodeCatalog_->removeOverlayDir(inodeNumber);
}
void Overlay::recursivelyRemoveOverlayDir(InodeNumber inodeNumber) {
@ -457,7 +456,7 @@ void Overlay::recursivelyRemoveOverlayDir(InodeNumber inodeNumber) {
// saveOverlayDir(I). There's also no risk of violating our durability
// guarantees if the process dies after this call but before the thread could
// remove this data.
auto dirData = backingOverlay_->loadAndRemoveOverlayDir(inodeNumber);
auto dirData = inodeCatalog_->loadAndRemoveOverlayDir(inodeNumber);
if (dirData) {
gcQueue_.lock()->queue.emplace_back(std::move(*dirData));
gcCondVar_.notify_one();
@ -476,7 +475,7 @@ folly::Future<folly::Unit> Overlay::flushPendingAsync() {
bool Overlay::hasOverlayDir(InodeNumber inodeNumber) {
IORequest req{this};
return backingOverlay_->hasOverlayDir(inodeNumber);
return inodeCatalog_->hasOverlayDir(inodeNumber);
}
#ifndef _WIN32
@ -615,7 +614,7 @@ void Overlay::handleGCRequest(GCRequest& request) {
if (std::holds_alternative<GCRequest::MaintenanceRequest>(
request.requestType)) {
backingOverlay_->maintenance();
inodeCatalog_->maintenance();
return;
}
@ -671,7 +670,7 @@ void Overlay::handleGCRequest(GCRequest& request) {
overlay::OverlayDir dir;
try {
freeInodeFromMetadataTable(ino);
auto dirData = backingOverlay_->loadAndRemoveOverlayDir(ino);
auto dirData = inodeCatalog_->loadAndRemoveOverlayDir(ino);
if (!dirData.has_value()) {
XLOG(DBG7) << "no dir data for inode " << ino;
continue;
@ -693,7 +692,7 @@ void Overlay::addChild(
const std::pair<PathComponent, DirEntry>& childEntry,
const DirContents& content) {
if (supportsSemanticOperations_) {
backingOverlay_->addChild(
inodeCatalog_->addChild(
parent, childEntry.first, serializeOverlayEntry(childEntry.second));
} else {
saveOverlayDir(parent, content);
@ -705,7 +704,7 @@ void Overlay::removeChild(
PathComponentPiece childName,
const DirContents& content) {
if (supportsSemanticOperations_) {
backingOverlay_->removeChild(parent, childName);
inodeCatalog_->removeChild(parent, childName);
} else {
saveOverlayDir(parent, content);
}
@ -723,7 +722,7 @@ void Overlay::renameChild(
const DirContents& srcContent,
const DirContents& dstContent) {
if (supportsSemanticOperations_) {
backingOverlay_->renameChild(src, dst, srcName, dstName);
inodeCatalog_->renameChild(src, dst, srcName, dstName);
} else {
saveOverlayDir(src, srcContent);
if (dst.get() != src.get()) {

View File

@ -38,7 +38,7 @@ class OverlayDir;
struct DirContents;
class InodeMap;
class SerializedInodeMap;
class IOverlay;
class InodeCatalog;
class IFileContentStore;
class DirEntry;
class EdenConfig;
@ -277,11 +277,11 @@ class Overlay : public std::enable_shared_from_this<Overlay> {
void maintenance();
/*
* Returns a raw pointer to the backing overlay. This method should only be
* Returns a raw pointer to the inode catalog. This method should only be
* used for testing.
*/
IOverlay* getRawBackingOverlay() {
return backingOverlay_.get();
InodeCatalog* getRawInodeCatalog() {
return inodeCatalog_.get();
}
overlay::OverlayDir serializeOverlayDir(
@ -355,12 +355,12 @@ class Overlay : public std::enable_shared_from_this<Overlay> {
std::atomic<uint64_t> nextInodeNumber_{0};
std::unique_ptr<IFileContentStore> fileContentStore_;
std::unique_ptr<IOverlay> backingOverlay_;
std::unique_ptr<InodeCatalog> inodeCatalog_;
Overlay::TreeOverlayType treeOverlayType_;
/**
* Indicates if the backing overlay supports semantic operations, see
* `IOverlay::supportsSemanticOperations` for more information.
* `InodeCatalog::supportsSemanticOperations` for more information.
*/
bool supportsSemanticOperations_;
@ -369,7 +369,7 @@ class Overlay : public std::enable_shared_from_this<Overlay> {
#ifndef _WIN32
/**
* Disk-backed mapping from inode number to InodeMetadata.
* Defined below backingOverlay_ because it acquires its own file lock, which
* Defined below inodeCatalog_ because it acquires its own file lock, which
* should be released first during shutdown.
*/
std::unique_ptr<InodeMetadataTable> inodeMetadataTable_;

View File

@ -14,7 +14,7 @@
#include <condition_variable>
#include <optional>
#include "eden/fs/inodes/IFileContentStore.h"
#include "eden/fs/inodes/IOverlay.h"
#include "eden/fs/inodes/InodeCatalog.h"
#include "eden/fs/inodes/InodeNumber.h"
#include "eden/fs/inodes/overlay/gen-cpp2/overlay_types.h"
#include "eden/fs/utils/DirType.h"
@ -246,7 +246,7 @@ class FileContentStore : public IFileContentStore {
* overlay's file system attributes and is responsible for obtaining and
* releasing its locks ("initOverlay" and "close" respectively).
*/
class FsOverlay : public IOverlay {
class FsOverlay : public InodeCatalog {
public:
explicit FsOverlay(FileContentStore* core) : core_(core) {}

View File

@ -16,7 +16,7 @@
#include "eden/fs/config/EdenConfig.h"
#include "eden/fs/inodes/DirEntry.h"
#include "eden/fs/inodes/IOverlay.h"
#include "eden/fs/inodes/InodeCatalog.h"
#include "eden/fs/inodes/Overlay.h"
#include "eden/fs/telemetry/NullStructuredLogger.h"
@ -36,7 +36,7 @@ constexpr uint64_t kIterations = 500000;
void copyOverlayDirectory(
std::shared_ptr<Overlay> overlay,
IOverlay* backingOverlay,
InodeCatalog* inodeCatalog,
const DirContents& contents) {
// Test copying the OverlayDir directly
printf("Overlay data written. Starting benchmark for copies...\n");
@ -49,10 +49,10 @@ void copyOverlayDirectory(
auto inodeNumber = overlay->allocateInodeNumber();
fns.emplace_back(
[backingOverlay,
[inodeCatalog,
inodeNumber,
odir = overlay->serializeOverlayDir(inodeNumber, contents)]() mutable {
backingOverlay->saveOverlayDir(inodeNumber, std::move(odir));
inodeCatalog->saveOverlayDir(inodeNumber, std::move(odir));
});
}
@ -78,7 +78,7 @@ void copyOverlayDirectory(
void serializeOverlayDirectory(
std::shared_ptr<Overlay> overlay,
IOverlay* backingOverlay,
InodeCatalog* inodeCatalog,
const DirContents& contents) {
// Test serialize the OverlayDir into a std::string
printf("Overlay data written. Starting benchmark for serializing...\n");
@ -95,14 +95,14 @@ void serializeOverlayDirectory(
auto serializedOverlayDir =
apache::thrift::CompactSerializer::serialize<std::string>(odir);
fns.emplace_back([backingOverlay,
fns.emplace_back([inodeCatalog,
inodeNumber,
serializedOverlayDir =
std::move(serializedOverlayDir)]() mutable {
auto deserializedOverlayDir =
apache::thrift::CompactSerializer::deserialize<overlay::OverlayDir>(
serializedOverlayDir);
backingOverlay->saveOverlayDir(
inodeCatalog->saveOverlayDir(
inodeNumber, std::move(deserializedOverlayDir));
});
}
@ -170,12 +170,12 @@ void benchmarkOverlayDirSerialization(AbsolutePathPiece overlayPath) {
ObjectId{folly::ByteRange{sp}});
}
IOverlay* backingOverlay = overlay->getRawBackingOverlay();
InodeCatalog* inodeCatalog = overlay->getRawInodeCatalog();
if (FLAGS_copy) {
copyOverlayDirectory(overlay, backingOverlay, contents);
copyOverlayDirectory(overlay, inodeCatalog, contents);
} else {
serializeOverlayDirectory(overlay, backingOverlay, contents);
serializeOverlayDirectory(overlay, inodeCatalog, contents);
}
folly::stop_watch<> closeTimer;

View File

@ -10,7 +10,7 @@
#include <folly/Range.h>
#include <optional>
#include "eden/fs/inodes/IOverlay.h"
#include "eden/fs/inodes/InodeCatalog.h"
#include "eden/fs/inodes/treeoverlay/SqliteTreeStore.h"
#include "eden/fs/model/Tree.h"
#include "eden/fs/utils/ImmediateFuture.h"
@ -28,7 +28,7 @@ class OverlayDir;
}
struct InodeNumber;
class TreeOverlay : public IOverlay {
class TreeOverlay : public InodeCatalog {
public:
explicit TreeOverlay(
AbsolutePathPiece path,

View File

@ -372,7 +372,7 @@ TEST_P(
// from disk since we don't store mode, the flush here makes the tests
// deterministic
if (overlayType() == Overlay::TreeOverlayType::TreeBuffered) {
static_cast<BufferedTreeOverlay*>(overlay->getRawBackingOverlay())->flush();
static_cast<BufferedTreeOverlay*>(overlay->getRawInodeCatalog())->flush();
}
// At the time of writing, the TreeOverlay does not store mode, which is why
@ -405,7 +405,7 @@ TEST_P(
// from disk since we don't store mode, the flush here makes the tests
// deterministic
if (overlayType() == Overlay::TreeOverlayType::TreeBuffered) {
static_cast<BufferedTreeOverlay*>(overlay->getRawBackingOverlay())->flush();
static_cast<BufferedTreeOverlay*>(overlay->getRawInodeCatalog())->flush();
}
// At the time of writing, the TreeOverlay does not store mode, which is why
@ -440,7 +440,7 @@ TEST_P(
// from disk since we don't store mode, the flush here makes the tests
// deterministic
if (overlayType() == Overlay::TreeOverlayType::TreeBuffered) {
static_cast<BufferedTreeOverlay*>(overlay->getRawBackingOverlay())->flush();
static_cast<BufferedTreeOverlay*>(overlay->getRawInodeCatalog())->flush();
}
// At the time of writing, the TreeOverlay does not store mode, which is why