]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: trim empty non-auth dirfrags
authorYan, Zheng <zheng.z.yan@intel.com>
Sun, 23 Mar 2014 09:47:05 +0000 (17:47 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Fri, 28 Mar 2014 18:08:13 +0000 (02:08 +0800)
Fragmenting a non-auth dirfrag results several smaller dirfrags. Some
of the resulting dirfrags can be empty, which are not used to connected
to auth subtree.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/MDCache.cc
src/mds/journal.cc

index ba5bc8df731a4bbf29bd0dc396978aa5480f1081..7bee6eaab52b9367cad6320c1661ab9c8a8e3ac9 100644 (file)
@@ -3460,9 +3460,14 @@ void MDCache::recalc_auth_bits()
       dfq.pop_front();
 
       // dir
-      if (auth) 
+      if (auth) {
        dir->state_set(CDir::STATE_AUTH);
-      else {
+      } else {
+       // close empty non-auth dirfrag
+       if (!dir->is_subtree_root() && dir->get_num_any() == 0) {
+         dir->inode->close_dirfrag(dir->get_frag());
+         continue;
+       }
        dir->state_set(CDir::STATE_REJOINING);
        dir->state_clear(CDir::STATE_AUTH);
        dir->state_clear(CDir::STATE_COMPLETE);
@@ -6644,6 +6649,9 @@ void MDCache::trim_non_auth()
       dir->remove_dentry(dn);
       // adjust the dir state
       dir->state_clear(CDir::STATE_COMPLETE);  // dir incomplete!
+      // close empty non-auth dirfrag
+      if (!dir->is_subtree_root() && dir->get_num_any() == 0)
+       dir->inode->close_dirfrag(dir->get_frag());
     }
   }
 
index 45d62ea315de8d705636d92569d502a4a41db316..2bf24c3eb3deb311c9cd53155fcfe2d4240d05db 100644 (file)
@@ -533,6 +533,18 @@ void EMetaBlob::fullbit::update_inode(MDS *mds, CInode *in)
               << dirfragtree << " on " << *in << dendl;
       in->dirfragtree = dirfragtree;
       in->force_dirfrags();
+      if (in->has_dirfrags() && in->authority() == CDIR_AUTH_UNDEF) {
+       list<CDir*> ls;
+       in->get_nested_dirfrags(ls);
+       for (list<CDir*>::iterator p = ls.begin(); p != ls.end(); ++p) {
+         CDir *dir = *p;
+         if (dir->get_num_any() == 0 &&
+             mds->mdcache->can_trim_non_auth_dirfrag(dir)) {
+           dout(10) << " closing empty non-auth dirfrag " << *dir << dendl;
+           in->close_dirfrag(dir->get_frag());
+         }
+       }
+      }
     }
 
     /*