]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: create auxiliary subtree inside auth subtree
authorYan, Zheng <zyan@redhat.com>
Thu, 27 Apr 2017 15:52:08 +0000 (23:52 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 28 Apr 2017 13:59:51 +0000 (09:59 -0400)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/CDir.cc
src/mds/CDir.h
src/mds/MDCache.cc
src/mds/Migrator.cc
src/mds/journal.cc

index bad5c7a7b43bf9868d704287d4130a326ad5e769..979b8caae5c1920e7d9c6f4ffa7767663ca225d9 100644 (file)
@@ -117,6 +117,7 @@ ostream& operator<<(ostream& out, const CDir& dir)
   if (dir.state_test(CDir::STATE_COMPLETE)) out << "|complete";
   if (dir.state_test(CDir::STATE_FREEZINGTREE)) out << "|freezingtree";
   if (dir.state_test(CDir::STATE_FROZENTREE)) out << "|frozentree";
+  if (dir.state_test(CDir::STATE_AUXSUBTREE)) out << "|auxsubtree";
   //if (dir.state_test(CDir::STATE_FROZENTREELEAF)) out << "|frozentreeleaf";
   if (dir.state_test(CDir::STATE_FROZENDIR)) out << "|frozendir";
   if (dir.state_test(CDir::STATE_FREEZINGDIR)) out << "|freezingdir";
index 03c53dee744a56c05ddaeb481996604e17491ffc..447ca3cb8a6e13e9638c272aef38cd1b0ca0edd2 100644 (file)
@@ -111,6 +111,7 @@ public:
   static const unsigned STATE_ASSIMRSTAT =    (1<<17);  // assimilating inode->frag rstats
   static const unsigned STATE_DIRTYDFT =      (1<<18);  // dirty dirfragtree
   static const unsigned STATE_BADFRAG =       (1<<19);  // bad dirfrag
+  static const unsigned STATE_AUXSUBTREE =    (1<<20);  // no subtree merge
 
   // common states
   static const unsigned STATE_CLEAN =  0;
index dfe914772e97fcc21a56ad764bd5e5861f464cbe..ba34e4bf28ce9047fc3518b79bf082509389889c 100644 (file)
@@ -931,7 +931,8 @@ void MDCache::try_subtree_merge_at(CDir *dir, bool do_eval)
   if (parent != dir &&                              // we have a parent,
       parent->dir_auth == dir->dir_auth &&          // auth matches,
       dir->dir_auth.second == CDIR_AUTH_UNKNOWN &&  // auth is unambiguous,
-      !dir->state_test(CDir::STATE_EXPORTBOUND)) {  // not an exportbound,
+      !dir->state_test(CDir::STATE_EXPORTBOUND) && // not an exportbound,
+      !dir->state_test(CDir::STATE_AUXSUBTREE)) {  // not aux subtree
     // merge with parent.
     dout(10) << "  subtree merge at " << *dir << dendl;
     dir->set_dir_auth(CDIR_AUTH_DEFAULT);
index 31aabc9c57541461f26987d31cb72d2b2e7e59c1..76d9545c7bd87133b7dc4b9ec9465e83723af9cf 100644 (file)
@@ -819,6 +819,32 @@ void Migrator::export_dir(CDir *dir, mds_rank_t dest)
     return;
   }
 
+  if (g_conf->mds_thrash_exports) {
+    // create random subtree bound (which will not be exported)
+    list<CDir*> ls;
+    for (auto p = dir->begin(); p != dir->end(); ++p) {
+      auto dn = p->second;
+      CDentry::linkage_t *dnl= dn->get_linkage();
+      if (dnl->is_primary()) {
+       CInode *in = dnl->get_inode();
+       if (in->is_dir())
+         in->get_nested_dirfrags(ls);
+      }
+    }
+    if (ls.size() > 0) {
+      int n = rand() % ls.size();
+      auto p = ls.begin();
+      while (n--) ++p;
+      CDir *bd = *p;
+      if (!(bd->is_frozen() || bd->is_freezing())) {
+       assert(bd->is_auth());
+       dir->state_set(CDir::STATE_AUXSUBTREE);
+       mds->mdcache->adjust_subtree_auth(dir, mds->get_nodeid());
+       dout(0) << "export_dir: create aux subtree " << *bd << " under " << *dir << dendl;
+      }
+    }
+  }
+
   mds->hit_export_target(ceph_clock_now(), dest, -1);
 
   dir->auth_pin(this);
@@ -1943,6 +1969,9 @@ void Migrator::export_finish(CDir *dir)
     bd->state_clear(CDir::STATE_EXPORTBOUND);
   }
 
+  if (dir->state_test(CDir::STATE_AUXSUBTREE))
+    dir->state_clear(CDir::STATE_AUXSUBTREE);
+
   // adjust auth, with possible subtree merge.
   //  (we do this _after_ removing EXPORTBOUND pins, to allow merges)
   cache->adjust_subtree_auth(dir, it->second.peer);
index db8efeba0c67e3896eed4a80175c0604f61d8d95..53dd3f466f131bfed54df59d8510eada640bd121 100644 (file)
@@ -335,13 +335,20 @@ void EMetaBlob::add_dir_context(CDir *dir, int mode)
 
     if (mode == TO_AUTH_SUBTREE_ROOT) {
       // subtree root?
-      if (dir->is_subtree_root() && !dir->state_test(CDir::STATE_EXPORTBOUND)) {
-       if (dir->is_auth() && !dir->is_ambiguous_auth()) {
-         // it's an auth subtree, we don't need maybe (if any), and we're done.
-         dout(20) << "EMetaBlob::add_dir_context(" << dir << ") reached unambig auth subtree, don't need " << maybe
-                  << " at " << *dir << dendl;
-         maybe.clear();
-         break;
+      if (dir->is_subtree_root() &&
+         !dir->state_test(CDir::STATE_EXPORTBOUND)) {
+       if (dir->is_auth() && !dir->is_ambiguous_auth() ) {
+         if (dir->state_test(CDir::STATE_AUXSUBTREE) &&
+             dir->get_dir_auth().first == diri->authority().first) {
+           // auxiliary subtree. treat it as normal dirfrag
+           dout(20) << "EMetaBlob::add_dir_context(" << dir << ") auxiliary subtree " << dendl;
+         } else {
+           // it's an auth subtree, we don't need maybe (if any), and we're done.
+           dout(20) << "EMetaBlob::add_dir_context(" << dir << ") reached unambig auth subtree, don't need " << maybe
+                    << " at " << *dir << dendl;
+           maybe.clear();
+           break;
+         }
        } else {
          dout(20) << "EMetaBlob::add_dir_context(" << dir << ") reached ambig or !auth subtree, need " << maybe
                   << " at " << *dir << dendl;