diff options
Diffstat (limited to 'src/os/bluestore/ZonedAllocator.cc')
-rw-r--r-- | src/os/bluestore/ZonedAllocator.cc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/os/bluestore/ZonedAllocator.cc b/src/os/bluestore/ZonedAllocator.cc index 3a80593f40c..bac6f016997 100644 --- a/src/os/bluestore/ZonedAllocator.cc +++ b/src/os/bluestore/ZonedAllocator.cc @@ -101,7 +101,6 @@ void ZonedAllocator::release(const interval_set<uint64_t>& release_set) { } uint64_t ZonedAllocator::get_free() { - std::lock_guard l(lock); return num_free; } @@ -117,8 +116,7 @@ void ZonedAllocator::dump(std::function<void(uint64_t offset, // This just increments |num_free|. The actual free space is added by // set_zone_states, as it updates the write pointer for each zone. void ZonedAllocator::init_add_free(uint64_t offset, uint64_t length) { - std::lock_guard l(lock); - ldout(cct, 10) << __func__ << " " << std::hex + ldout(cct, 40) << __func__ << " " << std::hex << offset << "~" << length << dendl; num_free += length; @@ -126,7 +124,7 @@ void ZonedAllocator::init_add_free(uint64_t offset, uint64_t length) { void ZonedAllocator::init_rm_free(uint64_t offset, uint64_t length) { std::lock_guard l(lock); - ldout(cct, 10) << __func__ << " 0x" << std::hex + ldout(cct, 40) << __func__ << " 0x" << std::hex << offset << "~" << length << dendl; num_free -= length; @@ -140,7 +138,7 @@ void ZonedAllocator::init_rm_free(uint64_t offset, uint64_t length) { ceph_assert(remaining_space <= length); advance_write_pointer(zone_num, remaining_space); - ldout(cct, 10) << __func__ << " set zone 0x" << std::hex + ldout(cct, 40) << __func__ << " set zone 0x" << std::hex << zone_num << " write pointer to 0x" << zone_size << dendl; length -= remaining_space; @@ -148,12 +146,25 @@ void ZonedAllocator::init_rm_free(uint64_t offset, uint64_t length) { for ( ; length; length -= zone_size) { advance_write_pointer(++zone_num, zone_size); - ldout(cct, 10) << __func__ << " set zone 0x" << std::hex + ldout(cct, 40) << __func__ << " set zone 0x" << std::hex << zone_num << " write pointer to 0x" << zone_size << dendl; } } -void ZonedAllocator::set_zone_states(std::vector<zone_state_t> &&_zone_states) { +bool ZonedAllocator::zoned_get_zones_to_clean(std::deque<uint64_t> *zones_to_clean) { + // TODO: make 0.25 tunable + if (static_cast<double>(num_free) / size > 0.25) { + return false; + } + { + std::lock_guard l(lock); + // TODO: populate |zones_to_clean| with the numbers of zones that should be + // cleaned. + } + return true; +} + +void ZonedAllocator::zoned_set_zone_states(std::vector<zone_state_t> &&_zone_states) { std::lock_guard l(lock); ldout(cct, 10) << __func__ << dendl; zone_states = std::move(_zone_states); |