From b76053359125f09e075c1ccd88ec09270b1bee22 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 9 Dec 2019 09:41:31 -0600 Subject: [PATCH] osd/OSDMap: new calc_pg_role() that takes a pg_shard_t If you have an acting set like [0,1,2,1] then osd.1 has two possible roles (1 and 3). If we simply return the first one we see then we can't correctly calculate a role for a pg like 1.0s3. Take pg_shard_t instead. Signed-off-by: Sage Weil --- src/osd/OSDMap.cc | 17 +++++++++++++++++ src/osd/OSDMap.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 45af7ad7c28..263d6fa7cc9 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -2649,6 +2649,23 @@ int OSDMap::calc_pg_role(int osd, const vector& acting, int nrep) return -1; } +int OSDMap::calc_pg_role(pg_shard_t who, const vector& acting) +{ + int nrep = acting.size(); + if (who.shard == shard_id_t::NO_SHARD) { + for (int i=0; i &oldacting, diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 3020aba2559..31cf9b2c8e0 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -1395,6 +1395,7 @@ public: static int calc_pg_role(int osd, const std::vector& acting, int nrep=0); + static int calc_pg_role(pg_shard_t who, const std::vector& acting); static bool primary_changed( int oldprimary, const std::vector &oldacting, -- 2.39.5