From: Mark Nelson Date: Tue, 27 Jun 2017 13:13:13 +0000 (-0500) Subject: os/bluestore: limit kv cache size. X-Git-Tag: v12.1.1~154^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7435ddd69f3dc7d09903c2c81a17e9326432dbb9;p=ceph-ci.git os/bluestore: limit kv cache size. Signed-off-by: Mark Nelson --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index da0f6e80b1c..aa303ab810f 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 50fa241137e..263c89aaf60 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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) {