From: John Spray Date: Thu, 14 May 2015 14:08:16 +0000 (+0100) Subject: tools: fix journal reset error handling X-Git-Tag: v9.0.3~38^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=56d6be8548ab0bda894df20253a3b713a504b6d9;p=ceph.git tools: fix journal reset error handling 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 --- diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 1bc7b79afc4..d07d48743e2 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -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(); diff --git a/src/tools/cephfs/Resetter.cc b/src/tools/cephfs/Resetter.cc index b96ea028fd1..6beaf98d589 100644 --- a/src/tools/cephfs/Resetter.cc +++ b/src/tools/cephfs/Resetter.cc @@ -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) diff --git a/src/tools/cephfs/Resetter.h b/src/tools/cephfs/Resetter.h index 6f29d67c48f..2baaf47f43a 100644 --- a/src/tools/cephfs/Resetter.h +++ b/src/tools/cephfs/Resetter.h @@ -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_ */