rename FsOverlay to FsInodeCatalog

Summary: Following the `IOverlay` -> `InodeCatalog` change, this propagates the rename to the `FsOverlay` class

Reviewed By: chadaustin

Differential Revision: D40520540

fbshipit-source-id: 5afd6e6d9c8f5e97c379f09e48c4680469fe9a73
This commit is contained in:
Genevieve (Genna) Helsel 2022-10-31 12:16:16 -07:00 committed by Facebook GitHub Bot
parent 4857402d1c
commit 2d3ada78d0
10 changed files with 50 additions and 44 deletions

View File

@ -77,7 +77,7 @@ std::unique_ptr<InodeCatalog> makeInodeCatalog(
}
return std::make_unique<TreeOverlay>(localDir);
#else
return std::make_unique<FsOverlay>(
return std::make_unique<FsInodeCatalog>(
static_cast<FileContentStore*>(fileContentStore));
#endif
}
@ -257,7 +257,7 @@ void Overlay::initOverlay(
// Therefore OverlayChecker must not exist longer than this initOverlay
// call.
OverlayChecker checker(
static_cast<FsOverlay*>(inodeCatalog_.get()),
static_cast<FsInodeCatalog*>(inodeCatalog_.get()),
static_cast<FileContentStore*>(fileContentStore_.get()),
std::nullopt,
lookupCallback);

View File

@ -26,7 +26,7 @@
#include "eden/fs/utils/PathFuncs.h"
#ifndef _WIN32
#include "eden/fs/inodes/fsoverlay/FsOverlay.h"
#include "eden/fs/inodes/fsoverlay/FsInodeCatalog.h"
#endif
namespace facebook::eden {

View File

@ -7,7 +7,7 @@
#ifndef _WIN32
#include "eden/fs/inodes/fsoverlay/FsOverlay.h"
#include "eden/fs/inodes/fsoverlay/FsInodeCatalog.h"
#include <boost/filesystem.hpp>
#include <algorithm>
@ -81,7 +81,7 @@ static void doFormatSubdirPath(
subdirPath[1] = hexdigit[inodeNum & 0xf];
}
bool FsOverlay::initialized() const {
bool FsInodeCatalog::initialized() const {
return core_->initialized();
}
@ -140,7 +140,8 @@ bool FileContentStore::initialize(bool createIfNonExisting) {
return overlayCreated;
}
std::optional<InodeNumber> FsOverlay::initOverlay(bool createIfNonExisting) {
std::optional<InodeNumber> FsInodeCatalog::initOverlay(
bool createIfNonExisting) {
bool overlayCreated = core_->initialize(createIfNonExisting);
if (overlayCreated) {
@ -160,7 +161,7 @@ void FileContentStore::close() {
infoFile_.close();
}
void FsOverlay::close(std::optional<InodeNumber> inodeNumber) {
void FsInodeCatalog::close(std::optional<InodeNumber> inodeNumber) {
if (inodeNumber) {
core_->saveNextInodeNumber(inodeNumber.value());
}
@ -302,19 +303,19 @@ void FileContentStore::initNewOverlay() {
.value();
}
optional<overlay::OverlayDir> FsOverlay::loadOverlayDir(
optional<overlay::OverlayDir> FsInodeCatalog::loadOverlayDir(
InodeNumber inodeNumber) {
return core_->deserializeOverlayDir(inodeNumber);
}
std::optional<overlay::OverlayDir> FsOverlay::loadAndRemoveOverlayDir(
std::optional<overlay::OverlayDir> FsInodeCatalog::loadAndRemoveOverlayDir(
InodeNumber inodeNumber) {
auto result = loadOverlayDir(inodeNumber);
removeOverlayDir(inodeNumber);
return result;
}
void FsOverlay::saveOverlayDir(
void FsInodeCatalog::saveOverlayDir(
InodeNumber inodeNumber,
overlay::OverlayDir&& odir) {
// Ask thrift to serialize it.
@ -651,7 +652,7 @@ void FileContentStore::removeOverlayFile(InodeNumber inodeNumber) {
}
}
void FsOverlay::removeOverlayDir(InodeNumber inodeNumber) {
void FsInodeCatalog::removeOverlayDir(InodeNumber inodeNumber) {
core_->removeOverlayFile(inodeNumber);
}
@ -668,7 +669,7 @@ bool FileContentStore::hasOverlayFile(InodeNumber inodeNumber) {
}
}
bool FsOverlay::hasOverlayDir(InodeNumber inodeNumber) {
bool FsInodeCatalog::hasOverlayDir(InodeNumber inodeNumber) {
return core_->hasOverlayFile(inodeNumber);
}

View File

@ -63,8 +63,9 @@ class FileContentStore : public IFileContentStore {
/**
* This entrypoint is used by the OverlayChecker which needs the localDir
* value but only has a pointer to the backing FsOverlay object. In most cases
* one should get the localDir by calling `Overlay::getLocalDir` instead.
* value but only has a pointer to the backing FsInodeCatalog object. In most
* cases one should get the localDir by calling `Overlay::getLocalDir`
* instead.
*/
const AbsolutePath& getLocalDir() const {
return localDir_;
@ -173,7 +174,7 @@ class FileContentStore : public IFileContentStore {
private:
FRIEND_TEST(OverlayTest, getFilePath);
friend class RawOverlayTest;
friend class FsOverlay;
friend class FsInodeCatalog;
void initNewOverlay();
@ -242,13 +243,13 @@ class FileContentStore : public IFileContentStore {
};
/**
* FsOverlay provides interfaces to manipulate the overlay. It stores the
* FsInodeCatalog provides interfaces to manipulate the overlay. It stores the
* overlay's file system attributes and is responsible for obtaining and
* releasing its locks ("initOverlay" and "close" respectively).
*/
class FsOverlay : public InodeCatalog {
class FsInodeCatalog : public InodeCatalog {
public:
explicit FsOverlay(FileContentStore* core) : core_(core) {}
explicit FsInodeCatalog(FileContentStore* core) : core_(core) {}
bool supportsSemanticOperations() const override {
return false;
@ -269,7 +270,7 @@ class FsOverlay : public InodeCatalog {
void close(std::optional<InodeNumber> nextInodeNumber) override;
/**
* Was FsOverlay initialized - i.e., is cleanup (close) necessary.
* Was FsInodeCatalog initialized - i.e., is cleanup (close) necessary.
*/
bool initialized() const override;

View File

@ -8,7 +8,7 @@
#pragma once
#include <folly/Range.h>
#include "eden/fs/inodes/fsoverlay/FsOverlay.h"
#include "eden/fs/inodes/fsoverlay/FsInodeCatalog.h"
#include "eden/fs/utils/PathFuncs.h"
namespace facebook::eden {

View File

@ -25,7 +25,7 @@
#include <folly/logging/xlog.h>
#include <thrift/lib/cpp2/protocol/Serializer.h>
#include "eden/fs/inodes/fsoverlay/FsOverlay.h"
#include "eden/fs/inodes/fsoverlay/FsInodeCatalog.h"
#include "eden/fs/utils/EnumValue.h"
using apache::thrift::CompactSerializer;
@ -58,14 +58,14 @@ struct OverlayChecker::InodeInfo {
};
struct OverlayChecker::Impl {
FsOverlay* const fs;
FsInodeCatalog* const fs;
FileContentStore* const fcs;
std::optional<InodeNumber> loadedNextInodeNumber;
LookupCallback& lookupCallback;
std::unordered_map<InodeNumber, InodeInfo> inodes;
Impl(
FsOverlay* fs,
FsInodeCatalog* fs,
FileContentStore* fcs,
std::optional<InodeNumber> nextInodeNumber,
LookupCallback& lookupCallback)
@ -110,7 +110,7 @@ class OverlayChecker::RepairState {
OverlayChecker* checker() {
return checker_;
}
FsOverlay* fs() {
FsInodeCatalog* fs() {
return checker_->impl_->fs;
}
FileContentStore* fcs() {
@ -750,7 +750,7 @@ class OverlayChecker::BadNextInodeNumber : public OverlayChecker::Error {
};
OverlayChecker::OverlayChecker(
FsOverlay* fs,
FsInodeCatalog* fs,
FileContentStore* fcs,
optional<InodeNumber> nextInodeNumber,
LookupCallback& lookupCallback)

View File

@ -23,7 +23,7 @@ class File;
namespace facebook::eden {
class FsOverlay;
class FsInodeCatalog;
class FileContentStore;
/**
@ -59,13 +59,13 @@ class OverlayChecker {
/**
* Create a new OverlayChecker.
*
* The OverlayChecker stores a raw pointer to the FsOverlay and
* The OverlayChecker stores a raw pointer to the FsInodeCatalog and
* FileContentStore for the duration of the check operation. The caller is
* responsible for ensuring that the FsOverlay and FileContentStore objects
* exist for at least as long as the OverlayChecker object.
* responsible for ensuring that the FsInodeCatalog and FileContentStore
* objects exist for at least as long as the OverlayChecker object.
*/
OverlayChecker(
FsOverlay* fs,
FsInodeCatalog* fs,
FileContentStore* fcs,
std::optional<InodeNumber> nextInodeNumber,
LookupCallback& lookupCallback);

View File

@ -14,7 +14,7 @@
#include <folly/logging/xlog.h>
#include <folly/portability/GFlags.h>
#include "eden/fs/inodes/fsoverlay/FsOverlay.h"
#include "eden/fs/inodes/fsoverlay/FsInodeCatalog.h"
#include "eden/fs/inodes/fsoverlay/OverlayChecker.h"
FOLLY_INIT_LOGGING_CONFIG("eden=DBG2; default:async=true");
@ -35,13 +35,14 @@ int main(int argc, char** argv) {
}
std::optional<FileContentStore> fileContentStore;
std::optional<FsOverlay> fsOverlay;
std::optional<FsInodeCatalog> fsInodeCatalog;
std::optional<InodeNumber> nextInodeNumber;
auto overlayPath = normalizeBestEffort(argv[1]);
try {
fileContentStore.emplace(overlayPath);
fsOverlay.emplace(&fileContentStore.value());
nextInodeNumber = fsOverlay->initOverlay(/*createIfNonExisting=*/false);
fsInodeCatalog.emplace(&fileContentStore.value());
nextInodeNumber =
fsInodeCatalog->initOverlay(/*createIfNonExisting=*/false);
} catch (std::exception& ex) {
XLOG(ERR) << "unable to open overlay: " << folly::exceptionStr(ex);
return 1;
@ -56,14 +57,17 @@ int main(int argc, char** argv) {
std::runtime_error("no lookup callback"));
};
OverlayChecker checker(
&fsOverlay.value(), &fileContentStore.value(), nextInodeNumber, lookup);
&fsInodeCatalog.value(),
&fileContentStore.value(),
nextInodeNumber,
lookup);
checker.scanForErrors();
if (FLAGS_dry_run) {
checker.logErrors();
fsOverlay->close(nextInodeNumber);
fsInodeCatalog->close(nextInodeNumber);
} else {
checker.repairErrors();
fsOverlay->close(checker.getNextInodeNumber());
fsInodeCatalog->close(checker.getNextInodeNumber());
}
return 0;
}

View File

@ -14,7 +14,7 @@
#include <folly/portability/GMock.h>
#include <folly/portability/GTest.h>
#include "eden/fs/inodes/fsoverlay/FsOverlay.h"
#include "eden/fs/inodes/fsoverlay/FsInodeCatalog.h"
#include "eden/fs/inodes/fsoverlay/OverlayChecker.h"
#include "eden/fs/model/ObjectId.h"
#include "eden/fs/testharness/TempFile.h"
@ -52,7 +52,7 @@ class TestOverlay : public std::enable_shared_from_this<TestOverlay> {
return fcs_;
}
FsOverlay& fs() {
FsInodeCatalog& fs() {
return fs_;
}
@ -82,7 +82,7 @@ class TestOverlay : public std::enable_shared_from_this<TestOverlay> {
folly::test::TemporaryDirectory tmpDir_;
AbsolutePath tmpDirPath_;
FileContentStore fcs_;
FsOverlay fs_;
FsInodeCatalog fs_;
uint64_t nextInodeNumber_{0};
};
@ -332,7 +332,7 @@ TEST(Fsck, testNoErrors) {
overlay->closeCleanly();
FileContentStore fcs(overlay->overlayPath());
FsOverlay fs(&fcs);
FsInodeCatalog fs(&fcs);
auto nextInode = fs.initOverlay(/*createIfNonExisting=*/false);
OverlayChecker::LookupCallback lookup = [](auto&&) {
return makeImmediateFuture<OverlayChecker::LookupCallbackValue>(
@ -368,7 +368,7 @@ TEST(Fsck, testMissingNextInodeNumber) {
overlay->fs().close(std::nullopt);
FileContentStore fcs(overlay->overlayPath());
FsOverlay fs(&fcs);
FsInodeCatalog fs(&fcs);
auto nextInode = fs.initOverlay(/*createIfNonExisting=*/false);
// Confirm there is no next inode data
EXPECT_FALSE(nextInode.has_value());
@ -397,7 +397,7 @@ TEST(Fsck, testBadNextInodeNumber) {
overlay->fs().close(InodeNumber(2));
FileContentStore fcs(overlay->overlayPath());
FsOverlay fs(&fcs);
FsInodeCatalog fs(&fcs);
auto nextInode = fs.initOverlay(/*createIfNonExisting=*/false);
EXPECT_EQ(2, nextInode ? nextInode->get() : 0);
OverlayChecker::LookupCallback lookup = [](auto&&) {

View File

@ -8,7 +8,7 @@
#ifndef _WIN32
#include "eden/fs/inodes/Overlay.h"
#include "eden/fs/inodes/fsoverlay/FsOverlay.h"
#include "eden/fs/inodes/fsoverlay/FsInodeCatalog.h"
#include "eden/fs/inodes/test/OverlayTestUtil.h"
#include <folly/Exception.h>