]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: fix journal reset error handling
authorJohn Spray <john.spray@redhat.com>
Thu, 14 May 2015 14:08:16 +0000 (15:08 +0100)
committerJohn Spray <john.spray@redhat.com>
Mon, 13 Jul 2015 13:05:16 +0000 (14:05 +0100)
When we failed and prompted for --force, it still
looked like a success.  ::reset never had any
proper error handling since it was lifted out
of the MDS, so add it now.

Signed-off-by: John Spray <john.spray@redhat.com>
src/tools/cephfs/JournalTool.cc
src/tools/cephfs/Resetter.cc
src/tools/cephfs/Resetter.h

index 1bc7b79afc4f5b624d0842f3c170365bef20b014..d07d48743e2df937b2f5c43db255c66d9c87826a 100644 (file)
@@ -564,9 +564,9 @@ int JournalTool::journal_reset(bool hard)
   }
 
   if (hard) {
-    resetter.reset_hard(rank);
+    r = resetter.reset_hard(rank);
   } else {
-    resetter.reset(rank);
+    r = resetter.reset(rank);
   }
   resetter.shutdown();
 
index b96ea028fd18acb48a2c08de5c131087d3d89902..6beaf98d5899db95b5f89c5159d84a75a0abd8c3 100644 (file)
@@ -25,7 +25,7 @@
 
 #define dout_subsys ceph_subsys_mds
 
-void Resetter::reset(int rank)
+int Resetter::reset(int rank)
 {
   Mutex mylock("Resetter::reset::lock");
   Cond cond;
@@ -37,7 +37,7 @@ void Resetter::reset(int rank)
   if (jp_load_result != 0) {
     std::cerr << "Error loading journal: " << cpp_strerror(jp_load_result) <<
       ", pass --force to forcibly reset this journal" << std::endl;
-    return;
+    return jp_load_result;
   }
 
   Journaler journaler(jp.front,
@@ -58,19 +58,12 @@ void Resetter::reset(int rank)
     if (r == -ENOENT) {
       cerr << "journal does not exist on-disk. Did you set a bad rank?"
           << std::endl;
-      std::cerr << "Error loading journal: " << cpp_strerror(jp_load_result) <<
+      std::cerr << "Error loading journal: " << cpp_strerror(r) <<
         ", pass --force to forcibly reset this journal" << std::endl;
-      std::cerr << "Falling back to hard reset..." << std::endl;
-      r = reset_hard(rank);
-      if (r != 0) {
-        std::cerr << "Hard reset failed: " << cpp_strerror(r) << std::endl;
-      } else {
-        std::cerr << "Hard reset successful." << std::endl;
-      }
-      return;
+      return r;
     } else {
-      cerr << "got error " << r << "from Journaler, failling" << std::endl;
-      return;
+      cerr << "got error " << r << "from Journaler, failing" << std::endl;
+      return r;
     }
   }
 
@@ -100,14 +93,20 @@ void Resetter::reset(int rank)
   mylock.Unlock();
     
   lock.Lock();
-  assert(r == 0);
+  if (r != 0) {
+    return r;
+  }
 
   r = _write_reset_event(&journaler);
-  assert(r == 0);
+  if (r != 0) {
+    return r;
+  }
 
   lock.Unlock();
 
   cout << "done" << std::endl;
+
+  return 0;
 }
 
 int Resetter::reset_hard(int rank)
index 6f29d67c48fd0bd3c55011f8143ef6361122d6ce..2baaf47f43a630e77a84f6045961ea93ef6750d3 100644 (file)
@@ -37,7 +37,7 @@ public:
    * out from scratch.
    */
   int reset_hard(int rank);
-  void reset(int rank);
+  int reset(int rank);
 };
 
 #endif /* JOURNAL_RESETTER_H_ */