]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/StupidAllocator: use cbits instead of calculating shift manually 9524/head
authorSage Weil <sage@redhat.com>
Mon, 6 Jun 2016 17:33:44 +0000 (13:33 -0400)
committerSage Weil <sage@redhat.com>
Wed, 15 Jun 2016 19:13:55 +0000 (15:13 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/StupidAllocator.cc

index ae2cd0039da8549471b8c29402d7d8f736ae91f1..6b54b4f547cca4db6a0fb63784ed76bb0b722c4f 100644 (file)
@@ -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;
 }