]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Add EMetaBlob::get_inodes
authorJohn Spray <john.spray@inktank.com>
Tue, 8 Apr 2014 10:17:54 +0000 (11:17 +0100)
committerJohn Spray <john.spray@inktank.com>
Sun, 18 May 2014 10:21:29 +0000 (11:21 +0100)
Used for filtering in journal tool

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

index 7384f47caaf875d00812cd24747b394b6e7e8797..9e001d9b0b7f44b6b99e43d86ec8a3e20b6a757d 100644 (file)
@@ -313,7 +313,8 @@ private:
  public:
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& bl);
-  int get_paths(std::vector<std::string> &paths);
+  void get_inodes(std::set<inodeno_t> &inodes);
+  void get_paths(std::vector<std::string> &paths);
   void dump(Formatter *f) const;
   static void generate_test_instances(list<EMetaBlob*>& ls);
   // soft stateadd
index 5a160d73d15b93ea9554a1a7cb79d851acf46289..b98676fd87a37d0f9c53ae92d5e74c918c729f05 100644 (file)
@@ -816,12 +816,47 @@ void EMetaBlob::decode(bufferlist::iterator &bl)
 }
 
 
+/**
+ * Get all inodes touched by this metablob.  Includes the 'bits' within
+ * dirlumps, and the inodes of the dirs themselves.
+ */
+void EMetaBlob::get_inodes(
+    std::set<inodeno_t> &inodes)
+{
+  // For all dirlumps in this metablob
+  for (std::map<dirfrag_t, dirlump>::iterator i = lump_map.begin(); i != lump_map.end(); ++i) {
+    // Record inode of dirlump
+    inodeno_t const dir_ino = i->first.ino;
+    inodes.insert(dir_ino);
+
+    // Decode dirlump bits
+    dirlump &dl = i->second;
+    dl._decode_bits();
+
+    // Record inodes of fullbits
+    list<ceph::shared_ptr<fullbit> > &fb_list = dl.get_dfull();
+    for (list<ceph::shared_ptr<fullbit> >::const_iterator
+        iter = fb_list.begin(); iter != fb_list.end(); ++iter) {
+      inodes.insert((*iter)->inode.ino);
+    }
+
+    // Record inodes of remotebits
+    list<remotebit> &rb_list = dl.get_dremote();
+    for (list<remotebit>::const_iterator
+       iter = rb_list.begin(); iter != rb_list.end(); ++iter) {
+      inodes.insert(iter->ino);
+    }
+  }
+}
+
+
+
 /**
  *
  * This is not const because the contained dirlump and 'bit' objects
  * are modified by being decoded.
  */
-int EMetaBlob::get_paths(
+void EMetaBlob::get_paths(
     std::vector<std::string> &paths)
 {
   // Each dentry has a 'location' which is a 2-tuple of parent inode and dentry name
@@ -838,7 +873,7 @@ int EMetaBlob::get_paths(
   // Special case: operations on root inode populate roots but not dirlumps
   if (lump_map.empty() && !roots.empty()) {
     paths.push_back("/");
-    return 0;
+    return;
   }
 
   // First pass
@@ -927,8 +962,6 @@ int EMetaBlob::get_paths(
 
     paths.push_back(path);
   }
-
-  return 0;
 }