]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: precondition rocksdb on mkfs 10814/head
authorSage Weil <sage@redhat.com>
Tue, 27 Sep 2016 15:38:42 +0000 (11:38 -0400)
committerSage Weil <sage@redhat.com>
Tue, 27 Sep 2016 15:38:42 +0000 (11:38 -0400)
Write N bytes of garbage to the kv store on startup.  With rocksdb,
this ensures that our log files are preallocated.

This option needs to match up with the rocksdb tunables so that it
is enough data to start recycling log files.  For now, start with
128MB.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/os/bluestore/BlueStore.cc

index 5f55e00602fd2ccab9f7e2c70ebb4022b947b9a8..5175334c5538f39fe8348eb76a072b4374d62646 100644 (file)
@@ -960,6 +960,8 @@ OPTION(bluestore_block_wal_path, OPT_STR, "")
 OPTION(bluestore_block_wal_size, OPT_U64, 96 * 1024*1024) // rocksdb wal
 OPTION(bluestore_block_wal_create, OPT_BOOL, false)
 OPTION(bluestore_block_preallocate_file, OPT_BOOL, false) //whether preallocate space if block/db_path/wal_path is file rather that block device.
+OPTION(bluestore_precondition_bluefs, OPT_U64, 128*1024*1024)  // write this much data at mkfs
+OPTION(bluestore_precondition_bluefs_block, OPT_U64, 1048576)
 OPTION(bluestore_csum_type, OPT_STR, "crc32c") // none|xxhash32|xxhash64|crc32c|crc32c_16|crc32c_8
 OPTION(bluestore_min_csum_block, OPT_U32, 4096)
 OPTION(bluestore_max_csum_block, OPT_U32, 64*1024)
index 2ede4e191aa374c2be12aa41116fef24ccf3f763..923bda285c26357c8c1d6bf5ca5b89ab50bf3658 100644 (file)
@@ -3588,6 +3588,36 @@ int BlueStore::mkfs()
     goto out_close_alloc;
   dout(10) << __func__ << " success" << dendl;
 
+  if (bluefs &&
+      g_conf->bluestore_precondition_bluefs > 0) {
+    dout(10) << __func__ << " preconditioning with "
+            << pretty_si_t(g_conf->bluestore_precondition_bluefs)
+            << " in blocks of "
+            << pretty_si_t(g_conf->bluestore_precondition_bluefs_block)
+            << dendl;
+    unsigned n = g_conf->bluestore_precondition_bluefs /
+      g_conf->bluestore_precondition_bluefs_block;
+    bufferlist bl;
+    bufferptr bp(g_conf->bluestore_precondition_bluefs_block);
+    for (unsigned i=0; i < g_conf->bluestore_precondition_bluefs_block; ++i) {
+      bp[i] = rand();
+    }
+    bl.append(bp);
+    string key1("a");
+    string key2("b");
+    for (unsigned i=0; i < n; ++i) {
+      KeyValueDB::Transaction t = db->get_transaction();
+      t->set(PREFIX_SUPER, (i & 1) ? key1 : key2, bl);
+      t->rmkey(PREFIX_SUPER, (i & 1) ? key2 : key1);
+      db->submit_transaction_sync(t);
+    }
+    KeyValueDB::Transaction t = db->get_transaction();
+    t->rmkey(PREFIX_SUPER, key1);
+    t->rmkey(PREFIX_SUPER, key2);
+    db->submit_transaction_sync(t);
+    dout(10) << __func__ << " done preconditioning" << dendl;
+  }
+
  out_close_alloc:
   _close_alloc();
  out_close_fm: