]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: make osd_state 32 bits wide in luminous 15390/head
authorSage Weil <sage@redhat.com>
Wed, 31 May 2017 16:02:40 +0000 (12:02 -0400)
committerSage Weil <sage@redhat.com>
Wed, 31 May 2017 16:02:40 +0000 (12:02 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index c609e1035ba1fad2c66d8d04c77e4ccd2db1f174..e975855a13d7cb117c7323a0b6a720837a2f822e 100644 (file)
@@ -2182,7 +2182,13 @@ void OSDMap::encode_client_old(bufferlist& bl) const
   ::encode(flags, bl);
 
   ::encode(max_osd, bl);
-  ::encode(osd_state, bl);
+  {
+    uint32_t n = osd_state.size();
+    ::encode(n, bl);
+    for (auto s : osd_state) {
+      ::encode((uint8_t)s, bl);
+    }
+  }
   ::encode(osd_weight, bl);
   ::encode(osd_addrs->client_addr, bl, 0);
 
@@ -2224,7 +2230,13 @@ void OSDMap::encode_classic(bufferlist& bl, uint64_t features) const
   ::encode(flags, bl);
 
   ::encode(max_osd, bl);
-  ::encode(osd_state, bl);
+  {
+    uint32_t n = osd_state.size();
+    ::encode(n, bl);
+    for (auto s : osd_state) {
+      ::encode((uint8_t)s, bl);
+    }
+  }
   ::encode(osd_weight, bl);
   ::encode(osd_addrs->client_addr, bl, features);
 
@@ -2271,7 +2283,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
   ENCODE_START(8, 7, bl);
 
   {
-    uint8_t v = 4;
+    uint8_t v = 5;
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       v = 3;
     }
@@ -2300,7 +2312,15 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
     }
 
     ::encode(max_osd, bl);
-    ::encode(osd_state, bl);
+    if (v >= 5) {
+      ::encode(osd_state, bl);
+    } else {
+      uint32_t n = osd_state.size();
+      ::encode(n, bl);
+      for (auto s : osd_state) {
+       ::encode((uint8_t)s, bl);
+      }
+    }
     ::encode(osd_weight, bl);
     ::encode(osd_addrs->client_addr, bl, features);
 
@@ -2442,7 +2462,14 @@ void OSDMap::decode_classic(bufferlist::iterator& p)
   ::decode(flags, p);
 
   ::decode(max_osd, p);
-  ::decode(osd_state, p);
+  {
+    vector<uint8_t> os;
+    ::decode(os, p);
+    osd_state.resize(os.size());
+    for (unsigned i = 0; i < os.size(); ++i) {
+      osd_state[i] = os[i];
+    }
+  }
   ::decode(osd_weight, p);
   ::decode(osd_addrs->client_addr, p);
   if (v <= 5) {
@@ -2527,7 +2554,7 @@ void OSDMap::decode(bufferlist::iterator& bl)
    * Since we made it past that hurdle, we can use our normal paths.
    */
   {
-    DECODE_START(4, bl); // client-usable data
+    DECODE_START(5, bl); // client-usable data
     // base
     ::decode(fsid, bl);
     ::decode(epoch, bl);
@@ -2541,7 +2568,16 @@ void OSDMap::decode(bufferlist::iterator& bl)
     ::decode(flags, bl);
 
     ::decode(max_osd, bl);
-    ::decode(osd_state, bl);
+    if (struct_v >= 5) {
+      ::decode(osd_state, bl);
+    } else {
+      vector<uint8_t> os;
+      ::decode(os, bl);
+      osd_state.resize(os.size());
+      for (unsigned i = 0; i < os.size(); ++i) {
+       osd_state[i] = os[i];
+      }
+    }
     ::decode(osd_weight, bl);
     ::decode(osd_addrs->client_addr, bl);
 
index f2d51a23722096de5c435be59aafca399a451369..8b83f747c7bb2bb03e6b8698cfa60036580cee6d 100644 (file)
@@ -236,7 +236,7 @@ private:
   int num_in_osd;      // not saved; see calc_num_osds
 
   int32_t max_osd;
-  vector<uint8_t> osd_state;
+  vector<uint32_t> osd_state;
 
   struct addrs_s {
     mempool::osdmap::vector<ceph::shared_ptr<entity_addr_t> > client_addr;