From 60a4189dd02e415712461ce8fa0fc6caee9d9745 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 20 Dec 2010 13:32:43 -0800 Subject: [PATCH] mdcache: change replay trimming a bit. Previously we were re-inserting dentrys on the open list. But if there weren't any other available dentrys to trim, this could have led to an infinite loop! Now, we save them in a list and pop them back in once the trim is done. Signed-off-by: Greg Farnum --- src/mds/MDCache.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 6ac26d51b26cb..a4661084d2657 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -4970,18 +4970,25 @@ bool MDCache::trim(int max) map expiremap; + bool is_standby_replay = mds->is_standby_replay(); + int unexpirable = 0; + list unexpirables; // trim dentries from the LRU - while (lru.lru_get_size() > (unsigned)max) { + while (lru.lru_get_size() + unexpirable > (unsigned)max) { CDentry *dn = (CDentry*)lru.lru_expire(); if (!dn) break; - if (dn->get_linkage() && + if (is_standby_replay && dn->get_linkage() && dn->get_linkage()->inode->item_open_file.is_on_list()) { - assert(mds->is_standby_replay()); - lru.lru_insert_mid(dn); + unexpirables.push_back(dn); + ++unexpirable; continue; } trim_dentry(dn, expiremap); } + for(list::iterator i = unexpirables.begin(); + i != unexpirables.end(); + ++i) + lru.lru_insert_mid(*i); // trim root? if (max == 0 && root) { -- 2.39.5