]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mdcache: change replay trimming a bit.
authorGreg Farnum <gregf@hq.newdream.net>
Mon, 20 Dec 2010 21:32:43 +0000 (13:32 -0800)
committerGreg Farnum <gregf@hq.newdream.net>
Thu, 6 Jan 2011 19:12:14 +0000 (11:12 -0800)
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 <gregf@hq.newdream.net>
src/mds/MDCache.cc

index 6ac26d51b26cb39e890ea94eaa401084e80b4579..a4661084d2657ef97ad12315ceb91da015b71c7f 100644 (file)
@@ -4970,18 +4970,25 @@ bool MDCache::trim(int max)
 
   map<int, MCacheExpire*> expiremap;
 
+  bool is_standby_replay = mds->is_standby_replay();
+  int unexpirable = 0;
+  list<CDentry*> 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<CDentry*>::iterator i = unexpirables.begin();
+      i != unexpirables.end();
+      ++i)
+    lru.lru_insert_mid(*i);
 
   // trim root?
   if (max == 0 && root) {