]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: release pool allocator memory after exceeding size limit
authorJohn Spray <john.spray@redhat.com>
Mon, 12 Dec 2016 11:54:48 +0000 (11:54 +0000)
committerJohn Spray <john.spray@redhat.com>
Mon, 12 Dec 2016 12:02:40 +0000 (12:02 +0000)
Usually we like keeping the memory in our pools, but in circumstances
where we have violated our self-imposed inode count cap, we should
shrink our usage of system memory afterwards.

Fixes: http://tracker.ceph.com/issues/18225
Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h

index e30bd9af5c4147e2da9de9cd506a0db439aab5e1..89c8068bcfa657f8f830ac4babf3853214da222a 100644 (file)
@@ -179,6 +179,7 @@ public:
 MDCache::MDCache(MDSRank *m) :
   mds(m),
   filer(m->objecter, m->finisher),
+  exceeded_size_limit(false),
   recovery_queue(m),
   stray_manager(m)
 {
@@ -280,6 +281,10 @@ void MDCache::add_inode(CInode *in)
     if (in->is_base())
       base_inodes.insert(in);
   }
+
+  if (get_num_inodes() > g_conf->mds_cache_size * 1.5) {
+    exceeded_size_limit = true;
+  }
 }
 
 void MDCache::remove_inode(CInode *o) 
@@ -7378,6 +7383,21 @@ void MDCache::check_memory_usage()
       mds->server->recall_client_state(ratio);
     }
   }
+
+  // If the cache size had exceeded its limit, but we're back in bounds
+  // now, free any unused pool memory so that our memory usage isn't
+  // permanently bloated.
+  if (exceeded_size_limit
+      && get_num_inodes() <= g_conf->mds_cache_size * 1.5) {
+    // Only do this once we are back in bounds: otherwise the releases would
+    // slow down whatever process caused us to exceed bounds to begin with
+    dout(2) << "check_memory_usage: releasing unused space from pool allocators"
+            << dendl;
+    CInode::pool.release_memory();
+    CDir::pool.release_memory();
+    CDentry::pool.release_memory();
+    exceeded_size_limit = false;
+  }
 }
 
 
index a31964846227d8a5ef42f8d81c7114a5dc377b2d..9304f94df2a6dc7f96fdfeaef350f90061b01715 100644 (file)
@@ -139,6 +139,8 @@ class MDCache {
 
   Filer filer;
 
+  bool exceeded_size_limit;
+
 public:
   void advance_stray() {
     stray_index = (stray_index+1)%NUM_STRAY;