diff mbox

[10/12] mds: Trim non auth subtree directory

Message ID 1349168152-13281-10-git-send-email-zheng.z.yan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yan, Zheng Oct. 2, 2012, 8:55 a.m. UTC
From: "Yan, Zheng" <zheng.z.yan@intel.com>

Trim non auth subtree directory if all its dentries were trimmed
and it's not bound of auth subtree.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
---
 src/mds/MDCache.cc | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox

Patch

diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
index 1348b3e..397b991 100644
--- a/src/mds/MDCache.cc
+++ b/src/mds/MDCache.cc
@@ -5412,6 +5412,15 @@  bool MDCache::trim(int max)
       ++i)
     lru.lru_insert_mid(*i);
 
+  for (map<CDir*, set<CDir*> >::iterator p = subtrees.begin();
+       p != subtrees.end();) {
+    CDir *dir = p->first;
+    p++;
+    if (!dir->is_auth() && !dir->get_inode()->is_auth()) {
+      if (dir->get_num_ref() == 1)  // subtree pin
+	trim_dirfrag(dir, 0, expiremap);
+    }
+  }
   // trim root?
   if (max == 0 && root) {
     list<CDir*> ls;