]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore, tools: Fix logging of DBObjectMap check() repairs 13423/head
authorDavid Zafman <dzafman@redhat.com>
Tue, 21 Mar 2017 00:28:45 +0000 (17:28 -0700)
committerDavid Zafman <dzafman@redhat.com>
Mon, 27 Mar 2017 15:33:34 +0000 (08:33 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/os/filestore/DBObjectMap.cc
src/tools/ceph_osdomap_tool.cc

index ed649085274dce8ec18f9f7d7a3445510a84397d..b0430c499e5857c381b95aab3c52579cdccb7c85 100644 (file)
@@ -58,6 +58,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);
@@ -90,6 +91,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);
@@ -135,6 +137,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;
 }
 
@@ -1062,8 +1066,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 0ac44105253f9b418ea052a8e51d64460ebe600b..d27a2802bfb038db2d50fd77c715063c301ac4dc 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") {