]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: make Incremental's new_state 32 bits wide (not 8)
authorSage Weil <sage@redhat.com>
Wed, 31 May 2017 15:59:41 +0000 (11:59 -0400)
committerSage Weil <sage@redhat.com>
Wed, 31 May 2017 15:59:41 +0000 (11:59 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 01a34a66d884db75c82f710ba95890ea5bfc25d6..3e1a707127d527677d5de4249158fbc9db7c8c14 100644 (file)
@@ -988,7 +988,7 @@ void OSDMonitor::maybe_prime_pg_temp()
 
   // check for interesting OSDs
   set<int> osds;
-  for (map<int32_t,uint8_t>::iterator p = pending_inc.new_state.begin();
+  for (auto p = pending_inc.new_state.begin();
        !all && p != pending_inc.new_state.end();
        ++p) {
     if ((p->second & CEPH_OSD_UP) &&
@@ -1206,7 +1206,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t)
   }
 
   // tell me about it
-  for (map<int32_t,uint8_t>::iterator i = pending_inc.new_state.begin();
+  for (auto i = pending_inc.new_state.begin();
        i != pending_inc.new_state.end();
        ++i) {
     int s = i->second ? i->second : CEPH_OSD_UP;
index fc5a426da144f3677e973d2756864ddce3332847..c609e1035ba1fad2c66d8d04c77e4ccd2db1f174 100644 (file)
@@ -366,7 +366,15 @@ void OSDMap::Incremental::encode_client_old(bufferlist& bl) const
     ::encode(n, bl);
   }
   ::encode(new_up_client, bl, 0);
-  ::encode(new_state, bl);
+  {
+    // legacy is map<int32_t,uint8_t>
+    uint32_t n = new_state.size();
+    ::encode(n, bl);
+    for (auto p : new_state) {
+      ::encode(p.first, bl);
+      ::encode((uint8_t)p.second, bl);
+    }
+  }
   ::encode(new_weight, bl);
   // for ::encode(new_pg_temp, bl);
   n = new_pg_temp.size();
@@ -402,7 +410,14 @@ void OSDMap::Incremental::encode_classic(bufferlist& bl, uint64_t features) cons
   ::encode(new_pool_names, bl);
   ::encode(old_pools, bl);
   ::encode(new_up_client, bl, features);
-  ::encode(new_state, bl);
+  {
+    uint32_t n = new_state.size();
+    ::encode(n, bl);
+    for (auto p : new_state) {
+      ::encode(p.first, bl);
+      ::encode((uint8_t)p.second, bl);
+    }
+  }
   ::encode(new_weight, bl);
   ::encode(new_pg_temp, bl);
 
@@ -444,7 +459,7 @@ void OSDMap::Incremental::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;
     }
@@ -462,7 +477,16 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const
     ::encode(new_pool_names, bl);
     ::encode(old_pools, bl);
     ::encode(new_up_client, bl, features);
-    ::encode(new_state, bl);
+    if (v >= 5) {
+      ::encode(new_state, bl);
+    } else {
+      uint32_t n = new_state.size();
+      ::encode(n, bl);
+      for (auto p : new_state) {
+       ::encode(p.first, bl);
+       ::encode((uint8_t)p.second, bl);
+      }
+    }
     ::encode(new_weight, bl);
     ::encode(new_pg_temp, bl);
     ::encode(new_primary_temp, bl);
@@ -581,7 +605,13 @@ void OSDMap::Incremental::decode_classic(bufferlist::iterator &p)
     ::decode(old_pools, p);
   }
   ::decode(new_up_client, p);
-  ::decode(new_state, p);
+  {
+    map<int32_t,uint8_t> ns;
+    ::decode(ns, p);
+    for (auto q : ns) {
+      new_state[q.first] = q.second;
+    }
+  }
   ::decode(new_weight, p);
 
   if (v < 6) {
@@ -650,7 +680,7 @@ void OSDMap::Incremental::decode(bufferlist::iterator& bl)
     return;
   }
   {
-    DECODE_START(4, bl); // client-usable data
+    DECODE_START(5, bl); // client-usable data
     ::decode(fsid, bl);
     ::decode(epoch, bl);
     ::decode(modified, bl);
@@ -664,7 +694,15 @@ void OSDMap::Incremental::decode(bufferlist::iterator& bl)
     ::decode(new_pool_names, bl);
     ::decode(old_pools, bl);
     ::decode(new_up_client, bl);
-    ::decode(new_state, bl);
+    if (struct_v >= 5) {
+      ::decode(new_state, bl);
+    } else {
+      map<int32_t,uint8_t> ns;
+      ::decode(ns, bl);
+      for (auto q : ns) {
+       new_state[q.first] = q.second;
+      }
+    }
     ::decode(new_weight, bl);
     ::decode(new_pg_temp, bl);
     ::decode(new_primary_temp, bl);
index 849569e8e7fcc8ee7fea458be992010920f57caf..f2d51a23722096de5c435be59aafca399a451369 100644 (file)
@@ -147,7 +147,7 @@ public:
     mempool::osdmap::vector<string> old_erasure_code_profiles;
     mempool::osdmap::map<int32_t,entity_addr_t> new_up_client;
     mempool::osdmap::map<int32_t,entity_addr_t> new_up_cluster;
-    mempool::osdmap::map<int32_t,uint8_t> new_state;             // XORed onto previous state.
+    mempool::osdmap::map<int32_t,uint32_t> new_state;             // XORed onto previous state.
     mempool::osdmap::map<int32_t,uint32_t> new_weight;
     mempool::osdmap::map<pg_t,mempool::osdmap::vector<int32_t> > new_pg_temp;     // [] to remove
     mempool::osdmap::map<pg_t, int32_t> new_primary_temp;            // [-1] to remove