]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: make CInode::get_dirfrags container agnostic
authorYan, Zheng <zyan@redhat.com>
Fri, 27 Jul 2018 01:17:04 +0000 (09:17 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 28 Aug 2018 23:12:42 +0000 (07:12 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit c2807b8ffea7d6b0075ac0f08641235b9b352ad2)

 Conflicts:
src/mds/CInode.cc
src/mds/CInode.h

src/mds/CInode.cc
src/mds/CInode.h

index af4b5c2a9a6109475bb768a0bdf7dcf1f14e7fef..11d3344d0f30fc1bdaf6f874196b4265538131b8 100644 (file)
@@ -604,31 +604,6 @@ CDir *CInode::get_approx_dirfrag(frag_t fg)
   return NULL;
 }      
 
-void CInode::get_dirfrags(std::list<CDir*>& ls) 
-{
-  // all dirfrags
-  for (const auto &p : dirfrags) {
-    ls.push_back(p.second);
-  }
-}
-void CInode::get_nested_dirfrags(list<CDir*>& ls) 
-{  
-  // dirfrags in same subtree
-  for (const auto &p : dirfrags) {
-    if (!p.second->is_subtree_root())
-      ls.push_back(p.second);
-  }
-}
-void CInode::get_subtree_dirfrags(list<CDir*>& ls) 
-{ 
-  // dirfrags that are roots of new subtrees
-  for (const auto &p : dirfrags) {
-    if (p.second->is_subtree_root())
-      ls.push_back(p.second);
-  }
-}
-
-
 CDir *CInode::get_or_open_dirfrag(MDCache *mdcache, frag_t fg)
 {
   assert(is_dir());
index b27e29f797b3f3ce29b35b71f5cefad5e6921465..fa03a0a12ebb24074e9ac7e6f9fff27b8ff4bebf 100644 (file)
@@ -524,9 +524,32 @@ public:
   }
   bool get_dirfrags_under(frag_t fg, std::list<CDir*>& ls);
   CDir* get_approx_dirfrag(frag_t fg);
-  void get_dirfrags(std::list<CDir*>& ls);
-  void get_nested_dirfrags(std::list<CDir*>& ls);
-  void get_subtree_dirfrags(std::list<CDir*>& ls);
+
+  template<typename Container>
+  void get_dirfrags(Container& ls) const {
+    // all dirfrags
+    for (const auto &p : dirfrags)
+      ls.push_back(p.second);
+  }
+  template<typename Container>
+  void get_nested_dirfrags(Container& ls) const {
+    // dirfrags in same subtree
+    for (const auto &p : dirfrags) {
+      typename Container::value_type dir = p.second;
+      if (!dir->is_subtree_root())
+        ls.push_back(dir);
+    }
+  }
+  template<typename Container>
+  void get_subtree_dirfrags(Container& ls) {
+    // dirfrags that are roots of new subtrees
+    for (const auto &p : dirfrags) {
+      typename Container::value_type dir = p.second;
+      if (dir->is_subtree_root())
+        ls.push_back(dir);
+    }
+  }
+
   CDir *get_or_open_dirfrag(MDCache *mdcache, frag_t fg);
   CDir *add_dirfrag(CDir *dir);
   void close_dirfrag(frag_t fg);