]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/server: skip unwanted dn in handle_client_readdir 13028/head
authorXiaoxi Chen <xiaoxchen@ebay.com>
Wed, 11 Jan 2017 02:11:08 +0000 (19:11 -0700)
committerNathan Cutler <ncutler@suse.com>
Fri, 20 Jan 2017 17:03:15 +0000 (18:03 +0100)
We can skip unwanted dn which  < (offset_key, snap) via map.lower_bound, rather than
iterate across them.

Previously we iterate and skip dn which < (offset_key, dn->last), as dn->last >= snap
 means (offset_key, dn->last) >= (offset_key, snap), and such iterate_and_skip logic
still keep, so this commit doesnt change code logic but an optimization.

Signed-off-by: Xiaoxi Chen <xiaoxchen@ebay.com>
(cherry picked from commit 52fe52baf920c672ac7f63a3087dcd31137891b6)

src/mds/CDir.h
src/mds/Server.cc

index edd5434eba307157e1aade308541b252584e8c7d..8eb2cbc27e8c0d60b3f1e876e7117312ae644639 100644 (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; }
index f1a9eed01bee7f83db1ef76aa9f52456c4c8d01e..2f29757b46776471921a32773d33699553b1c7a4 100644 (file)
@@ -3402,7 +3402,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;