From eb6a0bf22e5777b3977226d831380f5e68ae3739 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 28 Aug 2017 11:24:13 +0800 Subject: [PATCH] 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" (cherry picked from commit 88332c0f2f0a7a99639d1de237d5bb68edddbe70) --- src/mds/Server.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 952df343995e..0fdf18658fbe 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; -- 2.47.3