From 1212ceb0137e12b989653cca48b14f93e6848cb1 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 20 Jul 2011 14:30:16 -0700 Subject: [PATCH] Journaler: return errors from probing back to callers. Adjust Dumper to handle the error codes. The other callers already do so! Signed-off-by: Greg Farnum --- src/mds/Dumper.cc | 12 +++++++++++- src/osdc/Journaler.cc | 9 +++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/mds/Dumper.cc b/src/mds/Dumper.cc index af08f3786b459..05fcbbd577697 100644 --- a/src/mds/Dumper.cc +++ b/src/mds/Dumper.cc @@ -84,15 +84,24 @@ void Dumper::dump(const char *dump_file) { bool done = false; Cond cond; + int r = 0; int rank = strtol(g_conf->name.get_id().c_str(), 0, 0); inodeno_t ino = MDS_INO_LOG_OFFSET + rank; lock.Lock(); - journaler->recover(new C_SafeCond(&lock, &cond, &done)); + journaler->recover(new C_SafeCond(&lock, &cond, &done, &r)); while (!done) cond.Wait(lock); lock.Unlock(); + if (r < 0) { // Error + derr << "error on recovery: " << cpp_strerror(r) << dendl; + messenger->shutdown(); + // wait for messenger to finish + messenger->wait(); + shutdown(); + } + uint64_t start = journaler->get_read_pos(); uint64_t end = journaler->get_write_pos(); uint64_t len = end-start; @@ -136,6 +145,7 @@ void Dumper::dump(const char *dump_file) int err = errno; derr << "unable to open " << dump_file << ": " << cpp_strerror(err) << dendl; } + messenger->shutdown(); // wait for messenger to finish diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index 43eca74aa0dde..ab19c50843554 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -255,7 +255,6 @@ void Journaler::reprobe(Context *finish) void Journaler::_finish_reprobe(int r, uint64_t new_end, Context *onfinish) { assert(new_end >= write_pos); - assert(r >= 0); ldout(cct, 1) << "_finish_reprobe new_end = " << new_end << " (header had " << write_pos << ")." << dendl; @@ -268,7 +267,9 @@ void Journaler::_finish_reprobe(int r, uint64_t new_end, Context *onfinish) { void Journaler::_finish_probe_end(int r, uint64_t end) { assert(state == STATE_PROBING); - + if (r < 0) { // error in probing + goto out; + } if (((int64_t)end) == -1) { end = write_pos; ldout(cct, 1) << "_finish_probe_end write_pos = " << end @@ -277,7 +278,6 @@ void Journaler::_finish_probe_end(int r, uint64_t end) assert(0); // hrm. } else { assert(end >= write_pos); - assert(r >= 0); ldout(cct, 1) << "_finish_probe_end write_pos = " << end << " (header had " << write_pos << "). recovered." << dendl; @@ -287,10 +287,11 @@ void Journaler::_finish_probe_end(int r, uint64_t end) prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = end; +out: // done. list ls; ls.swap(waitfor_recover); - finish_contexts(cct, ls, 0); + finish_contexts(cct, ls, r); } class Journaler::C_RereadHeadProbe : public Context -- 2.39.5