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)
{
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) {