]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: introduce rejoin_invent_dirfrag() helper
authorSage Weil <sage@newdream.net>
Mon, 6 Dec 2010 22:34:36 +0000 (14:34 -0800)
committerSage Weil <sage@newdream.net>
Wed, 8 Dec 2010 00:44:18 +0000 (16:44 -0800)
Signed-off-by: Sage Weil <sage@newdream.net>
src/mds/MDCache.cc
src/mds/MDCache.h

index 2519953b476f4ac0f31639e3dc36119c90568eeb..72bd7074991070737347ca1db40e2a3443c64453 100644 (file)
@@ -3596,6 +3596,22 @@ CInode *MDCache::rejoin_invent_inode(inodeno_t ino, snapid_t last)
   return in;
 }
 
+CDir *MDCache::rejoin_invent_dirfrag(dirfrag_t df)
+{
+  CInode *in = get_inode(df.ino);
+  if (!in) {
+    in = rejoin_invent_inode(df.ino, CEPH_NOSNAP);
+    if (!in->is_dir()) {
+      assert(in->state_test(CInode::STATE_REJOINUNDEF));
+      in->inode.mode = S_IFDIR;
+    }
+  }
+  assert(in->is_dir());
+  CDir *dir = in->get_or_open_dirfrag(this, df.frag);
+  dout(10) << " invented " << *dir << dendl;
+  return dir;
+}
+
 /* This functions DOES NOT put the passed message before returning */
 void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
 {
@@ -3624,19 +3640,10 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
        p != strong->strong_dirfrags.end();
        ++p) {
     CDir *dir = get_dirfrag(p->first);
-    if (!dir) {
-      CInode *in = get_inode(p->first.ino);
-      if (!in)
-       in = rejoin_invent_inode(p->first.ino, CEPH_NOSNAP);
-      if (!in->is_dir()) {
-       assert(in->state_test(CInode::STATE_REJOINUNDEF));
-       in->inode.mode = S_IFDIR;
-      }
-      dir = in->get_or_open_dirfrag(this, p->first.frag);
-      dout(10) << " invented " << *dir << dendl;
-    } else {
+    if (!dir)
+      dir = rejoin_invent_dirfrag(p->first);
+    else
       dout(10) << " have " << *dir << dendl;
-    }
     dir->add_replica(from);
     dir->dir_rep = p->second.dir_rep;
 
index e4931a7fae945d29c74af7f1cda763af9803e4c1..e411155d830e08b32a006182e284ef73ae4414fe 100644 (file)
@@ -726,6 +726,7 @@ protected:
   void handle_cache_rejoin(MMDSCacheRejoin *m);
   void handle_cache_rejoin_weak(MMDSCacheRejoin *m);
   CInode* rejoin_invent_inode(inodeno_t ino, snapid_t last);
+  CDir* rejoin_invent_dirfrag(dirfrag_t df);
   void handle_cache_rejoin_strong(MMDSCacheRejoin *m);
   void rejoin_scour_survivor_replicas(int from, MMDSCacheRejoin *ack, set<vinodeno_t>& acked_inodes);
   void handle_cache_rejoin_ack(MMDSCacheRejoin *m);