Merge pull request #12870 from xiaoxichen/mds_readdir

mds/server: skip unwanted dn in handle_client_readdir

Reviewed-by: Yan, Zheng <zyan@redhat.com>
Reviewed-by: John Spray <john.spray@redhat.com>
Reviewed-by: Greg Farnum <gfarnum@redhat.com>
This commit is contained in:
John Spray 2017-01-13 11:57:09 +00:00 committed by GitHub
commit b5262c2091
2 changed files with 4 additions and 1 deletions

View File

@ -428,6 +428,7 @@ protected:
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; }

View File

@ -3430,7 +3430,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;