]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Add EMetaBlob::get_dentries
authorJohn Spray <john.spray@inktank.com>
Wed, 9 Apr 2014 10:17:30 +0000 (11:17 +0100)
committerJohn Spray <john.spray@inktank.com>
Sun, 18 May 2014 10:21:29 +0000 (11:21 +0100)
For tools that would like to know which dentries are
touched by a metablob, without understanding its
internal format.

Signed-off-by: John Spray <john.spray@inktank.com>
src/mds/events/EMetaBlob.h
src/mds/journal.cc

index 9e001d9b0b7f44b6b99e43d86ec8a3e20b6a757d..7fb7d67615b27f907dddbed69da57d8519f54a18 100644 (file)
@@ -315,6 +315,8 @@ private:
   void decode(bufferlist::iterator& bl);
   void get_inodes(std::set<inodeno_t> &inodes);
   void get_paths(std::vector<std::string> &paths);
+  void get_dentries(std::map<dirfrag_t, std::set<std::string> > &dentries);
+
   void dump(Formatter *f) const;
   static void generate_test_instances(list<EMetaBlob*>& ls);
   // soft stateadd
index b98676fd87a37d0f9c53ae92d5e74c918c729f05..83e2f665efb9af282b80fc07c3baaaeb3e46ee2c 100644 (file)
@@ -850,8 +850,46 @@ void EMetaBlob::get_inodes(
 }
 
 
+/**
+ * Get a map of dirfrag to set of dentries in that dirfrag which are
+ * touched in this operation.
+ */
+void EMetaBlob::get_dentries(std::map<dirfrag_t, std::set<std::string> > &dentries)
+{
+  for (std::map<dirfrag_t, dirlump>::iterator i = lump_map.begin(); i != lump_map.end(); ++i) {
+    inodeno_t const dir_ino = i->first.ino;
+    dirlump &dl = i->second;
+    dirfrag_t &df = i->first;
+
+    // Get all bits
+    dl._decode_bits();
+    list<ceph::shared_ptr<fullbit> > &fb_list = dl.get_dfull();
+    list<nullbit> &nb_list = dl.get_dnull();
+    list<remotebit> &rb_list = dl.get_dremote();
+
+    // For all bits, store dentry
+    for (list<ceph::shared_ptr<fullbit> >::const_iterator
+        iter = fb_list.begin(); iter != fb_list.end(); ++iter) {
+      dentries[df].insert((*iter)->dn);
+
+    }
+    for (list<nullbit>::const_iterator
+       iter = nb_list.begin(); iter != nb_list.end(); ++iter) {
+      dentries[df].insert(iter->dn);
+    }
+    for (list<remotebit>::const_iterator
+       iter = rb_list.begin(); iter != rb_list.end(); ++iter) {
+      dentries[df].insert(iter->dn);
+    }
+  }
+}
+
+
 
 /**
+ * Calculate all paths that we can infer are touched by this metablob.  Only uses
+ * information local to this metablob so it may only be the path within the
+ * subtree.
  *
  * This is not const because the contained dirlump and 'bit' objects
  * are modified by being decoded.