From: John Spray Date: Tue, 8 Apr 2014 10:17:54 +0000 (+0100) Subject: mds: Add EMetaBlob::get_inodes X-Git-Tag: v0.82~48^2~39 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=96720b6dcb6c4a8e555df84489d32f4de42c5098;p=ceph.git mds: Add EMetaBlob::get_inodes Used for filtering in journal tool Signed-off-by: John Spray --- diff --git a/src/mds/events/EMetaBlob.h b/src/mds/events/EMetaBlob.h index 7384f47caaf8..9e001d9b0b7f 100644 --- a/src/mds/events/EMetaBlob.h +++ b/src/mds/events/EMetaBlob.h @@ -313,7 +313,8 @@ private: public: void encode(bufferlist& bl) const; void decode(bufferlist::iterator& bl); - int get_paths(std::vector &paths); + void get_inodes(std::set &inodes); + void get_paths(std::vector &paths); void dump(Formatter *f) const; static void generate_test_instances(list& ls); // soft stateadd diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 5a160d73d15b..b98676fd87a3 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -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 &inodes) +{ + // For all dirlumps in this metablob + for (std::map::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 > &fb_list = dl.get_dfull(); + for (list >::const_iterator + iter = fb_list.begin(); iter != fb_list.end(); ++iter) { + inodes.insert((*iter)->inode.ino); + } + + // Record inodes of remotebits + list &rb_list = dl.get_dremote(); + for (list::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 &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; }