Skip to content

Commit

Permalink
Merge pull request #12921 from xiaoxichen/wip-18520-jewel
Browse files Browse the repository at this point in the history
Jewel: speed up readdir by skipping unwanted dn
  • Loading branch information
John Spray committed Jan 31, 2017
2 parents 384a425 + 8404426 commit 916e95d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mds/CDir.h
Expand Up @@ -428,6 +428,7 @@ class CDir : public MDSCacheObject {

map_t::iterator begin() { return items.begin(); }
map_t::iterator end() { return items.end(); }
map_t::iterator lower_bound(dentry_key_t key) { return items.lower_bound(key); }

unsigned get_num_head_items() const { return num_head_items; }
unsigned get_num_head_null() const { return num_head_null; }
Expand Down
4 changes: 3 additions & 1 deletion src/mds/Server.cc
Expand Up @@ -3394,7 +3394,9 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
bufferlist dnbl;
__u32 numfiles = 0;
bool end = (dir->begin() == dir->end());
for (CDir::map_t::iterator it = dir->begin();
// skip all dns < dentry_key_t(snapid, offset_str, offset_hash)
dentry_key_t skip_key(snapid, offset_str.c_str(), offset_hash);
for (CDir::map_t::iterator it = offset_str.empty() ? dir->begin() : dir->lower_bound(skip_key);
!end && numfiles < max;
end = (it == dir->end())) {
CDentry *dn = it->second;
Expand Down

0 comments on commit 916e95d

Please sign in to comment.