From 9749f30cdf82d3bd0eb2b20b952d31b9dbf016ec Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 20 Dec 2013 13:35:28 -0800 Subject: [PATCH] OSDMap: implement pg_to_up_acting_osds with primary interface Use our pointer calling conventions instead of a reference for the new version of the function. Right now we're just setting the primaries equal to the first member of up and acting (or -1 if none), but very shortly we'll modify our private OSDMap functions to export them based on the contents of temp_primary. While in general anybody querying for the mapping information will need to pay attention to whom the primary is as well, we have lots of callers who will need real code changes to do so. To serve them, we keep a version that does not export the primary, but asserts that the primary matches the first entry in its list. Signed-off-by: Greg Farnum --- src/osd/OSDMap.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 375cf92026b9..7bde573dde1f 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -533,10 +533,19 @@ public: * the acting set for data mapping purposes, but some users will * also find the up set useful for things like deciding what to * set as pg_temp. + * Each of these pointers must be non-NULL. */ - void pg_to_up_acting_osds(pg_t pg, vector& up, - vector& acting) const { - _pg_to_up_acting_osds(pg, &up, acting); + void pg_to_up_acting_osds(pg_t pg, vector *up, int *up_primary, + vector *acting, int *acting_primary) const { + _pg_to_up_acting_osds(pg, up, *acting); + *up_primary = (up->empty() ? -1 : up.front()); + *acting_primary = (acting->empty() ? -1 : acting.front()); + } + void pg_to_up_acting_osds(pg_t pg, vector& up, vector& acting) const { + int up_primary, acting_primary; + pg_to_up_acting_osds(pg, &up, &up_primary, &acting, &acting_primary); + assert(up.empty() || up_primary == up.front()); + assert(acting.empty() || acting_primary == acting.front()); } int64_t lookup_pg_pool_name(const string& name) { -- 2.47.3