]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix journal replay
authorSage Weil <sage@newdream.net>
Sat, 4 Apr 2009 22:33:43 +0000 (15:33 -0700)
committerSage Weil <sage@newdream.net>
Sat, 4 Apr 2009 22:33:43 +0000 (15:33 -0700)
Load root inode before replaying journal.  Kill root special case in
journal replay.  Replay root inode if it is journaled.

src/mds/CInode.cc
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDS.cc
src/mds/journal.cc

index 142df442a56b7d377a9d08fff415139b885cad3f..242dd6992c3b7de9afbcb1c5de7e67407e8dffbb 100644 (file)
@@ -672,6 +672,7 @@ void CInode::_fetched(bufferlist& bl, Context *fin)
   dout(10) << "_fetched" << dendl;
   bufferlist::iterator p = bl.begin();
   decode_store(p);
+  dout(10) << "_fetched " << *this << dendl;
   fin->finish(0);
   delete fin;
 }
index 64d5ffd1aa3c64a8088e799116e84195912b3475..2fd02ea6f73b59ce2964a13ff116c41e41525d75 100644 (file)
@@ -405,16 +405,27 @@ struct C_MDS_RetryOpenRoot : public Context {
   }
 };
 
+void MDCache::open_root_inode(Context *c)
+{
+  assert(!root);
+  if (mds->whoami == mds->mdsmap->get_root()) {
+    create_root_inode();  // initially inaccurate!
+    root->fetch(c);
+  } else {
+    discover_base_ino(MDS_INO_ROOT, c, mds->mdsmap->get_root());
+  }
+}
+
 void MDCache::open_root()
 {
-  dout(10) << "open_root root=" << root << dendl;
+  dout(10) << "open_root" << dendl;
+
+  if (!root) {
+    open_root_inode(new C_MDS_RetryOpenRoot(this));
+    return;
+  }
 
   if (mds->whoami == mds->mdsmap->get_root()) {
-    if (!root) {
-      create_root_inode();  // initially inaccurate!
-      root->fetch(new C_MDS_RetryOpenRoot(this));
-      return;
-    }
     assert(root->is_auth());  
 
     CDir *rootdir = root->get_or_open_dirfrag(this, frag_t());
@@ -447,10 +458,6 @@ void MDCache::open_root()
     assert(mydir);
 
   } else {
-    if (!root) {
-      discover_base_ino(MDS_INO_ROOT, new C_MDS_RetryOpenRoot(this), mds->mdsmap->get_root());
-      return; 
-    }
     assert(!root->is_auth());
 
     CDir *rootdir = root->get_dirfrag(frag_t());
index 25a9fc3d59c792c1ef54634f1892a3e26b605a13..368303e7784f12f0a9bdee647c23df57cbe0dc9e 100644 (file)
@@ -870,6 +870,7 @@ public:
     waiting_for_open.push_back(c);
   }
 
+  void open_root_inode(Context *c);
   void open_root();
   void populate_mydir();
 
index b43dc40752d1b7bdf11541e1efe50f5a250e86f0..bf60968b7e091c332448d261f76853382eafc183 100644 (file)
@@ -843,9 +843,14 @@ void MDS::boot_start(int step, int r)
     break;
 
   case 2:
+    dout(2) << "boot_start " << step << ": loading root inode" << dendl;
+    mdcache->open_root_inode(new C_MDS_BootStart(this, 3));
+    break;
+
+  case 3:
     if (is_replay() || is_standby_replay()) {
       dout(2) << "boot_start " << step << ": replaying mds log" << dendl;
-      mdlog->replay(new C_MDS_BootStart(this, 3));
+      mdlog->replay(new C_MDS_BootStart(this, 4));
       break;
     } else {
       dout(2) << "boot_start " << step << ": positioning at end of old mds log" << dendl;
@@ -853,7 +858,7 @@ void MDS::boot_start(int step, int r)
       step++;
     }
 
-  case 3:
+  case 4:
     if (is_replay() || is_standby_replay()) {
       replay_done();
       break;
index 0f3b6ada1c0463a669e78c6058ce1dc39365b756..7dc981224d52c581798229bb422ba66db2c40f28 100644 (file)
@@ -325,9 +325,31 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
 {
   dout(10) << "EMetaBlob.replay " << lump_map.size() << " dirlumps" << dendl;
 
-  //if (!logseg) logseg = _segment;
   assert(logseg);
 
+  if (root) {
+    CInode *in = mds->mdcache->get_inode(root->inode.ino);
+    bool isnew = in ? false:true;
+    if (!in)
+      in = new CInode(mds->mdcache, true);
+    in->inode = root->inode;
+    in->xattrs = root->xattrs;
+    if (in->inode.is_dir()) {
+      in->dirfragtree = root->dirfragtree;
+      /*
+       * we can do this before linking hte inode bc the split_at would
+       * be a no-op.. we have no children (namely open snaprealms) to
+       * divy up 
+       */
+      in->decode_snap_blob(root->snapbl);  
+    }
+    if (in->inode.is_symlink()) in->symlink = root->symlink;
+    if (isnew)
+      mds->mdcache->add_inode(in);
+    if (root->dirty) in->_mark_dirty(logseg);
+    dout(10) << "EMetaBlob.replay " << (isnew ? " added root ":" updated root ") << *in << dendl;    
+  }
+
   // walk through my dirs (in order!)
   for (list<dirfrag_t>::iterator lp = lump_order.begin();
        lp != lump_order.end();
@@ -341,14 +363,15 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
       // hmm.  do i have the inode?
       CInode *diri = mds->mdcache->get_inode((*lp).ino);
       if (!diri) {
-       if ((*lp).ino == MDS_INO_ROOT) {
+       /*if ((*lp).ino == MDS_INO_ROOT) {
          diri = mds->mdcache->create_root_inode();
          dout(10) << "EMetaBlob.replay created root " << *diri << dendl;
-       }/* else if (MDS_INO_IS_STRAY((*lp).ino)) {
+       } else if (MDS_INO_IS_STRAY((*lp).ino)) {
          int whose = (*lp).ino - MDS_INO_STRAY_OFFSET;
          diri = mds->mdcache->create_stray_inode(whose);
          dout(10) << "EMetaBlob.replay created stray " << *diri << dendl;
-         } */ else {
+         } else */
+       {
          dout(0) << "EMetaBlob.replay missing dir ino  " << (*lp).ino << dendl;
          assert(0);
        }