]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: avoid writes to cleaning zone
authorSage Weil <sage@newdream.net>
Fri, 17 Sep 2021 17:38:34 +0000 (12:38 -0500)
committerSage Weil <sage@newdream.net>
Fri, 29 Oct 2021 13:56:42 +0000 (09:56 -0400)
Signed-off-by: Sage Weil <sage@newdream.net>
src/os/bluestore/BlueStore.cc
src/os/bluestore/ZonedAllocator.cc
src/os/bluestore/ZonedAllocator.h

index a3859480fb423f3a29b20cf7f2b924d62ba923f8..c0dfcd36ea4848f9095f7583e68ed9b69d6a01e9 100644 (file)
@@ -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();
     }
   }
index 6933dd972d89150150b3a7af9ed2ae081f36da3a..8438c65c643cd0e725da8b0ceeb4317aa243a9da 100644 (file)
@@ -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) {
index 4dccb9f38062ef9213ab627c6146333133c17915..ab4cc27707a5cf8ecb7847d026907960b178dd8d 100644 (file)
@@ -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<uint32_t> cleaning_zone = -1;
   std::vector<zone_state_t> 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_state_t> _zone_states);