From: xie xingguo Date: Tue, 12 Jul 2016 02:33:57 +0000 (+0800) Subject: os/bluestore: use p2 macros to simplify bit-allocator block alignment X-Git-Tag: ses5-milestone5~377 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e3bd10336bd01def97731fc52b9ceb9e9ab15a73;p=ceph.git os/bluestore: use p2 macros to simplify bit-allocator block alignment 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 os/bluestore: use ISP2 macro for zone/span size checking Signed-off-by: xie xingguo --- diff --git a/src/os/bluestore/BitMapAllocator.cc b/src/os/bluestore/BitMapAllocator.cc index ac3037e2014..1695e211629 100644 --- a/src/os/bluestore/BitMapAllocator.cc +++ b/src/os/bluestore/BitMapAllocator.cc @@ -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;