Skip to content

Commit

Permalink
os/bluestore: bluestore_debug_prefill = <fill ratio>
Browse files Browse the repository at this point in the history
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 <sage@redhat.com>
  • Loading branch information
liewegas committed Jan 8, 2016
1 parent 8480ede commit ece7ef2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 23 additions & 1 deletion src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit ece7ef2

Please sign in to comment.