From ece7ef2a094bd8331452d2cc797a9952d458ea30 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 8 Jan 2016 15:22:25 -0500 Subject: [PATCH] os/bluestore: bluestore_debug_prefill = Prefill the objectstore by fragmenting the freespace. Max free allocations are bluestore_debug_prefragment_max bytes (default 1M). Prefill defaults to 0, of course. One would normally just set this to .8 to get something resembling an aged disk. Signed-off-by: Sage Weil --- src/common/config_opts.h | 2 ++ src/os/bluestore/BlueStore.cc | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 9587d5542c7be..f7ac5a60dc2c0 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -891,6 +891,8 @@ OPTION(bluestore_debug_misc, OPT_BOOL, false) OPTION(bluestore_debug_no_reuse_blocks, OPT_BOOL, false) OPTION(bluestore_debug_small_allocations, OPT_INT, 0) OPTION(bluestore_debug_freelist, OPT_BOOL, false) +OPTION(bluestore_debug_prefill, OPT_FLOAT, 0) +OPTION(bluestore_debug_prefragment_max, OPT_INT, 1048576) OPTION(kstore_max_ops, OPT_U64, 512) OPTION(kstore_max_bytes, OPT_U64, 64*1024*1024) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index a99fda36eeb77..38fb369e5ce3d 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1602,7 +1602,29 @@ int BlueStore::mkfs() } else { reserved = BLUEFS_START; } - fm->release(reserved, bdev->get_size() - reserved, t); + uint64_t end = bdev->get_size() - reserved; + if (g_conf->bluestore_debug_prefill > 0) { + dout(1) << __func__ << " pre-fragmenting freespace, using " + << g_conf->bluestore_debug_prefill << " with max free extent " + << g_conf->bluestore_debug_prefragment_max << dendl; + uint64_t min_alloc_size = g_conf->bluestore_min_alloc_size; + uint64_t start = ROUND_UP_TO(reserved, min_alloc_size); + uint64_t max_b = g_conf->bluestore_debug_prefragment_max / min_alloc_size; + float r = g_conf->bluestore_debug_prefill; + while (start < end) { + uint64_t l = (rand() % max_b + 1) * min_alloc_size; + if (start + l > end) + l = end - start; + l = ROUND_UP_TO(l, min_alloc_size); + fm->release(start, l, t); + uint64_t u = 1 + (uint64_t)(r * (double)l / (1.0 - r)); + u = ROUND_UP_TO(u, min_alloc_size); + dout(20) << " free " << start << "~" << l << " use " << u << dendl; + start += l + u; + } + } else { + fm->release(reserved, end, t); + } db->submit_transaction_sync(t); } -- 2.39.5