From bf0675fa47df63345adc6ea8b9b26bb7e8b4af77 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 16 Dec 2010 16:47:30 -0800 Subject: [PATCH] journaler: Add init_headers function, call when reading head off disk. Uninitialized headers were causing a failed assert during replay, and there's no good reason to leave them set at their defaults just because the *current* incarnation of this MDS has never written to disk! Signed-off-by: Greg Farnum --- src/mds/MDS.cc | 2 +- src/osdc/Journaler.cc | 3 +++ src/osdc/Journaler.h | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index ecdf91a32764c..7e2d4f49304cb 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -1228,7 +1228,7 @@ public: C_MDS_RestartReplay(MDS *mds_, uint64_t old_read_pos_) : mds(mds_), old_read_pos(old_read_pos_) {} void finish(int r) { - if (old_read_pos < mds->mdlog->get_journaler()->get_expire_pos()) { + if (old_read_pos < mds->mdlog->get_journaler()->get_trimmed_pos()) { cerr << "standby MDS fell behind active MDS journal's expire_pos, restarting" << std::endl; mds->respawn(); /* we're too far back, and this is easier than trying to reset everything in the cache, etc */ diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index 0f22c7b897545..c6148b775d468 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -166,6 +166,7 @@ void Journaler::_finish_reread_head(int r, bufferlist& bl, Context *finish) write_pos = flush_pos = h.write_pos; expire_pos = h.expire_pos; trimmed_pos = h.trimmed_pos; + init_headers(h); state = STATE_ACTIVE; finish->finish(r); } @@ -203,6 +204,8 @@ void Journaler::_finish_read_head(int r, bufferlist& bl) read_pos = requested_pos = received_pos = expire_pos = h.expire_pos; trimmed_pos = trimming_pos = h.trimmed_pos; + init_headers(h); + dout(1) << "_finish_read_head " << h << ". probing for end of log (from " << write_pos << ")..." << dendl; C_ProbeEnd *fin = new C_ProbeEnd(this); state = STATE_PROBING; diff --git a/src/osdc/Journaler.h b/src/osdc/Journaler.h index 2c709f695e894..a2b0fef40b7e0 100644 --- a/src/osdc/Journaler.h +++ b/src/osdc/Journaler.h @@ -219,6 +219,13 @@ private: class C_Trim; friend class C_Trim; + // only init_headers when following or first reading off-disk + void init_headers(Header& h) { + assert(readonly || + state == STATE_READHEAD); + last_written = last_committed = h; + } + public: Journaler(inodeno_t ino_, int pool, const char *mag, Objecter *obj, Logger *l, int lkey, SafeTimer *tim) : last_written(mag), last_committed(mag), -- 2.39.5