summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-09-05 18:20:21 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-09-05 18:20:21 -0800
commit837a476cc139167fc483016f0a2635a048f7709e (patch)
tree660c4b01cbc48665445a8a2e9e3bda8815bfc5eb
parent580ec0497a545bb52de204023928d4939dd14eb4 (diff)
bucket size must be a power of two
-rw-r--r--libbcache.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libbcache.c b/libbcache.c
index c278277..f17bd4a 100644
--- a/libbcache.c
+++ b/libbcache.c
@@ -90,6 +90,8 @@ void bcache_format(struct dev_opts *devs, size_t nr_devs,
unsigned scale = max(1U,
ilog2(i->size / min_size(i->bucket_size)) / 4);
+ scale = rounddown_pow_of_two(scale);
+
/* max bucket size 1 mb */
i->bucket_size = min(i->bucket_size * scale, 1U << 11);
} else {