]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: fix 'dirfrag end' check in Server::handle_client_readdir
authorYan, Zheng <zyan@redhat.com>
Mon, 28 Aug 2017 03:24:13 +0000 (11:24 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 28 Aug 2017 03:30:24 +0000 (11:30 +0800)
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" <zyan@redhat.com>
src/mds/Server.cc

index 19cc45ced7d5c2e1215ed5f507703a2f56e99ee6..92a625ff3c77eb635c132ff8bbe0f08e18ae48be 100644 (file)
@@ -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;