From: Greg Farnum Date: Thu, 11 Mar 2021 10:26:47 +0000 (+0000) Subject: osd: PeeringState: fix calc_replicated_acting_stretch() syntax/logic X-Git-Tag: v17.1.0~2614^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d09253081f7703fcb5a1bebce8840b489a3fc3ab;p=ceph.git osd: PeeringState: fix calc_replicated_acting_stretch() syntax/logic There was a major error here! get_ancestor() was type-deduced to return a bucket_candidates_t -- a *copy* of what was in the map, not the reference to it we wanted to actually amend! Fix this by returning a pointer instead. There's a way to coerce things to return a reference instead but the syntax seems clumsier to me and I'm not familiar with it anyway -- this works just fine. Signed-off-by: Greg Farnum --- diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index fe1fa1a473252..f1eaef1bfa235 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -1988,7 +1988,7 @@ void PeeringState::calc_replicated_acting_stretch( osd, pool.info.peering_crush_bucket_barrier, pool.info.crush_rule); - return ancestors[ancestor]; + return &ancestors[ancestor]; }; unsigned bucket_max = pool.info.size / pool.info.peering_crush_bucket_target; @@ -2005,7 +2005,7 @@ void PeeringState::calc_replicated_acting_stretch( want->push_back(osd); acting_backfill->insert( pg_shard_t(osd, shard_id_t::NO_SHARD)); - get_ancestor(osd).inc_selected(); + get_ancestor(osd)->inc_selected(); } }; add_required(primary->first.osd); @@ -2064,7 +2064,7 @@ void PeeringState::calc_replicated_acting_stretch( // We then filter these candidates by ancestor std::for_each(candidates.begin(), candidates.end(), [&](auto cand) { - get_ancestor(cand.second).add_osd(cand.first, cand.second); + get_ancestor(cand.second)->add_osd(cand.first, cand.second); }); }