]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdmap: store new range_blocklist, updated as we do the existing blocklist
authorGreg Farnum <gfarnum@redhat.com>
Thu, 28 Oct 2021 22:00:27 +0000 (22:00 +0000)
committerGreg Farnum <gfarnum@redhat.com>
Tue, 31 May 2022 23:18:15 +0000 (23:18 +0000)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
(cherry picked from commit c0b87d9aca6f61ffe726ce3407059c527b319cbe)

src/osd/OSDMap.cc
src/osd/OSDMap.h

index 8ef6a1607ad6792e2761fe6b675356eb0796175d..13444abe584e1401b36eac85678b7bd7641d0d8f 100644 (file)
@@ -648,7 +648,7 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
   }
 
   {
-    uint8_t target_v = 9; // if bumping this, be aware of stretch_mode target_v 10!
+    uint8_t target_v = 9; // if bumping this, be aware of range_blocklist 11
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 2;
     } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
@@ -657,6 +657,10 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
     if (change_stretch_mode) {
       target_v = std::max((uint8_t)10, target_v);
     }
+    if (!new_range_blocklist.empty() ||
+       !old_range_blocklist.empty()) {
+      target_v = std::max((uint8_t)11, target_v);
+    }
     ENCODE_START(target_v, 1, bl); // extended, osd-only data
     if (target_v < 7) {
       encode_addrvec_map_as_addr(new_hb_back_up, bl, features);
@@ -706,6 +710,10 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
       encode(new_stretch_mode_bucket, bl);
       encode(stretch_mode_enabled, bl);
     }
+    if (target_v >= 11) {
+      encode(new_range_blocklist, bl, features);
+      encode(old_range_blocklist, bl, features);
+    }
     ENCODE_FINISH(bl); // osd-only data
   }
 
@@ -980,7 +988,10 @@ void OSDMap::Incremental::decode(ceph::buffer::list::const_iterator& bl)
       decode(new_stretch_mode_bucket, bl);
       decode(stretch_mode_enabled, bl);
     }
-
+    if (struct_v >= 11) {
+      decode(new_range_blocklist, bl);
+      decode(old_range_blocklist, bl);
+    }
     DECODE_FINISH(bl); // osd-only data
   }
 
@@ -1226,6 +1237,17 @@ void OSDMap::Incremental::dump(Formatter *f) const
   for (const auto &blist : old_blocklist)
     f->dump_stream("addr") << blist;
   f->close_section();
+  f->open_array_section("new_range_blocklist");
+  for (const auto &blist : new_range_blocklist) {
+    stringstream ss;
+    ss << blist.first;
+    f->dump_stream(ss.str().c_str()) << blist.second;
+  }
+  f->close_section();
+  f->open_array_section("old_range_blocklist");
+  for (const auto &blist : old_range_blocklist)
+    f->dump_stream("addr") << blist;
+  f->close_section();
 
   f->open_array_section("new_xinfo");
   for (const auto &xinfo : new_xinfo) {
@@ -2287,6 +2309,14 @@ int OSDMap::apply_incremental(const Incremental &inc)
   for (const auto &addr : inc.old_blocklist)
     blocklist.erase(addr);
 
+  if (!inc.new_range_blocklist.empty()) {
+    range_blocklist.insert(inc.new_range_blocklist.begin(),
+                          inc.new_range_blocklist.end());
+    new_blocklist_entries = true;
+  }
+  for (const auto &addr : inc.old_range_blocklist)
+    range_blocklist.erase(addr);
+
   for (auto& i : inc.new_crush_node_flags) {
     if (i.second) {
       crush_node_flags[i.first] = i.second;
@@ -3037,7 +3067,7 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
   {
     // NOTE: any new encoding dependencies must be reflected by
     // SIGNIFICANT_FEATURES
-    uint8_t target_v = 9; // when bumping this, be aware of stretch_mode target_v 10!
+    uint8_t target_v = 9; // when bumping this, be aware of range blocklist
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 1;
     } else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
@@ -3048,6 +3078,9 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
     if (stretch_mode_enabled) {
       target_v = std::max((uint8_t)10, target_v);
     }
+    if (!range_blocklist.empty()) {
+      target_v = std::max((uint8_t)11, target_v);
+    }
     ENCODE_START(target_v, 1, bl); // extended, osd-only data
     if (target_v < 7) {
       encode_addrvec_pvec_as_addr(osd_addrs->hb_back_addrs, bl, features);
@@ -3103,6 +3136,9 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
       encode(recovering_stretch_mode, bl);
       encode(stretch_mode_bucket, bl);
     }
+    if (target_v >= 11) {
+      ::encode(range_blocklist, bl, features);
+    }
     ENCODE_FINISH(bl); // osd-only data
   }
 
@@ -3442,6 +3478,9 @@ void OSDMap::decode(ceph::buffer::list::const_iterator& bl)
       recovering_stretch_mode = 0;
       stretch_mode_bucket = 0;
     }
+    if (struct_v >= 11) {
+      decode(range_blocklist, bl);
+    }
     DECODE_FINISH(bl); // osd-only data
   }
 
@@ -3654,6 +3693,13 @@ void OSDMap::dump(Formatter *f) const
     f->dump_stream(ss.str().c_str()) << addr.second;
   }
   f->close_section();
+  f->open_object_section("range_blocklist");
+  for (const auto &addr : range_blocklist) {
+    stringstream ss;
+    ss << addr.first;
+    f->dump_stream(ss.str().c_str()) << addr.second;
+  }
+  f->close_section();
 
   dump_erasure_code_profiles(erasure_code_profiles, f);
 
@@ -3918,6 +3964,8 @@ void OSDMap::print(ostream& out) const
 
   for (const auto &addr : blocklist)
     out << "blocklist " << addr.first << " expires " << addr.second << "\n";
+  for (const auto &addr : range_blocklist)
+    out << "range blocklist " << addr.first << " expires " << addr.second << "\n";
 }
 
 class OSDTreePlainDumper : public CrushTreeDumper::Dumper<TextTable> {
index 4cf02756c1d85bb49b01c236cbef6b5fa3a48996..3969a9ea90cdc2265c339531087b8b280971af9c 100644 (file)
@@ -397,6 +397,8 @@ public:
 
     mempool::osdmap::map<entity_addr_t,utime_t> new_blocklist;
     mempool::osdmap::vector<entity_addr_t> old_blocklist;
+    mempool::osdmap::map<entity_addr_t,utime_t> new_range_blocklist;
+    mempool::osdmap::vector<entity_addr_t> old_range_blocklist;
     mempool::osdmap::map<int32_t, entity_addrvec_t> new_hb_back_up;
     mempool::osdmap::map<int32_t, entity_addrvec_t> new_hb_front_up;
 
@@ -583,6 +585,7 @@ private:
   mempool::osdmap::vector<osd_xinfo_t> osd_xinfo;
 
   mempool::osdmap::unordered_map<entity_addr_t,utime_t> blocklist;
+  mempool::osdmap::map<entity_addr_t,utime_t> range_blocklist;
 
   /// queue of snaps to remove
   mempool::osdmap::map<int64_t, snap_interval_set_t> removed_snaps_queue;