From: Yan, Zheng Date: Mon, 28 Aug 2017 03:24:13 +0000 (+0800) Subject: mds: fix 'dirfrag end' check in Server::handle_client_readdir X-Git-Tag: v13.0.1~1022^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=88332c0f2f0a7a99639d1de237d5bb68edddbe70;p=ceph-ci.git mds: fix 'dirfrag end' check in Server::handle_client_readdir The 'dirfrag end' check can be wrong when not reading from beginning of dirfrag. Fixes: http://tracker.ceph.com/issues/21070 Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 19cc45ced7d..92a625ff3c7 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -3668,12 +3668,11 @@ void Server::handle_client_readdir(MDRequestRef& mdr) bufferlist dnbl; __u32 numfiles = 0; bool start = !offset_hash && offset_str.empty(); - bool end = (dir->begin() == dir->end()); // 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 = start ? dir->begin() : dir->lower_bound(skip_key); - !end && numfiles < max; - end = (it == dir->end())) { + auto it = start ? dir->begin() : dir->lower_bound(skip_key); + bool end = (it == dir->end()); + for (; !end && numfiles < max; end = (it == dir->end())) { CDentry *dn = it->second; ++it;