From: Sage Weil Date: Mon, 6 Jun 2016 17:33:44 +0000 (-0400) Subject: os/bluestore/StupidAllocator: use cbits instead of calculating shift manually X-Git-Tag: v11.0.0~162^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3e3f48b90816c5978540a8450914fd7a48d30602;p=ceph.git os/bluestore/StupidAllocator: use cbits instead of calculating shift manually Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/StupidAllocator.cc b/src/os/bluestore/StupidAllocator.cc index ae2cd0039da..6b54b4f547c 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; }