]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: open undef dirfrags during rejoin
authorSage Weil <sage@newdream.net>
Tue, 7 Dec 2010 19:15:56 +0000 (11:15 -0800)
committerSage Weil <sage@newdream.net>
Wed, 8 Dec 2010 00:44:18 +0000 (16:44 -0800)
Any invented dirfrags have a version of 0.  This will cause problems later
if we pre_dirty() anything in that dir because the dir version won't be
in sync (it'll be way too small).  Also, we can do that at any point,
e.g. when flushing dirty caps, and aren't allowed to delay, so we need to
load those dirfrags now.

In theory we could read only the fnode and not all the dentries, but we
may as well.  We should be more careful about memory that this patch is,
though.

Fixes #15.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mds/CDir.cc
src/mds/CInode.h
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/mdstypes.h

index 62ee0619fb3bf39cb24c7fb5fc2887a131a4c47f..661e6386988248e203fb0904c7538e139df7c2d5 100644 (file)
@@ -1258,6 +1258,12 @@ void CDir::_fetched(bufferlist &bl, const string& want_dn)
     assert(!state_test(STATE_COMMITTING));
     fnode = got_fnode;
     projected_version = committing_version = committed_version = got_fnode.version;
+
+    if (state_test(STATE_REJOINUNDEF)) {
+      assert(cache->mds->is_rejoin());
+      state_clear(STATE_REJOINUNDEF);
+      cache->opened_undef_dirfrag(this);
+    }
   }
 
   // purge stale snaps?
index ab3613c27adfc1d725de9b64a71ef327e97d97ab..5d9a7c7da1f1c0dac3a313e0072af8f568aa8a34 100644 (file)
@@ -162,7 +162,6 @@ public:
   static const int STATE_ANCHORING =   (1<<3);
   static const int STATE_UNANCHORING = (1<<4);
   static const int STATE_OPENINGDIR =  (1<<5);
-  static const int STATE_REJOINUNDEF = (1<<6);   // inode contents undefined.
   static const int STATE_FREEZING =    (1<<7);
   static const int STATE_FROZEN =      (1<<8);
   static const int STATE_AMBIGUOUSAUTH = (1<<9);
index 72bd7074991070737347ca1db40e2a3443c64453..52e48fd650fffa1b5a6a97948591797f665388f7 100644 (file)
@@ -3608,6 +3608,8 @@ CDir *MDCache::rejoin_invent_dirfrag(dirfrag_t df)
   }
   assert(in->is_dir());
   CDir *dir = in->get_or_open_dirfrag(this, df.frag);
+  dir->state_set(CDir::STATE_REJOINUNDEF);
+  rejoin_undef_dirfrags.insert(dir);
   dout(10) << " invented " << *dir << dendl;
   return dir;
 }
@@ -4406,8 +4408,38 @@ void MDCache::open_snap_parents()
     assert(reconnected_snaprealms.empty());
     dout(10) << "open_snap_parents - all open" << dendl;
     do_delayed_cap_imports();
-    start_files_to_recover(rejoin_recover_q, rejoin_check_q);
 
+    open_undef_dirfrags();
+  }
+}
+
+struct C_MDC_OpenUndefDirfragsFinish : public Context {
+  MDCache *cache;
+  C_MDC_OpenUndefDirfragsFinish(MDCache *c) : cache(c) {}
+  void finish(int r) {
+    cache->open_undef_dirfrags();
+  }
+};
+
+void MDCache::open_undef_dirfrags()
+{
+  dout(10) << "open_undef_dirfrags " << rejoin_undef_dirfrags.size() << " dirfrags" << dendl;
+  
+  C_Gather *gather = 0;
+  for (set<CDir*>::iterator p = rejoin_undef_dirfrags.begin();
+       p != rejoin_undef_dirfrags.end();
+       p++) {
+    CDir *dir = *p;
+    if (!gather)
+      gather = new C_Gather(new C_MDC_OpenUndefDirfragsFinish(this));
+    dir->fetch(gather->new_sub());
+  }
+
+  if (rejoin_undef_dirfrags.empty()) {
+    assert(!gather);
+
+    start_files_to_recover(rejoin_recover_q, rejoin_check_q);
+   
     mds->queue_waiters(rejoin_waiters);
 
     mds->rejoin_done();
index e411155d830e08b32a006182e284ef73ae4414fe..957dceb2273e9724dcb493adac108f66bfbc7866 100644 (file)
@@ -718,6 +718,7 @@ protected:
   
   set<CInode*> rejoin_undef_inodes;
   set<CInode*> rejoin_potential_updated_scatterlocks;
+  set<CDir*>   rejoin_undef_dirfrags;
 
   vector<CInode*> rejoin_recover_q, rejoin_check_q;
   list<Context*> rejoin_waiters;
@@ -791,6 +792,11 @@ public:
   void check_realm_past_parents(SnapRealm *realm);
   void open_snap_parents();
 
+  void open_undef_dirfrags();
+  void opened_undef_dirfrag(CDir *dir) {
+    rejoin_undef_dirfrags.erase(dir);
+  }
+
   void reissue_all_caps();
   
 
index 8b3cd53fd759aedab11b3a7d3852a8881556e597..1da6a3d2f981d3f3bc99c3232e6747724b9d4ed9 100644 (file)
@@ -1794,6 +1794,8 @@ class MDSCacheObject {
   const static int STATE_AUTH      = (1<<30);
   const static int STATE_DIRTY     = (1<<29);
   const static int STATE_REJOINING = (1<<28);  // replica has not joined w/ primary copy
+  const static int STATE_REJOINUNDEF = (1<<27);  // contents undefined.
+
 
   // -- wait --
   const static uint64_t WAIT_SINGLEAUTH  = (1ull<<60);