From 3e3f48b90816c5978540a8450914fd7a48d30602 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 6 Jun 2016 13:33:44 -0400 Subject: [PATCH] os/bluestore/StupidAllocator: use cbits instead of calculating shift manually Signed-off-by: Sage Weil --- src/os/bluestore/StupidAllocator.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/os/bluestore/StupidAllocator.cc b/src/os/bluestore/StupidAllocator.cc index ae2cd0039da8..6b54b4f547cc 100644 --- a/src/os/bluestore/StupidAllocator.cc +++ b/src/os/bluestore/StupidAllocator.cc @@ -26,11 +26,7 @@ StupidAllocator::~StupidAllocator() unsigned StupidAllocator::_choose_bin(uint64_t orig_len) { uint64_t len = orig_len / g_conf->bdev_block_size; - int bin = 0; - while (len && bin + 1 < (int)free.size()) { - len >>= 1; - bin++; - } + int bin = std::min((int)cbits(len), (int)free.size() - 1); dout(30) << __func__ << " len " << orig_len << " -> " << bin << dendl; return bin; } -- 2.47.3