From: Greg Farnum Date: Fri, 17 Dec 2010 00:47:30 +0000 (-0800) Subject: journaler: Add init_headers function, call when reading head off disk. X-Git-Tag: v0.25~367^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf0675fa47df63345adc6ea8b9b26bb7e8b4af77;p=ceph.git 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 --- diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index ecdf91a32764..7e2d4f49304c 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 0f22c7b89754..c6148b775d46 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 2c709f695e89..a2b0fef40b7e 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),