From: Sage Weil Date: Mon, 9 Dec 2019 15:41:31 +0000 (-0600) Subject: osd/OSDMap: new calc_pg_role() that takes a pg_shard_t X-Git-Tag: v15.1.0~577^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b76053359125f09e075c1ccd88ec09270b1bee22;p=ceph.git 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 --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 45af7ad7c28b..263d6fa7cc97 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 3020aba2559c..31cf9b2c8e0a 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,