]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore, tools: Fix logging of DBObjectMap check() repairs 14204/head
authorDavid Zafman <dzafman@redhat.com>
Tue, 21 Mar 2017 00:28:45 +0000 (17:28 -0700)
committerDavid Zafman <dzafman@redhat.com>
Wed, 26 Apr 2017 21:03:54 +0000 (14:03 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 1704f62c0831e6b07138f7dd14a89fef3c9ed2c1)

src/os/filestore/DBObjectMap.cc
src/tools/ceph_osdomap_tool.cc

index a415e380ff7c3e00e0d753b807311464953d6747..44d48cc436fdba151b9f5e1184439caf3c9dd152 100644 (file)
@@ -57,6 +57,7 @@ static void append_escaped(const string &in, string *out)
 int DBObjectMap::check(std::ostream &out, bool repair)
 {
   int errors = 0;
+  bool repaired = false;
   map<uint64_t, uint64_t> parent_to_num_children;
   map<uint64_t, uint64_t> parent_to_actual_num_children;
   KeyValueDB::Iterator iter = db->get_iterator(HOBJECT_TO_SEQ);
@@ -89,6 +90,7 @@ int DBObjectMap::check(std::ostream &out, bool repair)
           out << complete_iter->key() << " -> " << string(complete_iter->value().c_str(), complete_iter->value().length() - 1) << std::endl;
         }
         if (repair) {
+          repaired = true;
           KeyValueDB::Transaction t = db->get_transaction();
           t->rmkeys_by_prefix(USER_PREFIX + header_key(header.seq) + COMPLETE_PREFIX);
           db->submit_transaction(t);
@@ -134,6 +136,8 @@ int DBObjectMap::check(std::ostream &out, bool repair)
     }
     parent_to_actual_num_children.erase(i->first);
   }
+  if (errors == 0 && repaired)
+    return -1;
   return errors;
 }
 
@@ -1060,8 +1064,9 @@ int DBObjectMap::init(bool do_upgrade)
   ostringstream ss;
   int errors = check(ss, true);
   if (errors) {
-    dout(5) << ss.str() << dendl;
-    return -EINVAL;
+    derr << ss.str() << dendl;
+    if (errors > 0)
+      return -EINVAL;
   }
   dout(20) << "(init)dbobjectmap: seq is " << state.seq << dendl;
   return 0;
index 57cc3ecc01925b6732aaf8417c7685d7a5bd8fec..99974713df7507141a7c2459e818ab349a75cca0 100644 (file)
@@ -164,11 +164,13 @@ int main(int argc, char **argv) {
     ostringstream ss;
     bool repair = (cmd == "repair");
     r = omap.check(ss, repair);
-    if (r > 0) {
+    if (r) {
       std::cerr << ss.str() << std::endl;
-      std::cerr << "check got " << r << " error(s)" << std::endl;
-      r = 1;
-      goto done;
+      if (r > 0) {
+        std::cerr << "check got " << r << " error(s)" << std::endl;
+        r = 1;
+        goto done;
+      }
     }
     std::cout << (repair ? "repair" : "check") << " succeeded" << std::endl;
   } else if (cmd == "dump-headers") {