From: Adam Kupczyk Date: Tue, 28 Feb 2017 14:30:45 +0000 (+0100) Subject: Bluestore : cleanup, got rid of table reference of 1< --- diff --git a/src/os/bluestore/BitAllocator.cc b/src/os/bluestore/BitAllocator.cc index 616853841204..3c44a640e097 100644 --- a/src/os/bluestore/BitAllocator.cc +++ b/src/os/bluestore/BitAllocator.cc @@ -41,8 +41,6 @@ int64_t BitMapAreaLeaf::count = 0; int64_t BitMapZone::count = 0; int64_t BitMapZone::total_blocks = 0; -bool BmapEntry::m_bit_mask_init = false; -bmap_mask_vec_t BmapEntry::m_bit_to_mask; int64_t BmapEntityListIter::index() @@ -50,30 +48,8 @@ int64_t BmapEntityListIter::index() return m_cur_idx; } -/* - * Bitmap Entry functions. - */ -void BmapEntry::_init_bit_mask() -{ - - if (m_bit_mask_init) { - return; - } - - m_bit_to_mask.reserve(BmapEntry::size()); - - uint64_t bmask = ((bmap_t) 0x1 << (BmapEntry::size() - 1)); - for (int i = 0; i < BmapEntry::size(); i++) { - m_bit_to_mask[i] = bmask >> i; - } - BmapEntry::m_bit_mask_init = true; -} - BmapEntry::BmapEntry(CephContext*, const bool full) { - - BmapEntry::_init_bit_mask(); - if (full) { m_bits = BmapEntry::full_bmask(); } else { @@ -86,37 +62,11 @@ BmapEntry::~BmapEntry() } -bmap_t BmapEntry::full_bmask() { - return (bmap_t) -1; -} - -int64_t BmapEntry::size() { - return (sizeof(bmap_t) * 8); -} - -bmap_t BmapEntry::empty_bmask() { - return (bmap_t) 0; -} - -bmap_t BmapEntry::align_mask(int x) -{ - return ((x) >= BmapEntry::size()? (bmap_t) -1 : (~(((bmap_t) -1) >> (x)))); -} - -bmap_t BmapEntry::bit_mask(int bit) -{ - return m_bit_to_mask[bit]; -} bool BmapEntry::check_bit(int bit) { return (atomic_fetch() & bit_mask(bit)); } -bmap_t BmapEntry::atomic_fetch() -{ - return m_bits; -} - bool BmapEntry::is_allocated(int64_t offset, int64_t num_bits) { bmap_t bmask = BmapEntry::align_mask(num_bits) >> offset; diff --git a/src/os/bluestore/BitAllocator.h b/src/os/bluestore/BitAllocator.h index a90d760dde13..338a9c716a52 100644 --- a/src/os/bluestore/BitAllocator.h +++ b/src/os/bluestore/BitAllocator.h @@ -141,20 +141,27 @@ typedef mempool::bluestore_alloc::vector bmap_mask_vec_t; class BmapEntry { private: bmap_t m_bits; - static bool m_bit_mask_init; - static bmap_mask_vec_t m_bit_to_mask; - - - static void _init_bit_mask(); public: MEMPOOL_CLASS_HELPERS(); - static bmap_t full_bmask(); - static int64_t size(); - static bmap_t empty_bmask(); - static bmap_t align_mask(int x); - static bmap_t bit_mask(int bit_num); - bmap_t atomic_fetch(); + static bmap_t full_bmask() { + return (bmap_t) -1; + } + static int64_t size() { + return (sizeof(bmap_t) * 8); + } + static bmap_t empty_bmask() { + return (bmap_t) 0; + } + static bmap_t align_mask(int x) { + return ((x) >= BmapEntry::size()? (bmap_t) -1 : (~(((bmap_t) -1) >> (x)))); + } + static bmap_t bit_mask(int bit_num) { + return (bmap_t) 0x1 << ((BmapEntry::size() - 1) - bit_num); + } + bmap_t atomic_fetch() { + return m_bits; + } BmapEntry(CephContext*, bool val); BmapEntry(CephContext*) { m_bits = 0;