From: Sage Weil Date: Fri, 17 Sep 2021 17:38:34 +0000 (-0500) Subject: os/bluestore: avoid writes to cleaning zone X-Git-Tag: v17.1.0~535^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cf2c533cd838ef78242eeacf051b5d5cd1e723ab;p=ceph.git os/bluestore: avoid writes to cleaning zone Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index a3859480fb42..c0dfcd36ea48 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -13080,10 +13080,9 @@ void BlueStore::_zoned_cleaner_thread() dout(20) << __func__ << " wake" << dendl; } else { l.unlock(); + a->set_cleaning_zone(zone_to_clean); _zoned_clean_zone(zone_to_clean); - bdev->reset_zone(zone_to_clean); - f->mark_zone_to_clean_free(zone_to_clean, db); - //a->mark_zone_to_clean_free(); + a->clear_cleaning_zone(zone_to_clean); l.lock(); } } diff --git a/src/os/bluestore/ZonedAllocator.cc b/src/os/bluestore/ZonedAllocator.cc index 6933dd972d89..8438c65c643c 100644 --- a/src/os/bluestore/ZonedAllocator.cc +++ b/src/os/bluestore/ZonedAllocator.cc @@ -66,17 +66,26 @@ int64_t ZonedAllocator::allocate( ldout(cct, 10) << " trying to allocate 0x" << std::hex << want_size << std::dec << dendl; + // FIXME: start search at last zone we successfully allocated from, so we + // avoid re-checking full zones so much + uint64_t zone_num = starting_zone_num; for ( ; zone_num < num_zones; ++zone_num) { - if (fits(want_size, zone_num)) { - break; + if (zone_num == cleaning_zone) { + ldout(cct, 10) << " skipping zone 0x" << std::hex << zone_num + << " because we are cleaning it" << std::dec << dendl; + continue; + } + if (!fits(want_size, zone_num)) { + ldout(cct, 10) << " skipping zone 0x" << std::hex << zone_num + << " because there is not enough space: " + << " want_size = 0x" << want_size + << " available = 0x" << get_remaining_space(zone_num) + << std::dec + << dendl; + continue; } - ldout(cct, 10) << " skipping zone 0x" << std::hex << zone_num - << " because there is not enough space: " - << " want_size = 0x" << want_size - << " available = 0x" << get_remaining_space(zone_num) - << std::dec - << dendl; + break; } if (zone_num == num_zones) { diff --git a/src/os/bluestore/ZonedAllocator.h b/src/os/bluestore/ZonedAllocator.h index 4dccb9f38062..ab4cc27707a5 100644 --- a/src/os/bluestore/ZonedAllocator.h +++ b/src/os/bluestore/ZonedAllocator.h @@ -38,6 +38,7 @@ class ZonedAllocator : public Allocator { uint64_t first_seq_zone_num; uint64_t starting_zone_num; uint64_t num_zones; + std::atomic cleaning_zone = -1; std::vector zone_states; inline uint64_t get_offset(uint64_t zone_num) const { @@ -92,6 +93,12 @@ public: uint64_t length)> notify) override; int64_t pick_zone_to_clean(void); + void set_cleaning_zone(uint32_t zone) { + cleaning_zone = zone; + } + void clear_cleaning_zone(uint32_t zone) { + cleaning_zone = -1; + } void init_from_zone_pointers( std::vector _zone_states);