From c5f3cca9fe30148a5630bb42588d488817df05af Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 11 Mar 2021 07:40:52 +0000 Subject: [PATCH] osd: PeeringState: respect stretch peering constraints for async recovery Happily this is pretty simple: we just need to check that the resulting wanted set can peer, which we have a function for. Run it before actually swapping the want and candidate_want sets. If we're not in stretch mode, this is a cheap function call that will always return true, so it's equivalent to what we already have for them. Signed-off-by: Greg Farnum --- src/osd/PeeringState.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 4d6892473aae7..fe1fa1a473252 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -2273,13 +2273,18 @@ void PeeringState::choose_async_recovery_replicated( vector candidate_want(*want); for (auto it = candidate_want.begin(); it != candidate_want.end(); ++it) { if (*it == cur_shard.osd) { - candidate_want.erase(it); - want->swap(candidate_want); - async_recovery->insert(cur_shard); - break; + candidate_want.erase(it); + if (pool.info.stretch_set_can_peer(candidate_want, *osdmap, NULL)) { + // if we're in stretch mode, we can only remove the osd if it doesn't + // break peering limits. + want->swap(candidate_want); + async_recovery->insert(cur_shard); + } + break; } } } + psdout(20) << __func__ << " result want=" << *want << " async_recovery=" << *async_recovery << dendl; } -- 2.39.5