for (auto osd : osds) {
vector<spg_t> spgs;
epoch_t epoch;
- cluster_state.with_pgmap([&](const PGMap& pgmap) {
- cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- epoch = osdmap.get_epoch();
- auto p = pgmap.pg_by_osd.find(osd);
- if (p != pgmap.pg_by_osd.end()) {
- for (auto pgid : p->second) {
- int primary;
- spg_t spg;
- osdmap.get_primary_shard(pgid, &primary, &spg);
- if (primary == osd) {
- spgs.push_back(spg);
- }
- }
+ cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pgmap) {
+ epoch = osdmap.get_epoch();
+ auto p = pgmap.pg_by_osd.find(osd);
+ if (p != pgmap.pg_by_osd.end()) {
+ for (auto pgid : p->second) {
+ int primary;
+ spg_t spg;
+ osdmap.get_primary_shard(pgid, &primary, &spg);
+ if (primary == osd) {
+ spgs.push_back(spg);
}
- });
+ }
+ }
});
auto p = osd_cons.find(osd);
if (p == osd_cons.end()) {
cmd_getval(g_ceph_context, cmdctx->cmdmap, "no_increasing", no_increasing);
string out_str;
mempool::osdmap::map<int32_t, uint32_t> new_weights;
- r = cluster_state.with_pgmap([&](const PGMap& pgmap) {
- return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- return reweight::by_utilization(osdmap, pgmap,
- oload,
- max_change,
- max_osds,
- by_pg,
- pools.empty() ? NULL : &pools,
- no_increasing,
- &new_weights,
- &ss, &out_str, f.get());
- });
+ r = cluster_state.with_osdmap_and_pgmap([&](const OSDMap &osdmap, const PGMap& pgmap) {
+ return reweight::by_utilization(osdmap, pgmap,
+ oload,
+ max_change,
+ max_osds,
+ by_pg,
+ pools.empty() ? NULL : &pools,
+ no_increasing,
+ &new_weights,
+ &ss, &out_str, f.get());
});
if (r >= 0) {
dout(10) << "reweight::by_utilization: finished with " << out_str << dendl;
} else if (prefix == "osd df") {
string method;
cmd_getval(g_ceph_context, cmdctx->cmdmap, "output_method", method);
- r = cluster_state.with_pgmap([&](const PGMap& pgmap) {
- return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- print_osd_utilization(osdmap, pgmap, ss,
- f.get(), method == "tree");
-
- cmdctx->odata.append(ss);
- return 0;
- });
+ r = cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pgmap) {
+ print_osd_utilization(osdmap, pgmap, ss,
+ f.get(), method == "tree");
+
+ cmdctx->odata.append(ss);
+ return 0;
});
cmdctx->reply(r, "");
return true;
cmd_getval(g_ceph_context, cmdctx->cmdmap, "pool_name", pool_name);
int64_t poolid = -ENOENT;
bool one_pool = false;
- r = cluster_state.with_pgmap([&](const PGMap& pg_map) {
- return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
+ r = cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
if (!pool_name.empty()) {
poolid = osdmap.lookup_pg_pool_name(pool_name);
if (poolid < 0) {
}
return 0;
});
- });
if (r != -EOPNOTSUPP) {
cmdctx->reply(r, ss);
return true;
}
set<int> active_osds, missing_stats, stored_pgs, safe_to_destroy;
int affected_pgs = 0;
- cluster_state.with_pgmap([&](const PGMap& pg_map) {
+ cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
if (pg_map.num_pg_unknown > 0) {
ss << pg_map.num_pg_unknown << " pgs have unknown state; cannot draw"
<< " any conclusions";
num_active_clean += p.second;
}
}
- cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- for (auto osd : osds) {
- if (!osdmap.exists(osd)) {
- safe_to_destroy.insert(osd);
- continue; // clearly safe to destroy
- }
- auto q = pg_map.num_pg_by_osd.find(osd);
- if (q != pg_map.num_pg_by_osd.end()) {
- if (q->second.acting > 0 || q->second.up > 0) {
- active_osds.insert(osd);
- affected_pgs += q->second.acting + q->second.up;
- continue;
- }
- }
- if (num_active_clean < pg_map.num_pg) {
- // all pgs aren't active+clean; we need to be careful.
- auto p = pg_map.osd_stat.find(osd);
- if (p == pg_map.osd_stat.end()) {
- missing_stats.insert(osd);
- continue;
- } else if (p->second.num_pgs > 0) {
- stored_pgs.insert(osd);
- continue;
- }
- }
- safe_to_destroy.insert(osd);
+ for (auto osd : osds) {
+ if (!osdmap.exists(osd)) {
+ safe_to_destroy.insert(osd);
+ continue; // clearly safe to destroy
+ }
+ auto q = pg_map.num_pg_by_osd.find(osd);
+ if (q != pg_map.num_pg_by_osd.end()) {
+ if (q->second.acting > 0 || q->second.up > 0) {
+ active_osds.insert(osd);
+ affected_pgs += q->second.acting + q->second.up;
+ continue;
}
- });
+ }
+ if (num_active_clean < pg_map.num_pg) {
+ // all pgs aren't active+clean; we need to be careful.
+ auto p = pg_map.osd_stat.find(osd);
+ if (p == pg_map.osd_stat.end()) {
+ missing_stats.insert(osd);
+ continue;
+ } else if (p->second.num_pgs > 0) {
+ stored_pgs.insert(osd);
+ continue;
+ }
+ }
+ safe_to_destroy.insert(osd);
+ }
});
if (!r && (!active_osds.empty() ||
!missing_stats.empty() || !stored_pgs.empty())) {
}
map<pg_t,int> pg_delta; // pgid -> net acting set size change
int dangerous_pgs = 0;
- cluster_state.with_pgmap([&](const PGMap& pg_map) {
- return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- if (pg_map.num_pg_unknown > 0) {
- ss << pg_map.num_pg_unknown << " pgs have unknown state; "
- << "cannot draw any conclusions";
- r = -EAGAIN;
- return;
- }
- for (auto osd : osds) {
- auto p = pg_map.pg_by_osd.find(osd);
- if (p != pg_map.pg_by_osd.end()) {
- for (auto& pgid : p->second) {
- --pg_delta[pgid];
- }
- }
+ cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
+ if (pg_map.num_pg_unknown > 0) {
+ ss << pg_map.num_pg_unknown << " pgs have unknown state; "
+ << "cannot draw any conclusions";
+ r = -EAGAIN;
+ return;
+ }
+ for (auto osd : osds) {
+ auto p = pg_map.pg_by_osd.find(osd);
+ if (p != pg_map.pg_by_osd.end()) {
+ for (auto& pgid : p->second) {
+ --pg_delta[pgid];
}
- for (auto& p : pg_delta) {
- auto q = pg_map.pg_stat.find(p.first);
- if (q == pg_map.pg_stat.end()) {
- ss << "missing information about " << p.first << "; cannot draw"
- << " any conclusions";
- r = -EAGAIN;
- return;
- }
- if (!(q->second.state & PG_STATE_ACTIVE) ||
- (q->second.state & PG_STATE_DEGRADED)) {
- // we don't currently have a good way to tell *how* degraded
- // a degraded PG is, so we have to assume we cannot remove
- // any more replicas/shards.
- ++dangerous_pgs;
- continue;
- }
- const pg_pool_t *pi = osdmap.get_pg_pool(p.first.pool());
- if (!pi) {
- ++dangerous_pgs; // pool is creating or deleting
- } else {
- if (q->second.acting.size() + p.second < pi->min_size) {
- ++dangerous_pgs;
- }
- }
+ }
+ }
+ for (auto& p : pg_delta) {
+ auto q = pg_map.pg_stat.find(p.first);
+ if (q == pg_map.pg_stat.end()) {
+ ss << "missing information about " << p.first << "; cannot draw"
+ << " any conclusions";
+ r = -EAGAIN;
+ return;
+ }
+ if (!(q->second.state & PG_STATE_ACTIVE) ||
+ (q->second.state & PG_STATE_DEGRADED)) {
+ // we don't currently have a good way to tell *how* degraded
+ // a degraded PG is, so we have to assume we cannot remove
+ // any more replicas/shards.
+ ++dangerous_pgs;
+ continue;
+ }
+ const pg_pool_t *pi = osdmap.get_pg_pool(p.first.pool());
+ if (!pi) {
+ ++dangerous_pgs; // pool is creating or deleting
+ } else {
+ if (q->second.acting.size() + p.second < pi->min_size) {
+ ++dangerous_pgs;
}
- });
+ }
+ }
});
if (r) {
cmdctx->reply(r, ss);
}
// fall back to feeding command to PGMap
- r = cluster_state.with_pgmap([&](const PGMap& pg_map) {
- return cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- return process_pg_map_command(prefix, cmdctx->cmdmap, pg_map, osdmap,
- f.get(), &ss, &cmdctx->odata);
- });
+ r = cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
+ return process_pg_map_command(prefix, cmdctx->cmdmap, pg_map, osdmap,
+ f.get(), &ss, &cmdctx->odata);
});
if (f) {
map<string,unsigned> pg_num_to_set;
map<string,unsigned> pgp_num_to_set;
set<pg_t> upmaps_to_clear;
- cluster_state.with_pgmap([&](const PGMap& pg_map) {
+ cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap, const PGMap& pg_map) {
unsigned creating_or_unknown = 0;
for (auto& i : pg_map.num_pg_by_state) {
if ((i.first & (PG_STATE_CREATING)) ||
<< "; target_max_misplaced_ratio " << max_misplaced
<< dendl;
- cluster_state.with_osdmap([&](const OSDMap& osdmap) {
- for (auto& i : osdmap.get_pools()) {
- const pg_pool_t& p = i.second;
+ for (auto& i : osdmap.get_pools()) {
+ const pg_pool_t& p = i.second;
- // adjust pg_num?
- if (p.get_pg_num_target() != p.get_pg_num()) {
- dout(20) << "pool " << i.first
+ // adjust pg_num?
+ if (p.get_pg_num_target() != p.get_pg_num()) {
+ dout(20) << "pool " << i.first
+ << " pg_num " << p.get_pg_num()
+ << " target " << p.get_pg_num_target()
+ << dendl;
+ if (p.has_flag(pg_pool_t::FLAG_CREATING)) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - still creating initial pgs"
+ << dendl;
+ } else if (p.get_pg_num_target() < p.get_pg_num()) {
+ // pg_num decrease (merge)
+ pg_t merge_source(p.get_pg_num() - 1, i.first);
+ pg_t merge_target = merge_source.get_parent();
+ bool ok = true;
+
+ if (osdmap.have_pg_upmaps(merge_target)) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
<< " pg_num " << p.get_pg_num()
- << " target " << p.get_pg_num_target()
- << dendl;
- if (p.has_flag(pg_pool_t::FLAG_CREATING)) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - still creating initial pgs"
- << dendl;
- } else if (p.get_pg_num_target() < p.get_pg_num()) {
- // pg_num decrease (merge)
- pg_t merge_source(p.get_pg_num() - 1, i.first);
- pg_t merge_target = merge_source.get_parent();
- bool ok = true;
-
- if (osdmap.have_pg_upmaps(merge_target)) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - merge target " << merge_target
- << " has upmap" << dendl;
- upmaps_to_clear.insert(merge_target);
- ok = false;
- } else if (osdmap.have_pg_upmaps(merge_source)) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - merge source " << merge_source
- << " has upmap" << dendl;
- upmaps_to_clear.insert(merge_source);
- ok = false;
- }
+ << " - merge target " << merge_target
+ << " has upmap" << dendl;
+ upmaps_to_clear.insert(merge_target);
+ ok = false;
+ } else if (osdmap.have_pg_upmaps(merge_source)) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - merge source " << merge_source
+ << " has upmap" << dendl;
+ upmaps_to_clear.insert(merge_source);
+ ok = false;
+ }
- auto q = pg_map.pg_stat.find(merge_source);
- if (p.get_pg_num() != p.get_pg_num_pending()) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - decrease and pg_num_pending != pg_num, waiting"
- << dendl;
- ok = false;
- } else if (p.get_pg_num() == p.get_pgp_num()) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - decrease blocked by pgp_num "
- << p.get_pgp_num()
- << dendl;
- ok = false;
- } else if (q == pg_map.pg_stat.end()) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - no state for " << merge_source
- << " (merge source)"
- << dendl;
- ok = false;
- } else if (!(q->second.state & (PG_STATE_ACTIVE |
- PG_STATE_CLEAN))) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - merge source " << merge_source
- << " not clean (" << pg_state_string(q->second.state)
- << ")" << dendl;
- ok = false;
- } else if (q->second.state & PG_STATE_REMAPPED) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - merge source " << merge_source
- << " remapped" << dendl;
- ok = false;
- }
+ auto q = pg_map.pg_stat.find(merge_source);
+ if (p.get_pg_num() != p.get_pg_num_pending()) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - decrease and pg_num_pending != pg_num, waiting"
+ << dendl;
+ ok = false;
+ } else if (p.get_pg_num() == p.get_pgp_num()) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - decrease blocked by pgp_num "
+ << p.get_pgp_num()
+ << dendl;
+ ok = false;
+ } else if (q == pg_map.pg_stat.end()) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - no state for " << merge_source
+ << " (merge source)"
+ << dendl;
+ ok = false;
+ } else if (!(q->second.state & (PG_STATE_ACTIVE |
+ PG_STATE_CLEAN))) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - merge source " << merge_source
+ << " not clean (" << pg_state_string(q->second.state)
+ << ")" << dendl;
+ ok = false;
+ } else if (q->second.state & PG_STATE_REMAPPED) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - merge source " << merge_source
+ << " remapped" << dendl;
+ ok = false;
+ }
- q = pg_map.pg_stat.find(merge_target);
- if (q == pg_map.pg_stat.end()) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - no state for " << merge_target
- << " (merge target)"
+ q = pg_map.pg_stat.find(merge_target);
+ if (q == pg_map.pg_stat.end()) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - no state for " << merge_target
+ << " (merge target)"
+ << dendl;
+ ok = false;
+ } else if (!(q->second.state & (PG_STATE_ACTIVE |
+ PG_STATE_CLEAN))) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - merge target " << merge_target
+ << " not clean (" << pg_state_string(q->second.state)
+ << ")" << dendl;
+ ok = false;
+ } else if (q->second.state & PG_STATE_REMAPPED) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - merge target " << merge_target
+ << " remapped" << dendl;
+ ok = false;
+ }
+ if (ok) {
+ unsigned target = p.get_pg_num() - 1;
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " -> " << target
+ << " (merging " << merge_source
+ << " and " << merge_target
+ << ")" << dendl;
+ pg_num_to_set[osdmap.get_pool_name(i.first)] = target;
+ }
+ } else if (p.get_pg_num_target() > p.get_pg_num()) {
+ // pg_num increase (split)
+ bool active = true;
+ auto q = pg_map.num_pg_by_pool_state.find(i.first);
+ if (q != pg_map.num_pg_by_pool_state.end()) {
+ for (auto& j : q->second) {
+ if ((j.first & (PG_STATE_ACTIVE|PG_STATE_PEERED)) == 0) {
+ dout(20) << "pool " << i.first << " has " << j.second
+ << " pgs in " << pg_state_string(j.first)
<< dendl;
- ok = false;
- } else if (!(q->second.state & (PG_STATE_ACTIVE |
- PG_STATE_CLEAN))) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - merge target " << merge_target
- << " not clean (" << pg_state_string(q->second.state)
- << ")" << dendl;
- ok = false;
- } else if (q->second.state & PG_STATE_REMAPPED) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - merge target " << merge_target
- << " remapped" << dendl;
- ok = false;
- }
- if (ok) {
- unsigned target = p.get_pg_num() - 1;
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " -> " << target
- << " (merging " << merge_source
- << " and " << merge_target
- << ")" << dendl;
- pg_num_to_set[osdmap.get_pool_name(i.first)] = target;
- }
- } else if (p.get_pg_num_target() > p.get_pg_num()) {
- // pg_num increase (split)
- bool active = true;
- auto q = pg_map.num_pg_by_pool_state.find(i.first);
- if (q != pg_map.num_pg_by_pool_state.end()) {
- for (auto& j : q->second) {
- if ((j.first & (PG_STATE_ACTIVE|PG_STATE_PEERED)) == 0) {
- dout(20) << "pool " << i.first << " has " << j.second
- << " pgs in " << pg_state_string(j.first)
- << dendl;
- active = false;
- break;
- }
- }
- } else {
active = false;
- }
- if (!active) {
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " - not all pgs active"
- << dendl;
- } else {
- unsigned add = std::min(
- left,
- p.get_pg_num_target() - p.get_pg_num());
- unsigned target = p.get_pg_num() + add;
- left -= add;
- dout(10) << "pool " << i.first
- << " pg_num_target " << p.get_pg_num_target()
- << " pg_num " << p.get_pg_num()
- << " -> " << target << dendl;
- pg_num_to_set[osdmap.get_pool_name(i.first)] = target;
+ break;
}
}
+ } else {
+ active = false;
}
-
- // adjust pgp_num?
- unsigned target = std::min(p.get_pg_num_pending(),
- p.get_pgp_num_target());
- if (target != p.get_pgp_num()) {
- dout(20) << "pool " << i.first
- << " pgp_num_target " << p.get_pgp_num_target()
- << " pgp_num " << p.get_pgp_num()
+ if (!active) {
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
+ << " - not all pgs active"
+ << dendl;
+ } else {
+ unsigned add = std::min(
+ left,
+ p.get_pg_num_target() - p.get_pg_num());
+ unsigned target = p.get_pg_num() + add;
+ left -= add;
+ dout(10) << "pool " << i.first
+ << " pg_num_target " << p.get_pg_num_target()
+ << " pg_num " << p.get_pg_num()
<< " -> " << target << dendl;
- if (target > p.get_pgp_num() &&
- p.get_pgp_num() == p.get_pg_num()) {
- dout(10) << "pool " << i.first
- << " pgp_num_target " << p.get_pgp_num_target()
- << " pgp_num " << p.get_pgp_num()
- << " - increase blocked by pg_num " << p.get_pg_num()
- << dendl;
- } else if (!aggro && (inactive_pgs_ratio > 0 ||
- degraded_ratio > 0 ||
- unknown_pgs_ratio > 0)) {
- dout(10) << "pool " << i.first
- << " pgp_num_target " << p.get_pgp_num_target()
- << " pgp_num " << p.get_pgp_num()
- << " - inactive|degraded|unknown pgs, deferring pgp_num"
- << " update" << dendl;
- } else if (!aggro && (misplaced_ratio > max_misplaced)) {
- dout(10) << "pool " << i.first
- << " pgp_num_target " << p.get_pgp_num_target()
- << " pgp_num " << p.get_pgp_num()
- << " - misplaced_ratio " << misplaced_ratio
- << " > max " << max_misplaced
- << ", deferring pgp_num update" << dendl;
+ pg_num_to_set[osdmap.get_pool_name(i.first)] = target;
+ }
+ }
+ }
+
+ // adjust pgp_num?
+ unsigned target = std::min(p.get_pg_num_pending(),
+ p.get_pgp_num_target());
+ if (target != p.get_pgp_num()) {
+ dout(20) << "pool " << i.first
+ << " pgp_num_target " << p.get_pgp_num_target()
+ << " pgp_num " << p.get_pgp_num()
+ << " -> " << target << dendl;
+ if (target > p.get_pgp_num() &&
+ p.get_pgp_num() == p.get_pg_num()) {
+ dout(10) << "pool " << i.first
+ << " pgp_num_target " << p.get_pgp_num_target()
+ << " pgp_num " << p.get_pgp_num()
+ << " - increase blocked by pg_num " << p.get_pg_num()
+ << dendl;
+ } else if (!aggro && (inactive_pgs_ratio > 0 ||
+ degraded_ratio > 0 ||
+ unknown_pgs_ratio > 0)) {
+ dout(10) << "pool " << i.first
+ << " pgp_num_target " << p.get_pgp_num_target()
+ << " pgp_num " << p.get_pgp_num()
+ << " - inactive|degraded|unknown pgs, deferring pgp_num"
+ << " update" << dendl;
+ } else if (!aggro && (misplaced_ratio > max_misplaced)) {
+ dout(10) << "pool " << i.first
+ << " pgp_num_target " << p.get_pgp_num_target()
+ << " pgp_num " << p.get_pgp_num()
+ << " - misplaced_ratio " << misplaced_ratio
+ << " > max " << max_misplaced
+ << ", deferring pgp_num update" << dendl;
+ } else {
+ // NOTE: this calculation assumes objects are
+ // basically uniformly distributed across all PGs
+ // (regardless of pool), which is probably not
+ // perfectly correct, but it's a start. make no
+ // single adjustment that's more than half of the
+ // max_misplaced, to somewhat limit the magnitude of
+ // our potential error here.
+ int next;
+ if (aggro) {
+ next = target;
+ } else {
+ double room =
+ std::min<double>(max_misplaced - misplaced_ratio,
+ misplaced_ratio / 2.0);
+ unsigned estmax = std::max<unsigned>(
+ (double)p.get_pg_num() * room, 1u);
+ int delta = target - p.get_pgp_num();
+ next = p.get_pgp_num();
+ if (delta < 0) {
+ next += std::max<int>(-estmax, delta);
} else {
- // NOTE: this calculation assumes objects are
- // basically uniformly distributed across all PGs
- // (regardless of pool), which is probably not
- // perfectly correct, but it's a start. make no
- // single adjustment that's more than half of the
- // max_misplaced, to somewhat limit the magnitude of
- // our potential error here.
- int next;
- if (aggro) {
- next = target;
- } else {
- double room =
- std::min<double>(max_misplaced - misplaced_ratio,
- misplaced_ratio / 2.0);
- unsigned estmax = std::max<unsigned>(
- (double)p.get_pg_num() * room, 1u);
- int delta = target - p.get_pgp_num();
- next = p.get_pgp_num();
- if (delta < 0) {
- next += std::max<int>(-estmax, delta);
- } else {
- next += std::min<int>(estmax, delta);
- }
- dout(20) << " room " << room << " estmax " << estmax
- << " delta " << delta << " next " << next << dendl;
- }
- dout(10) << "pool " << i.first
- << " pgp_num_target " << p.get_pgp_num_target()
- << " pgp_num " << p.get_pgp_num()
- << " -> " << next << dendl;
- pgp_num_to_set[osdmap.get_pool_name(i.first)] = next;
+ next += std::min<int>(estmax, delta);
}
+ dout(20) << " room " << room << " estmax " << estmax
+ << " delta " << delta << " next " << next << dendl;
}
- if (left == 0) {
- return;
- }
+ dout(10) << "pool " << i.first
+ << " pgp_num_target " << p.get_pgp_num_target()
+ << " pgp_num " << p.get_pgp_num()
+ << " -> " << next << dendl;
+ pgp_num_to_set[osdmap.get_pool_name(i.first)] = next;
}
- });
+ }
+ if (left == 0) {
+ return;
+ }
+ }
});
for (auto i : pg_num_to_set) {
const string cmd =