BitmapAllocator::BitmapAllocator(CephContext* _cct,
int64_t capacity,
int64_t alloc_unit,
- const std::string& name) :
+ std::string_view name) :
Allocator(name, capacity, alloc_unit),
cct(_cct)
{
if (!allocated) {
return -ENOSPC;
}
- for (auto i = old_size; i < extents->size(); ++i) {
- auto& e = (*extents)[i];
- ldout(cct, 10) << __func__
- << " extent: 0x" << std::hex << e.offset << "~" << e.length
- << "/" << alloc_unit << "," << max_alloc_size << "," << hint
- << std::dec << dendl;
+ if (cct->_conf->subsys.should_gather<dout_subsys, 10>()) {
+ for (auto i = old_size; i < extents->size(); ++i) {
+ auto& e = (*extents)[i];
+ ldout(cct, 10) << __func__
+ << " extent: 0x" << std::hex << e.offset << "~" << e.length
+ << "/" << alloc_unit << "," << max_alloc_size << "," << hint
+ << std::dec << dendl;
+ }
}
return int64_t(allocated);
}
void BitmapAllocator::release(
const interval_set<uint64_t>& release_set)
{
- for (auto r : release_set) {
- ldout(cct, 10) << __func__ << " 0x" << std::hex << r.first << "~" << r.second
- << std::dec << dendl;
+ if (cct->_conf->subsys.should_gather<dout_subsys, 10>()) {
+ for (auto& [offset, len] : release_set) {
+ ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << len
+ << std::dec << dendl;
+ ceph_assert(offset + len <= (uint64_t)device_size);
+ }
}
_free_l2(release_set);
ldout(cct, 10) << __func__ << " done" << dendl;
auto mas = get_min_alloc_size();
uint64_t offs = round_up_to(offset, mas);
uint64_t l = p2align(offset + length - offs, mas);
+ ceph_assert(offs + l <= (uint64_t)device_size);
_mark_free(offs, l);
ldout(cct, 10) << __func__ << " done" << dendl;
auto mas = get_min_alloc_size();
uint64_t offs = round_up_to(offset, mas);
uint64_t l = p2align(offset + length - offs, mas);
+ ceph_assert(offs + l <= (uint64_t)device_size);
_mark_allocated(offs, l);
ldout(cct, 10) << __func__ << " done" << dendl;
}