lizardfs/0001-master-Fix-issues-with...

120 lines
4.0 KiB
Diff

From 0ff659db5d0847db2aa0d59be4955c16012d6fc2 Mon Sep 17 00:00:00 2001
From: Piotr Sarna <sarna@skytechnology.pl>
Date: Mon, 12 Jun 2017 12:41:56 +0200
Subject: [PATCH 1/3] master: Fix issues with reporting defective files
This commit fixes printing paths for trash/reserved files
in defective files report and adds missing counter increments
in fs_test_getdata loop.
Fixes #565
Change-Id: Ifb3932800b1d7998ff55cecb09fcc28a5dbc4717
---
src/master/filesystem_periodic.cc | 59 ++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 28 deletions(-)
diff --git a/src/master/filesystem_periodic.cc b/src/master/filesystem_periodic.cc
index d9fab6f9..8b7913fb 100644
--- a/src/master/filesystem_periodic.cc
+++ b/src/master/filesystem_periodic.cc
@@ -92,36 +92,11 @@ void fs_background_task_manager_work() {
}
}
-std::vector<DefectiveFileInfo> fs_get_defective_nodes_info(uint8_t requested_flags, uint64_t max_entries,
- uint64_t &entry_index) {
- FSNode *node;
- FSNodeDirectory *parent;
- std::string file_path;
- std::vector<DefectiveFileInfo> defective_nodes_info;
- ActiveLoopWatchdog watchdog;
- defective_nodes_info.reserve(max_entries);
- auto it = gDefectiveNodes.find_nth(entry_index);
- watchdog.start();
- for (uint64_t i = 0; i < max_entries && it != gDefectiveNodes.end(); ++it) {
- if (((*it).second & requested_flags) != 0) {
- node = fsnodes_id_to_node<FSNode>((*it).first);
- parent = fsnodes_get_first_parent(node);
- fsnodes_getpath(parent, node, file_path);
- file_path = "/" + file_path;
- defective_nodes_info.emplace_back(file_path, (*it).second);
- ++i;
- }
- ++entry_index;
- if (watchdog.expired()) {
- return defective_nodes_info;
- }
- }
- entry_index = 0;
- return defective_nodes_info;
-}
-
static std::string get_node_info(FSNode *node) {
std::string name;
+ if (node == nullptr) {
+ return name;
+ }
if (node->type == FSNode::kTrash) {
name = "file in trash " + std::to_string(node->id) + ": " +
(std::string)gMetadata->trash.at(TrashPathKey(node));
@@ -157,6 +132,30 @@ static std::string get_node_info(FSNode *node) {
return fsnodes_escape_name(name);
}
+std::vector<DefectiveFileInfo> fs_get_defective_nodes_info(uint8_t requested_flags, uint64_t max_entries,
+ uint64_t &entry_index) {
+ FSNode *node;
+ std::vector<DefectiveFileInfo> defective_nodes_info;
+ ActiveLoopWatchdog watchdog;
+ defective_nodes_info.reserve(max_entries);
+ auto it = gDefectiveNodes.find_nth(entry_index);
+ watchdog.start();
+ for (uint64_t i = 0; i < max_entries && it != gDefectiveNodes.end(); ++it) {
+ if (((*it).second & requested_flags) != 0) {
+ node = fsnodes_id_to_node<FSNode>((*it).first);
+ std::string info = get_node_info(node);
+ defective_nodes_info.emplace_back(std::move(info), (*it).second);
+ ++i;
+ }
+ ++entry_index;
+ if (watchdog.expired()) {
+ return defective_nodes_info;
+ }
+ }
+ entry_index = 0;
+ return defective_nodes_info;
+}
+
void fs_test_getdata(uint32_t &loopstart, uint32_t &loopend, uint32_t &files, uint32_t &ugfiles,
uint32_t &mfiles, uint32_t &chunks, uint32_t &ugchunks, uint32_t &mchunks,
std::string &result) {
@@ -170,6 +169,8 @@ void fs_test_getdata(uint32_t &loopstart, uint32_t &loopend, uint32_t &files, ui
FSNode *node = fsnodes_id_to_node<FSNode>(entry.first);
if (!node) {
+ report << "Structure error in defective list, entry " << std::to_string(entry.first) << "\n";
+ errors++;
continue;
}
@@ -213,6 +214,7 @@ void fs_test_getdata(uint32_t &loopstart, uint32_t &loopend, uint32_t &files, ui
report << "*";
}
report << " currently unavailable " << name << "\n";
+ errors++;
}
if (errors >= ERRORS_LOG_MAX) {
@@ -222,6 +224,7 @@ void fs_test_getdata(uint32_t &loopstart, uint32_t &loopend, uint32_t &files, ui
if (entry.second & kStructureError) {
std::string name = get_node_info(node);
report << "Structure error in " << name << "\n";
+ errors++;
}
if (errors >= ERRORS_LOG_MAX) {
--
2.13.0