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: v16.2.0~85^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=afb874962dd4ba9d50bca364622a72ebf1457573;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 (cherry picked from commit d09253081f7703fcb5a1bebce8840b489a3fc3ab) --- diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 60a3f72e4bd..9a7af7fa224 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -2002,7 +2002,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; @@ -2019,7 +2019,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); @@ -2078,7 +2078,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); }); }