Skip to content

Commit

Permalink
mds: Add EMetaBlob::get_dentries
Browse files Browse the repository at this point in the history
For tools that would like to know which dentries are
touched by a metablob, without understanding its
internal format.

Signed-off-by: John Spray <[email protected]>
  • Loading branch information
John Spray committed May 18, 2014
1 parent f4927f0 commit 220f9c9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mds/events/EMetaBlob.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ class EMetaBlob {
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
Expand Down
38 changes: 38 additions & 0 deletions src/mds/journal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 220f9c9

Please sign in to comment.