From: Sage Weil Date: Wed, 31 May 2017 15:59:41 +0000 (-0400) Subject: osd/OSDMap: make Incremental's new_state 32 bits wide (not 8) X-Git-Tag: v12.1.0~263^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a8fb39b57884d96201fa502b17bc9395ec38c1b3;p=ceph.git osd/OSDMap: make Incremental's new_state 32 bits wide (not 8) Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 01a34a66d884..3e1a707127d5 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -988,7 +988,7 @@ void OSDMonitor::maybe_prime_pg_temp() // check for interesting OSDs set osds; - for (map::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::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; diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index fc5a426da144..c609e1035ba1 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -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 + 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 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 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); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 849569e8e7fc..f2d51a237220 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -147,7 +147,7 @@ public: mempool::osdmap::vector old_erasure_code_profiles; mempool::osdmap::map new_up_client; mempool::osdmap::map new_up_cluster; - mempool::osdmap::map new_state; // XORed onto previous state. + mempool::osdmap::map new_state; // XORed onto previous state. mempool::osdmap::map new_weight; mempool::osdmap::map > new_pg_temp; // [] to remove mempool::osdmap::map new_primary_temp; // [-1] to remove