From 66f3bd6278222351946e505e823a613fbb76710f Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 19 Jan 2015 15:16:46 +0000 Subject: [PATCH] tools: output per-event errors from recover dentries --- src/tools/cephfs/EventOutput.cc | 10 ++++++++++ src/tools/cephfs/JournalScanner.h | 15 +++++++++++++++ src/tools/cephfs/JournalTool.cc | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/tools/cephfs/EventOutput.cc b/src/tools/cephfs/EventOutput.cc index 6af9497fd4fd..342489952e20 100644 --- a/src/tools/cephfs/EventOutput.cc +++ b/src/tools/cephfs/EventOutput.cc @@ -120,4 +120,14 @@ void EventOutput::summary() const for (std::map::iterator i = type_count.begin(); i != type_count.end(); ++i) { std::cout << " " << i->first << ": " << i->second << std::endl; } + + std::cout << "Errors: " << scan.errors.size() << std::endl; + if (scan.errors.size()) { + for (JournalScanner::ErrorMap::const_iterator i = scan.errors.begin(); + i != scan.errors.end(); ++i) { + std::cout << " 0x" << std::hex << i->first << std::dec + << ": " << i->second.r << " " + << i->second.description << std::endl; + } + } } diff --git a/src/tools/cephfs/JournalScanner.h b/src/tools/cephfs/JournalScanner.h index 2700f2b14872..eb0218df294d 100644 --- a/src/tools/cephfs/JournalScanner.h +++ b/src/tools/cephfs/JournalScanner.h @@ -85,7 +85,17 @@ class JournalScanner LogEvent *log_event; uint32_t raw_size; //< Size from start offset including all encoding overhead }; + + class EventError { + public: + int r; + std::string description; + EventError(int r_, const std::string &desc_) + : r(r_), description(desc_) {} + }; + typedef std::map EventMap; + typedef std::map ErrorMap; typedef std::pair Range; bool pointer_present; bool pointer_valid; @@ -101,6 +111,11 @@ class JournalScanner std::vector events_valid; EventMap events; + // For events present in ::events (i.e. scanned successfully), + // any subsequent errors handling them (e.g. replaying) + ErrorMap errors; + + private: // Forbid copy construction because I have ptr members JournalScanner(const JournalScanner &rhs); diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 81bd9b55ce79..611832043594 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -368,7 +368,10 @@ int JournalTool::main_event(std::vector &argv) if (r == 0) { r = scav_r; } - // Our goal is to read all we can, so don't stop on errors + // Our goal is to read all we can, so don't stop on errors, but + // do record them for possible later output + js.errors.insert(std::make_pair(i->first, + JournalScanner::EventError(scav_r, cpp_strerror(r)))); } } } -- 2.47.3