/*
* Zone related functions.
*/
-void BitMapZone::init(int64_t zone_num, int64_t total_blocks, bool def)
+void BitMapZone::init(CephContext* const cct,
+ const int64_t zone_num,
+ const int64_t total_blocks,
+ const bool def)
{
m_area_index = zone_num;
BitMapZone::total_blocks = total_blocks;
int64_t zone_num)
: BitMapArea(cct)
{
- init(zone_num, total_blocks, false);
+ init(cct, zone_num, total_blocks, false);
}
BitMapZone::BitMapZone(CephContext* cct, int64_t total_blocks,
int64_t zone_num, bool def)
: BitMapArea(cct)
{
- init(zone_num, total_blocks, def);
+ init(cct, zone_num, total_blocks, def);
}
void BitMapZone::shutdown()
-void BitMapZone::dump_state(int& count)
+void BitMapZone::dump_state(CephContext* const cct, int& count)
{
BmapEntry *bmap = NULL;
int bmap_idx = 0;
// nothing
}
-void BitMapAreaIN::init_common(int64_t total_blocks, int64_t area_idx, bool def)
+void BitMapAreaIN::init_common(CephContext* const cct,
+ const int64_t total_blocks,
+ const int64_t area_idx,
+ const bool def)
{
m_area_index = area_idx;
m_total_blocks = total_blocks;
m_used_blocks = def? total_blocks: 0;
}
-void BitMapAreaIN::init(int64_t total_blocks, int64_t area_idx, bool def)
+void BitMapAreaIN::init(CephContext* const cct,
+ int64_t total_blocks,
+ const int64_t area_idx,
+ const bool def)
{
int64_t num_child = 0;
alloc_assert(!(total_blocks % BmapEntry::size()));
- init_common(total_blocks, area_idx, def);
+ init_common(cct, total_blocks, area_idx, def);
int64_t level_factor = BitMapArea::get_level_factor(cct, m_level);
num_child = (total_blocks + level_factor - 1) / level_factor;
int64_t area_idx)
: BitMapArea(cct)
{
- init(total_blocks, area_idx, false);
+ init(cct, total_blocks, area_idx, false);
}
BitMapAreaIN::BitMapAreaIN(CephContext* cct, int64_t total_blocks,
int64_t area_idx, bool def)
: BitMapArea(cct)
{
- init(total_blocks, area_idx, def);
+ init(cct, total_blocks, area_idx, def);
}
BitMapAreaIN::~BitMapAreaIN()
unlock();
}
-void BitMapAreaIN::dump_state(int& count)
+void BitMapAreaIN::dump_state(CephContext* const cct, int& count)
{
BitMapArea *child = NULL;
m_child_list, 0, false);
while ((child = (BitMapArea *) iter.next())) {
- child->dump_state(count);
+ child->dump_state(cct, count);
}
}
int64_t area_idx)
: BitMapAreaIN(cct)
{
- init(total_blocks, area_idx, false);
+ init(cct, total_blocks, area_idx, false);
}
BitMapAreaLeaf::BitMapAreaLeaf(CephContext* cct, int64_t total_blocks,
int64_t area_idx, bool def)
: BitMapAreaIN(cct)
{
- init(total_blocks, area_idx, def);
+ init(cct, total_blocks, area_idx, def);
}
-void BitMapAreaLeaf::init(int64_t total_blocks, int64_t area_idx,
- bool def)
+void BitMapAreaLeaf::init(CephContext* const cct,
+ const int64_t total_blocks,
+ const int64_t area_idx,
+ const bool def)
{
int64_t num_child = 0;
alloc_assert(!(total_blocks % BmapEntry::size()));
- init_common(total_blocks, area_idx, def);
+ init_common(cct, total_blocks, area_idx, def);
alloc_assert(m_level == 1);
int zone_size_block = get_zone_size(cct);
alloc_assert(zone_size_block > 0);
*/
BitAllocator::BitAllocator(CephContext* cct, int64_t total_blocks,
int64_t zone_size_block, bmap_alloc_mode_t mode)
- : BitMapAreaIN(cct)
+ : BitMapAreaIN(cct),
+ cct(cct)
{
init_check(total_blocks, zone_size_block, mode, false, false);
}
BitAllocator::BitAllocator(CephContext* cct, int64_t total_blocks,
int64_t zone_size_block, bmap_alloc_mode_t mode,
bool def)
- : BitMapAreaIN(cct)
+ : BitMapAreaIN(cct),
+ cct(cct)
{
init_check(total_blocks, zone_size_block, mode, def, false);
}
BitAllocator::BitAllocator(CephContext* cct, int64_t total_blocks,
int64_t zone_size_block, bmap_alloc_mode_t mode,
bool def, bool stats_on)
- : BitMapAreaIN(cct)
+ : BitMapAreaIN(cct),
+ cct(cct)
{
init_check(total_blocks, zone_size_block, mode, def, stats_on);
}
}
pthread_rwlock_init(&m_rw_lock, NULL);
- init(total_blocks, 0, def);
+ init(cct, total_blocks, 0, def);
if (!def && unaligned_blocks) {
/*
* Mark extra padded blocks used from beginning.
{
int count = 0;
serial_lock();
- dump_state(count);
+ dump_state(cct, count);
serial_unlock();
}
} bmap_area_type_t;
class BitMapArea {
-public:
- CephContext* cct;
-
protected:
int16_t m_area_index;
bmap_area_type_t m_type;
int64_t get_index();
int64_t get_level();
bmap_area_type_t get_type();
- virtual void dump_state(int& count) = 0;
- BitMapArea(CephContext* cct) : cct(cct), m_type(UNDEFINED) {}
+ virtual void dump_state(CephContext* cct, int& count) = 0;
+ BitMapArea(CephContext*)
+ : m_type(UNDEFINED) {
+ }
virtual ~BitMapArea() { }
};
typedef mempool::bluestore_alloc::vector<BmapEntry> BmapEntryVector;
-class BitMapZone: public BitMapArea{
+class BitMapZone: public BitMapArea {
private:
std::atomic<int32_t> m_used_blocks;
bool check_locked();
void free_blocks_int(int64_t start_block, int64_t num_blocks);
- void init(int64_t zone_num, int64_t total_blocks, bool def);
+ void init(CephContext* cct, int64_t zone_num, int64_t total_blocks, bool def);
BitMapZone(CephContext* cct, int64_t total_blocks, int64_t zone_num);
BitMapZone(CephContext* cct, int64_t total_blocks, int64_t zone_num, bool def);
void set_blocks_used(int64_t start_block, int64_t num_blocks) override;
void free_blocks(int64_t start_block, int64_t num_blocks) override;
- void dump_state(int& count) override;
+ void dump_state(CephContext* cct, int& count) override;
};
class BitMapAreaIN: public BitMapArea{
return;
}
- void init(int64_t total_blocks, int64_t zone_size_block, bool def);
- void init_common(int64_t total_blocks, int64_t zone_size_block, bool def);
+ void init(CephContext* cct, int64_t total_blocks, int64_t zone_size_block, bool def);
+ void init_common(CephContext* cct,
+ int64_t total_blocks,
+ int64_t zone_size_block,
+ bool def);
int64_t alloc_blocks_dis_int_work(bool wrap, int64_t num_blocks, int64_t min_alloc, int64_t hint,
int64_t blk_off, ExtentList *block_list);
virtual void free_blocks_int(int64_t start_block, int64_t num_blocks);
void free_blocks(int64_t start_block, int64_t num_blocks) override;
- void dump_state(int& count) override;
+ void dump_state(CephContext* cct, int& count) override;
};
class BitMapAreaLeaf: public BitMapAreaIN{
private:
- void init(int64_t total_blocks, int64_t zone_size_block,
+ void init(CephContext* cct, int64_t total_blocks, int64_t zone_size_block,
bool def);
public:
class BitAllocator:public BitMapAreaIN{
private:
+ CephContext* const cct;
bmap_alloc_mode_t m_alloc_mode;
std::mutex m_serial_mutex;
pthread_rwlock_t m_rw_lock;