From 2fa16d018d2ee86363796ea52df5aed81bfa30a2 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 15 May 2017 10:28:06 +0800 Subject: [PATCH] mds: fix MDCache::trim_non_auth() After introducing the bottom_lru, "stop when we see a dentry the second time" no longer works. Signed-off-by: "Yan, Zheng" --- src/mds/MDCache.cc | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 4136e8f68b6ad..9eeca5c7c452d 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -6806,9 +6806,7 @@ void MDCache::trim_non_auth() ++p) p->first->get(CDir::PIN_SUBTREETEMP); - // note first auth item we see. - // when we see it the second time, stop. - CDentry *first_auth = 0; + list auth_list; // trim non-auth items from the lru for (;;) { @@ -6824,20 +6822,10 @@ void MDCache::trim_non_auth() if (dn->is_auth()) { // add back into lru (at the top) - if (dn->state_test(CDentry::STATE_BOTTOMLRU)) - bottom_lru.lru_insert_mid(dn); - else - lru.lru_insert_top(dn); + auth_list.push_back(dn); if (dnl->is_remote() && dnl->get_inode() && !dnl->get_inode()->is_auth()) dn->unlink_remote(dnl); - - if (!first_auth) { - first_auth = dn; - } else { - if (first_auth == dn) - break; - } } else { // non-auth. expire. CDir *dir = dn->get_dir(); @@ -6875,6 +6863,13 @@ void MDCache::trim_non_auth() } } + for (auto dn : auth_list) { + if (dn->state_test(CDentry::STATE_BOTTOMLRU)) + bottom_lru.lru_insert_mid(dn); + else + lru.lru_insert_top(dn); + } + // move everything in the pintail to the top bit of the lru. lru.lru_touch_entire_pintail(); -- 2.47.3