}
// up/down
- for (map<int32_t,uint8_t>::const_iterator i = inc.new_state.begin();
- i != inc.new_state.end();
- ++i) {
- int s = i->second ? i->second : CEPH_OSD_UP;
- if ((osd_state[i->first] & CEPH_OSD_UP) &&
+ for (const auto &state : inc.new_state) {
+ const auto osd = state.first;
+ int s = state.second ? state.second : CEPH_OSD_UP;
+ if ((osd_state[osd] & CEPH_OSD_UP) &&
(s & CEPH_OSD_UP)) {
- osd_info[i->first].down_at = epoch;
- osd_xinfo[i->first].down_stamp = modified;
+ osd_info[osd].down_at = epoch;
+ osd_xinfo[osd].down_stamp = modified;
}
- if ((osd_state[i->first] & CEPH_OSD_EXISTS) &&
+ if ((osd_state[osd] & CEPH_OSD_EXISTS) &&
(s & CEPH_OSD_EXISTS)) {
// osd is destroyed; clear out anything interesting.
- (*osd_uuid)[i->first] = uuid_d();
- osd_info[i->first] = osd_info_t();
- osd_xinfo[i->first] = osd_xinfo_t();
- set_primary_affinity(i->first, CEPH_OSD_DEFAULT_PRIMARY_AFFINITY);
- osd_addrs->client_addr[i->first].reset(new entity_addr_t());
- osd_addrs->cluster_addr[i->first].reset(new entity_addr_t());
- osd_addrs->hb_front_addr[i->first].reset(new entity_addr_t());
- osd_addrs->hb_back_addr[i->first].reset(new entity_addr_t());
- osd_state[i->first] = 0;
+ (*osd_uuid)[osd] = uuid_d();
+ osd_info[osd] = osd_info_t();
+ osd_xinfo[osd] = osd_xinfo_t();
+ set_primary_affinity(osd, CEPH_OSD_DEFAULT_PRIMARY_AFFINITY);
+ osd_addrs->client_addr[osd].reset(new entity_addr_t());
+ osd_addrs->cluster_addr[osd].reset(new entity_addr_t());
+ osd_addrs->hb_front_addr[osd].reset(new entity_addr_t());
+ osd_addrs->hb_back_addr[osd].reset(new entity_addr_t());
+ osd_state[osd] = 0;
} else {
- osd_state[i->first] ^= s;
+ osd_state[osd] ^= s;
}
}
- for (map<int32_t,entity_addr_t>::const_iterator i = inc.new_up_client.begin();
- i != inc.new_up_client.end();
- ++i) {
- osd_state[i->first] |= CEPH_OSD_EXISTS | CEPH_OSD_UP;
- osd_addrs->client_addr[i->first].reset(new entity_addr_t(i->second));
+
+ for (const auto &client : inc.new_up_client) {
+ osd_state[client.first] |= CEPH_OSD_EXISTS | CEPH_OSD_UP;
+ osd_addrs->client_addr[client.first].reset(new entity_addr_t(client.second));
if (inc.new_hb_back_up.empty())
- osd_addrs->hb_back_addr[i->first].reset(new entity_addr_t(i->second)); //this is a backward-compatibility hack
+ osd_addrs->hb_back_addr[client.first].reset(new entity_addr_t(client.second)); //this is a backward-compatibility hack
else
- osd_addrs->hb_back_addr[i->first].reset(
- new entity_addr_t(inc.new_hb_back_up.find(i->first)->second));
- map<int32_t,entity_addr_t>::const_iterator j = inc.new_hb_front_up.find(i->first);
+ osd_addrs->hb_back_addr[client.first].reset(
+ new entity_addr_t(inc.new_hb_back_up.find(client.first)->second));
+ const auto j = inc.new_hb_front_up.find(client.first);
if (j != inc.new_hb_front_up.end())
- osd_addrs->hb_front_addr[i->first].reset(new entity_addr_t(j->second));
+ osd_addrs->hb_front_addr[client.first].reset(new entity_addr_t(j->second));
else
- osd_addrs->hb_front_addr[i->first].reset();
+ osd_addrs->hb_front_addr[client.first].reset();
- osd_info[i->first].up_from = epoch;
+ osd_info[client.first].up_from = epoch;
}
- for (map<int32_t,entity_addr_t>::const_iterator i = inc.new_up_cluster.begin();
- i != inc.new_up_cluster.end();
- ++i)
- osd_addrs->cluster_addr[i->first].reset(new entity_addr_t(i->second));
+
+ for (const auto &cluster : inc.new_up_cluster)
+ osd_addrs->cluster_addr[cluster.first].reset(new entity_addr_t(cluster.second));
// info
- for (map<int32_t,epoch_t>::const_iterator i = inc.new_up_thru.begin();
- i != inc.new_up_thru.end();
- ++i)
- osd_info[i->first].up_thru = i->second;
- for (map<int32_t,pair<epoch_t,epoch_t> >::const_iterator i = inc.new_last_clean_interval.begin();
- i != inc.new_last_clean_interval.end();
- ++i) {
- osd_info[i->first].last_clean_begin = i->second.first;
- osd_info[i->first].last_clean_end = i->second.second;
- }
- for (map<int32_t,epoch_t>::const_iterator p = inc.new_lost.begin(); p != inc.new_lost.end(); ++p)
- osd_info[p->first].lost_at = p->second;
+ for (const auto &thru : inc.new_up_thru)
+ osd_info[thru.first].up_thru = thru.second;
+
+ for (const auto &interval : inc.new_last_clean_interval) {
+ osd_info[interval.first].last_clean_begin = interval.second.first;
+ osd_info[interval.first].last_clean_end = interval.second.second;
+ }
+
+ for (const auto &lost : inc.new_lost)
+ osd_info[lost.first].lost_at = lost.second;
// xinfo
- for (map<int32_t,osd_xinfo_t>::const_iterator p = inc.new_xinfo.begin(); p != inc.new_xinfo.end(); ++p)
- osd_xinfo[p->first] = p->second;
+ for (const auto &xinfo : inc.new_xinfo)
+ osd_xinfo[xinfo.first] = xinfo.second;
// uuid
- for (map<int32_t,uuid_d>::const_iterator p = inc.new_uuid.begin(); p != inc.new_uuid.end(); ++p)
- (*osd_uuid)[p->first] = p->second;
+ for (const auto &uuid : inc.new_uuid)
+ (*osd_uuid)[uuid.first] = uuid.second;
// pg rebuild
- for (map<pg_t, vector<int> >::const_iterator p = inc.new_pg_temp.begin(); p != inc.new_pg_temp.end(); ++p) {
- if (p->second.empty())
- pg_temp->erase(p->first);
+ for (const auto &pg : inc.new_pg_temp) {
+ if (pg.second.empty())
+ pg_temp->erase(pg.first);
else
- (*pg_temp)[p->first] = p->second;
+ (*pg_temp)[pg.first] = pg.second;
}
- for (map<pg_t,int32_t>::const_iterator p = inc.new_primary_temp.begin();
- p != inc.new_primary_temp.end();
- ++p) {
- if (p->second == -1)
- primary_temp->erase(p->first);
+ for (const auto &pg : inc.new_primary_temp) {
+ if (pg.second == -1)
+ primary_temp->erase(pg.first);
else
- (*primary_temp)[p->first] = p->second;
+ (*primary_temp)[pg.first] = pg.second;
}
- for (auto& p : inc.new_pg_remap) {
- pg_remap[p.first] = p.second;
+ for (auto& p : inc.new_pg_upmap) {
+ pg_upmap[p.first] = p.second;
}
- for (auto& pg : inc.old_pg_remap) {
- pg_remap.erase(pg);
+ for (auto& pg : inc.old_pg_upmap) {
+ pg_upmap.erase(pg);
}
- for (auto& p : inc.new_pg_remap_items) {
- pg_remap_items[p.first] = p.second;
+ for (auto& p : inc.new_pg_upmap_items) {
+ pg_upmap_items[p.first] = p.second;
}
- for (auto& pg : inc.old_pg_remap_items) {
- pg_remap_items.erase(pg);
+ for (auto& pg : inc.old_pg_upmap_items) {
+ pg_upmap_items.erase(pg);
}
// blacklist
}
out << std::endl;
- for (auto& p : pg_remap) {
- out << "pg_remap " << p.first << " " << p.second << "\n";
+ for (auto& p : pg_upmap) {
+ out << "pg_upmap " << p.first << " " << p.second << "\n";
}
- for (auto& p : pg_remap_items) {
- out << "pg_remap_items " << p.first << " " << p.second << "\n";
+ for (auto& p : pg_upmap_items) {
+ out << "pg_upmap_items " << p.first << " " << p.second << "\n";
}
- for (map<pg_t,vector<int32_t> >::const_iterator p = pg_temp->begin();
- p != pg_temp->end();
- ++p)
- out << "pg_temp " << p->first << " " << p->second << "\n";
+ for (const auto pg : *pg_temp)
+ out << "pg_temp " << pg.first << " " << pg.second << "\n";
- for (map<pg_t,int32_t>::const_iterator p = primary_temp->begin();
- p != primary_temp->end();
- ++p)
- out << "primary_temp " << p->first << " " << p->second << "\n";
+ for (const auto pg : *primary_temp)
+ out << "primary_temp " << pg.first << " " << pg.second << "\n";
- for (ceph::unordered_map<entity_addr_t,utime_t>::const_iterator p = blacklist.begin();
- p != blacklist.end();
- ++p)
- out << "blacklist " << p->first << " expires " << p->second << "\n";
+ for (const auto &addr : blacklist)
+ out << "blacklist " << addr.first << " expires " << addr.second << "\n";
// ignore pg_swap_primary
}