mirror of
https://github.com/deepseek-ai/3FS
synced 2025-06-26 18:16:45 +00:00
Merge e26f5a901a into 91bfcf3606
This commit is contained in:
@@ -162,112 +162,4 @@ TYPED_TEST(TestScan, Exit) {
|
||||
ASSERT_FALSE(entries.empty());
|
||||
}
|
||||
|
||||
DEFINE_string(fdb_cluster, "", "fdb cluster file path");
|
||||
DEFINE_uint32(scan_threads, 4, "scan threads");
|
||||
DEFINE_uint32(scan_coroutines, 8, "scan coroutines");
|
||||
DEFINE_bool(scan_all, false, "scan all inodes and direntries");
|
||||
DEFINE_bool(scan_check, false, "check parent exists");
|
||||
|
||||
TEST(TestScanFDB, DISABLED_FDB) {
|
||||
MetaScan::Options options;
|
||||
options.fdb_cluster_file = FLAGS_fdb_cluster;
|
||||
options.threads = FLAGS_scan_threads;
|
||||
options.coroutines = FLAGS_scan_coroutines;
|
||||
MetaScan scan(options);
|
||||
|
||||
std::set<InodeId> directories;
|
||||
std::set<InodeId> missing;
|
||||
|
||||
auto begin = SteadyClock::now();
|
||||
size_t totalInodes = 0;
|
||||
while (true) {
|
||||
auto inodes = scan.getInodes();
|
||||
totalInodes += inodes.size();
|
||||
if (inodes.empty() || !FLAGS_scan_all) {
|
||||
break;
|
||||
}
|
||||
if (FLAGS_scan_check) {
|
||||
for (auto &inode : inodes) {
|
||||
if (inode.isDirectory()) {
|
||||
directories.insert(inode.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
XLOGF(DBG, "MetaScan get {} inodes", inodes.size());
|
||||
}
|
||||
XLOGF(INFO,
|
||||
"MetaScan scan Inode finished, duration {}, get {} inodes\n",
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(SteadyClock::now() - begin),
|
||||
totalInodes);
|
||||
|
||||
begin = SteadyClock::now();
|
||||
size_t totalEntries = 0;
|
||||
while (true) {
|
||||
auto entries = scan.getDirEntries();
|
||||
totalEntries += entries.size();
|
||||
if (entries.empty() || !FLAGS_scan_all) {
|
||||
break;
|
||||
}
|
||||
if (FLAGS_scan_check) {
|
||||
for (auto &entry : entries) {
|
||||
if (!directories.contains(entry.parent)) {
|
||||
missing.insert(entry.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
XLOGF(DBG, "MetaScan get {} entries", entries.size());
|
||||
}
|
||||
XLOGF(INFO,
|
||||
"MetaScan scan DirEntry finished, duration {}, get {} entries",
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(SteadyClock::now() - begin),
|
||||
totalEntries);
|
||||
XLOGF_IF(WARNING, !missing.empty(), "Missing parent: {}", fmt::join(missing.begin(), missing.end(), ", "));
|
||||
}
|
||||
|
||||
DEFINE_int64(inode_id, 0, "inode id");
|
||||
|
||||
TEST(TestScanFDB, DISABLED_PrintInode) {
|
||||
MetaScan::Options options;
|
||||
options.fdb_cluster_file = FLAGS_fdb_cluster;
|
||||
options.threads = FLAGS_scan_threads;
|
||||
options.coroutines = FLAGS_scan_coroutines;
|
||||
MetaScan scan(options);
|
||||
auto &kv = scan.kvEngine();
|
||||
|
||||
folly::coro::blockingWait([&]() -> CoTask<void> {
|
||||
auto txn = kv.createReadonlyTransaction();
|
||||
auto inodeId = InodeId(FLAGS_inode_id);
|
||||
auto inode = co_await Inode::snapshotLoad(*txn, inodeId);
|
||||
CO_ASSERT_OK(inode);
|
||||
if (inode->has_value()) {
|
||||
fmt::print("inode: {}\n", **inode);
|
||||
} else {
|
||||
fmt::print("inode {} doesn't exist!", inodeId);
|
||||
}
|
||||
fmt::print("============\n");
|
||||
|
||||
std::string prev;
|
||||
while (true) {
|
||||
auto txn = kv.createReadonlyTransaction();
|
||||
auto entries = co_await DirEntryList::snapshotLoad(*txn, inodeId, prev, -1);
|
||||
CO_ASSERT_OK(entries);
|
||||
for (auto entry : entries->entries) {
|
||||
auto inode = co_await Inode::snapshotLoad(*kv.createReadWriteTransaction(), entry.id);
|
||||
CO_ASSERT_OK(inode);
|
||||
fmt::print("entry: {} inode: {}\n", entry, inode->has_value() ? fmt::format("{}", **inode) : "");
|
||||
prev = entry.name;
|
||||
}
|
||||
if (!entries->more) break;
|
||||
}
|
||||
fmt::print("============\n");
|
||||
|
||||
if (inode->has_value() && inode->value().isDirectory()) {
|
||||
auto txn = kv.createReadonlyTransaction();
|
||||
auto entry = co_await inode->value().snapshotLoadDirEntry(*txn);
|
||||
CO_ASSERT_OK(entry);
|
||||
fmt::print("entry points to {}: {}\n", inodeId, *entry);
|
||||
}
|
||||
}());
|
||||
}
|
||||
|
||||
} // namespace hf3fs::meta::server
|
||||
|
||||
Reference in New Issue
Block a user