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 <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>
This commit is contained in:
xie xingguo 2016-07-12 10:33:57 +08:00 committed by Mark Nelson
parent 7f564d9e2c
commit e3bd10336b

View 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;