]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: add allow_crimson flag
authorSamuel Just <sjust@redhat.com>
Sat, 8 Oct 2022 22:58:52 +0000 (22:58 +0000)
committerSamuel Just <sjust@redhat.com>
Tue, 14 Feb 2023 06:36:35 +0000 (22:36 -0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 699ccb21665575077c214059b066829184ed4c17..edd649085c1990305d5ce6984ba5951376c67cac 100644 (file)
@@ -655,7 +655,7 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
   }
 
   {
-    uint8_t target_v = 9; // if bumping this, be aware of range_blocklist 11
+    uint8_t target_v = 9; // if bumping this, be aware of allow_crimson 12
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 2;
     } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
@@ -668,6 +668,9 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
        !old_range_blocklist.empty()) {
       target_v = std::max((uint8_t)11, target_v);
     }
+    if (mutate_allow_crimson != mutate_allow_crimson_t::NONE) {
+      target_v = std::max((uint8_t)12, 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);
@@ -721,6 +724,9 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
       encode(new_range_blocklist, bl, features);
       encode(old_range_blocklist, bl, features);
     }
+    if (target_v >= 12) {
+      encode(mutate_allow_crimson, bl);
+    }
     ENCODE_FINISH(bl); // osd-only data
   }
 
@@ -999,6 +1005,9 @@ void OSDMap::Incremental::decode(ceph::buffer::list::const_iterator& bl)
       decode(new_range_blocklist, bl);
       decode(old_range_blocklist, bl);
     }
+    if (struct_v >= 12) {
+      decode(mutate_allow_crimson, bl);
+    }
     DECODE_FINISH(bl); // osd-only data
   }
 
@@ -1047,6 +1056,7 @@ void OSDMap::Incremental::dump(Formatter *f) const
   f->dump_float("new_backfillfull_ratio", new_backfillfull_ratio);
   f->dump_int("new_require_min_compat_client", to_integer<int>(new_require_min_compat_client));
   f->dump_int("new_require_osd_release", to_integer<int>(new_require_osd_release));
+  f->dump_unsigned("mutate_allow_crimson", static_cast<unsigned>(mutate_allow_crimson));
 
   if (fullmap.length()) {
     f->open_object_section("full_map");
@@ -2526,6 +2536,17 @@ int OSDMap::apply_incremental(const Incremental &inc)
     stretch_mode_bucket = inc.new_stretch_mode_bucket;
   }
 
+  switch (inc.mutate_allow_crimson) {
+  case Incremental::mutate_allow_crimson_t::NONE:
+    break;
+  case Incremental::mutate_allow_crimson_t::SET:
+    allow_crimson = true;
+    break;
+  case Incremental::mutate_allow_crimson_t::CLEAR:
+    allow_crimson = false;
+    break;
+  }
+
   calc_num_osds();
   _calc_up_osd_features();
   return 0;
@@ -3222,7 +3243,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 range blocklist
+    uint8_t target_v = 9; // when bumping this, be aware of allow_crimson
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 1;
     } else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
@@ -3236,6 +3257,9 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
     if (!range_blocklist.empty()) {
       target_v = std::max((uint8_t)11, target_v);
     }
+    if (allow_crimson) {
+      target_v = std::max((uint8_t)12, 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);
@@ -3294,6 +3318,9 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
     if (target_v >= 11) {
       ::encode(range_blocklist, bl, features);
     }
+    if (target_v >= 12) {
+      ::encode(allow_crimson, bl);
+    }
     ENCODE_FINISH(bl); // osd-only data
   }
 
@@ -3645,6 +3672,9 @@ void OSDMap::decode(ceph::buffer::list::const_iterator& bl)
        calculated_ranges.emplace(i.first, i.first);
       }
     }
+    if (struct_v >= 12) {
+      decode(allow_crimson, bl);
+    }
     DECODE_FINISH(bl); // osd-only data
   }
 
@@ -3785,6 +3815,7 @@ void OSDMap::dump(Formatter *f) const
   f->dump_string("require_osd_release",
                 to_string(require_osd_release));
 
+  f->dump_bool("allow_crimson", allow_crimson);
   f->open_array_section("pools");
   for (const auto &pool : pools) {
     std::string name("<unknown>");
@@ -4116,6 +4147,9 @@ void OSDMap::print(ostream& out) const
   }
   if (get_cluster_snapshot().length())
     out << "cluster_snapshot " << get_cluster_snapshot() << "\n";
+  if (allow_crimson) {
+    out << "allow_crimson=true\n";
+  }
   out << "\n";
 
   print_pools(out);
index 54474c2893e11b9eb47de441bd908de00201c378..98e30de2564af00d2aa7546a05eeb34514131cc8 100644 (file)
@@ -371,6 +371,13 @@ public:
     bool stretch_mode_enabled{false};
     bool change_stretch_mode{false};
 
+    enum class mutate_allow_crimson_t : uint8_t {
+      NONE = 0,
+      SET = 1,
+      // Monitor won't allow CLEAR to be set currently, but we may allow it later
+      CLEAR = 2
+    } mutate_allow_crimson = mutate_allow_crimson_t::NONE;
+
     // full (rare)
     ceph::buffer::list fullmap;  // in lieu of below.
     ceph::buffer::list crush;
@@ -517,6 +524,8 @@ public:
       }
       return p->second.contains(snap);
     }
+
+    void set_allow_crimson() { mutate_allow_crimson = mutate_allow_crimson_t::SET; }
   };
   
 private:
@@ -652,6 +661,7 @@ private:
   uint32_t degraded_stretch_mode; // 0 if not degraded; else count of up sites
   uint32_t recovering_stretch_mode; // 0 if not recovering; else 1
   int32_t stretch_mode_bucket; // the bucket type we're stretched across
+  bool allow_crimson{false};
 private:
   uint32_t crush_version = 1;
 
@@ -855,6 +865,10 @@ public:
     return erasure_code_profiles;
   }
 
+  bool get_allow_crimson() const {
+    return allow_crimson;
+  }
+
   bool exists(int osd) const {
     //assert(osd >= 0);
     return osd >= 0 && osd < max_osd && (osd_state[osd] & CEPH_OSD_EXISTS);