From 16af25fba303a541bff83b18851f17dda9d51b99 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 1 Apr 2014 21:08:02 +0800 Subject: [PATCH] mds: add dentries in dirfrag to LRU in reverse order Files in a dirfrag are usually processed in the order of readdir results. Files at the beginning of are more likely to be used in the future than files at the last. Signed-off-by: Yan, Zheng --- src/mds/CDir.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index a3b4945e4d84f..6e93ec5ecea73 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1540,10 +1540,10 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, bool stray = inode->is_stray(); - unsigned pos = 0; - for (map::iterator p = omap.begin(); - p != omap.end(); - ++p, ++pos) { + unsigned pos = omap.size() - 1; + for (map::reverse_iterator p = omap.rbegin(); + p != omap.rend(); + ++p, --pos) { // dname string dname; snapid_t first, last; -- 2.39.5