]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: explicitly disable block_cache when set to 0.
authorMark Nelson <mnelson@redhat.com>
Tue, 27 Jun 2017 13:15:03 +0000 (08:15 -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/kv/RocksDBStore.cc
src/kv/RocksDBStore.h

index aad274f5c71f5b674f217eb7c3f510bd35735847..01c2369ca6f0f4e08f962de8af1e204f207ea5ec 100644 (file)
@@ -298,23 +298,31 @@ int RocksDBStore::do_open(ostream &out, bool create_if_missing)
   }
 
   // caches
-  if (!cache_size) {
+  if (!set_cache_flag) {
     cache_size = g_conf->rocksdb_cache_size;
   }
   uint64_t row_cache_size = cache_size * g_conf->rocksdb_cache_row_ratio;
   uint64_t block_cache_size = cache_size - row_cache_size;
-  if (g_conf->rocksdb_cache_type == "lru") {
-    bbt_opts.block_cache = rocksdb::NewLRUCache(
-      block_cache_size,
-      g_conf->rocksdb_cache_shard_bits);
-  } else if (g_conf->rocksdb_cache_type == "clock") {
-    bbt_opts.block_cache = rocksdb::NewClockCache(
-      block_cache_size,
-      g_conf->rocksdb_cache_shard_bits);
+
+  if (block_cache_size == 0) {
+    // disable block cache
+    dout(10) << __func__ << " block_cache_size " << block_cache_size
+             << ", setting no_block_cache " << dendl;
+    bbt_opts.no_block_cache = true;
   } else {
-    derr << "unrecognized rocksdb_cache_type '" << g_conf->rocksdb_cache_type
-        << "'" << dendl;
-    return -EINVAL;
+    if (g_conf->rocksdb_cache_type == "lru") {
+      bbt_opts.block_cache = rocksdb::NewLRUCache(
+        block_cache_size,
+        g_conf->rocksdb_cache_shard_bits);
+    } else if (g_conf->rocksdb_cache_type == "clock") {
+      bbt_opts.block_cache = rocksdb::NewClockCache(
+        block_cache_size,
+        g_conf->rocksdb_cache_shard_bits);
+    } else {
+      derr << "unrecognized rocksdb_cache_type '" << g_conf->rocksdb_cache_type
+        << "'" << dendl;
+      return -EINVAL;
+    }
   }
   bbt_opts.block_size = g_conf->rocksdb_block_size;
 
index c437badebabbbf76887094ec2c53fe0aae00a3ef..321653448973f5327aa3459e8c55d9fa94e5e242 100644 (file)
@@ -76,6 +76,7 @@ class RocksDBStore : public KeyValueDB {
   string options_str;
 
   uint64_t cache_size = 0;
+  bool set_cache_flag = false;
 
   int do_open(ostream &out, bool create_if_missing);
 
@@ -439,6 +440,7 @@ err:
 
   int set_cache_size(uint64_t s) override {
     cache_size = s;
+    set_cache_flag = true;
     return 0;
   }