]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix 'dirfrag end' check in Server::handle_client_readdir 17686/head
authorYan, Zheng <zyan@redhat.com>
Mon, 28 Aug 2017 03:24:13 +0000 (11:24 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 13 Sep 2017 02:11:00 +0000 (10:11 +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>
(cherry picked from commit 88332c0f2f0a7a99639d1de237d5bb68edddbe70)

src/mds/Server.cc

index 952df343995eac50b17a691e53da796abedf97e2..0fdf18658fbe07a41523b165add669f28dea9d4e 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;