]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journaler: Add init_headers function, call when reading head off disk.
authorGreg Farnum <gregf@hq.newdream.net>
Fri, 17 Dec 2010 00:47:30 +0000 (16:47 -0800)
committerGreg Farnum <gregf@hq.newdream.net>
Thu, 6 Jan 2011 19:12:14 +0000 (11:12 -0800)
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 <gregf@hq.newdream.net>
src/mds/MDS.cc
src/osdc/Journaler.cc
src/osdc/Journaler.h

index ecdf91a32764c086d4670a74a5e3792c8b41b965..7e2d4f49304cb16f9edc63f8667ec9be1eebc30d 100644 (file)
@@ -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 */
index 0f22c7b89754599c1efffe3a6b90d00a7b709ccb..c6148b775d4685f97b654ed0a84ff94e6ca43ddb 100644 (file)
@@ -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;
index 2c709f695e8946d6d0065f25daf6d2f125333349..a2b0fef40b7e026a19ac1ee43058012f31a77227 100644 (file)
@@ -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),