]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: add flags for crush nodes
authorSage Weil <sage@redhat.com>
Tue, 16 Apr 2019 22:22:38 +0000 (17:22 -0500)
committerSage Weil <sage@redhat.com>
Tue, 16 Apr 2019 22:22:38 +0000 (17:22 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 2be95af8211225c43d72e439b6000a25743bdab7)

# Conflicts:
# src/osd/OSDMap.h
 - due to std:: prefix on string cluster_snapshot

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

index 0c10811a88f58d2aaf58c16990a4988d872fce50..d73930b66ac7fe42e0a8fbf5af11a04321fee4cb 100644 (file)
@@ -581,7 +581,7 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const
   }
 
   {
-    uint8_t target_v = 7;
+    uint8_t target_v = 8;
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 2;
     } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
@@ -622,6 +622,9 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const
       encode(new_require_min_compat_client, bl);
       encode(new_require_osd_release, bl);
     }
+    if (target_v >= 8) {
+      encode(new_crush_node_flags, bl);
+    }
     ENCODE_FINISH(bl); // osd-only data
   }
 
@@ -831,7 +834,7 @@ void OSDMap::Incremental::decode(bufferlist::const_iterator& bl)
   }
 
   {
-    DECODE_START(7, bl); // extended, osd-only data
+    DECODE_START(8, bl); // extended, osd-only data
     decode(new_hb_back_up, bl);
     decode(new_up_thru, bl);
     decode(new_last_clean_interval, bl);
@@ -882,6 +885,9 @@ void OSDMap::Incremental::decode(bufferlist::const_iterator& bl)
        new_require_osd_release = -1;
       }
     }
+    if (struct_v >= 8) {
+      decode(new_crush_node_flags, bl);
+    }
     DECODE_FINISH(bl); // osd-only data
   }
 
@@ -1185,6 +1191,18 @@ void OSDMap::Incremental::dump(Formatter *f) const
     f->close_section();
     f->close_section();
   }
+  f->open_array_section("new_crush_node_flags");
+  for (auto& i : new_crush_node_flags) {
+    f->open_object_section("node");
+    f->dump_int("id", i.first);
+    set<string> st;
+    calc_state_set(i.second, st);
+    for (auto& j : st) {
+      f->dump_string("flag", j);
+    }
+    f->close_section();
+  }
+  f->close_section();
   f->close_section();
 }
 
@@ -2087,6 +2105,14 @@ int OSDMap::apply_incremental(const Incremental &inc)
   for (const auto &addr : inc.old_blacklist)
     blacklist.erase(addr);
 
+  for (auto& i : inc.new_crush_node_flags) {
+    if (i.second) {
+      crush_node_flags[i.first] = i.second;
+    } else {
+      crush_node_flags.erase(i.first);
+    }
+  }
+
   // cluster snapshot?
   if (inc.cluster_snapshot.length()) {
     cluster_snapshot = inc.cluster_snapshot;
@@ -2785,7 +2811,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
   {
     // NOTE: any new encoding dependencies must be reflected by
     // SIGNIFICANT_FEATURES
-    uint8_t target_v = 7;
+    uint8_t target_v = 8;
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 1;
     } else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
@@ -2835,6 +2861,9 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
     if (target_v >= 6) {
       encode(removed_snaps_queue, bl);
     }
+    if (target_v >= 8) {
+      encode(crush_node_flags, bl);
+    }
     ENCODE_FINISH(bl); // osd-only data
   }
 
@@ -3095,7 +3124,7 @@ void OSDMap::decode(bufferlist::const_iterator& bl)
   }
 
   {
-    DECODE_START(7, bl); // extended, osd-only data
+    DECODE_START(8, bl); // extended, osd-only data
     decode(osd_addrs->hb_back_addrs, bl);
     decode(osd_info, bl);
     decode(blacklist, bl);
@@ -3151,6 +3180,11 @@ void OSDMap::decode(bufferlist::const_iterator& bl)
     if (struct_v >= 6) {
       decode(removed_snaps_queue, bl);
     }
+    if (struct_v >= 8) {
+      decode(crush_node_flags, bl);
+    } else {
+      crush_node_flags.clear();
+    }
     DECODE_FINISH(bl); // osd-only data
   }
 
@@ -3395,6 +3429,19 @@ void OSDMap::dump(Formatter *f) const
     f->close_section();
   }
   f->close_section();
+  f->open_object_section("crush_node_flags");
+  for (auto& i : crush_node_flags) {
+    string s = crush->item_exists(i.first) ? crush->get_item_name(i.first)
+      : stringify(i.first);
+    f->open_array_section(s.c_str());
+    set<string> st;
+    calc_state_set(i.second, st);
+    for (auto& j : st) {
+      f->dump_string("flag", j);
+    }
+    f->close_section();
+  }
+  f->close_section();
 }
 
 void OSDMap::generate_test_instances(list<OSDMap*>& o)
index a477d5827e4e8538252a11b8c15f194b68772f36..3cfa2e65d809bc4791b32b987e5bf4cf1afc2e15 100644 (file)
@@ -399,6 +399,8 @@ public:
     mempool::osdmap::map<int64_t, snap_interval_set_t> new_removed_snaps;
     mempool::osdmap::map<int64_t, snap_interval_set_t> new_purged_snaps;
 
+    mempool::osdmap::map<int32_t,uint32_t> new_crush_node_flags;
+
     string cluster_snapshot;
 
     float new_nearfull_ratio = -1;
@@ -511,6 +513,8 @@ private:
   int32_t max_osd;
   vector<uint32_t> osd_state;
 
+  mempool::osdmap::map<int32_t,uint32_t> crush_node_flags; // crush node -> CEPH_OSD_* flags
+
   utime_t last_up_change, last_in_change;
 
   // These features affect OSDMap[::Incremental] encoding, or the