]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: use p2 macros to simplify bit-allocator block alignment
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 12 Jul 2016 02:33:57 +0000 (10:33 +0800)
committerMark Nelson <mnelson@redhat.com>
Mon, 18 Jul 2016 15:47:41 +0000 (10:47 -0500)
Mark's comments:

This passed "ceph_test_objectstore --gtest_filter=*/2".
This PR did not appear to have a significant impact on performance tests.

Closes #10253

os/bluestore: require block_size to be power of 2 aligned

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
os/bluestore: use ISP2 macro for zone/span size checking

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BitMapAllocator.cc

index ac3037e20143f9dd96c71b66be87b371960f6780..1695e21162964f0ca6b357090b725ca959e7663e 100644 (file)
@@ -23,9 +23,17 @@ BitMapAllocator::BitMapAllocator(int64_t device_size, int64_t block_size)
   : m_num_uncommitted(0),
     m_num_committing(0)
 {
+  assert(ISP2(block_size));
+  if (!ISP2(block_size)) {
+    derr << __func__ << " block_size " << block_size
+         << " not power of 2 aligned!"
+         << dendl;
+    return;
+  }
+
   int64_t zone_size_blks = g_conf->bluestore_bitmapallocator_blocks_per_zone;
-  assert((zone_size_blks & (zone_size_blks - 1)) == 0);
-  if (zone_size_blks & (zone_size_blks - 1)) {
+  assert(ISP2(zone_size_blks));
+  if (!ISP2(zone_size_blks)) {
     derr << __func__ << " zone_size " << zone_size_blks
          << " not power of 2 aligned!"
          << dendl;
@@ -33,8 +41,8 @@ BitMapAllocator::BitMapAllocator(int64_t device_size, int64_t block_size)
   }
 
   int64_t span_size = g_conf->bluestore_bitmapallocator_span_size;
-  assert((span_size & (span_size - 1)) == 0);
-  if (span_size & (span_size - 1)) {
+  assert(ISP2(span_size));
+  if (!ISP2(span_size)) {
     derr << __func__ << " span_size " << span_size
          << " not power of 2 aligned!"
          << dendl;