]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: limit kv cache size.
authorMark Nelson <mnelson@redhat.com>
Tue, 27 Jun 2017 13:13:13 +0000 (08:13 -0500)
committerMark Nelson <mnelson@redhat.com>
Thu, 6 Jul 2017 16:13:13 +0000 (11:13 -0500)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
src/common/config_opts.h
src/os/bluestore/BlueStore.cc

index da0f6e80b1cbaa205ecd8902fce249e47c494499..aa303ab810fb85c5cf6a9308081f6eca33c6979f 100644 (file)
@@ -1165,6 +1165,7 @@ OPTION(bluestore_2q_cache_kout_ratio, OPT_DOUBLE, .5)   // number of kout page s
 OPTION(bluestore_cache_size, OPT_U64, 3*1024*1024*1024)
 OPTION(bluestore_cache_meta_ratio, OPT_DOUBLE, .7)
 OPTION(bluestore_cache_kv_ratio, OPT_DOUBLE, .2)
+OPTION(bluestore_cache_kv_max, OPT_U64, 512*1024*1024) // limit the maximum amont of cache for the kv store
 OPTION(bluestore_kvbackend, OPT_STR, "rocksdb")
 OPTION(bluestore_allocator, OPT_STR, "bitmap")     // stupid | bitmap
 OPTION(bluestore_freelist_blocks_per_key, OPT_INT, 128)
index 50fa241137e417e4b25e058f059ee265e3878a43..263c89aaf600916732642ad6ce0d64bafc4b8db4 100644 (file)
@@ -3691,17 +3691,34 @@ int BlueStore::_set_cache_sizes()
 {
   cache_meta_ratio = cct->_conf->bluestore_cache_meta_ratio;
   cache_kv_ratio = cct->_conf->bluestore_cache_kv_ratio;
+
+  double cache_size = cct->_conf->bluestore_cache_size;
+  double cache_kv_max = cct->_conf->bluestore_cache_kv_max;
+  double cache_kv_max_ratio = 0;
+
+  // if cache_kv_max is negative, disable it
+  if (cache_size > 0 && cache_kv_max >= 0) {
+    cache_kv_max_ratio = (double) cache_kv_max / (double) cache_size;
+    if (cache_kv_max_ratio < 1.0 && cache_kv_max_ratio < cache_kv_ratio) {
+      dout(1) << __func__ << " max " << cache_kv_max_ratio
+            << " < ratio " << cache_kv_ratio
+            << dendl;
+      cache_meta_ratio = cache_meta_ratio + cache_kv_ratio - cache_kv_max_ratio;
+      cache_kv_ratio = cache_kv_max_ratio;
+    }
+  }  
+
   cache_data_ratio =
     (double)1.0 - (double)cache_meta_ratio - (double)cache_kv_ratio;
 
-  if (cache_meta_ratio <= 0 || cache_meta_ratio > 1.0) {
+  if (cache_meta_ratio < 0 || cache_meta_ratio > 1.0) {
     derr << __func__ << "bluestore_cache_meta_ratio (" << cache_meta_ratio
-        << ") must be in range (0,1.0]" << dendl;
+        << ") must be in range [0,1.0]" << dendl;
     return -EINVAL;
   }
-  if (cache_kv_ratio <= 0 || cache_kv_ratio > 1.0) {
+  if (cache_kv_ratio < 0 || cache_kv_ratio > 1.0) {
     derr << __func__ << "bluestore_cache_kv_ratio (" << cache_kv_ratio
-        << ") must be in range (0,1.0]" << dendl;
+        << ") must be in range [0,1.0]" << dendl;
     return -EINVAL;
   }
   if (cache_meta_ratio + cache_kv_ratio > 1.0) {