From: Greg Farnum Date: Thu, 19 Dec 2013 22:39:05 +0000 (-0800) Subject: OSDMap: add primary out params to internal _pg_to_up_acting_osds function X-Git-Tag: v0.78~329^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0c3050932b6f39a65ae24b995efc5e36ff2fc917;p=ceph.git OSDMap: add primary out params to internal _pg_to_up_acting_osds function And use pointers instead of references for out params. Now pg_to_up_acting_osds and pg_to_acting_osds can plug in to this slightly more real implementation, instead of making up their own. (We are still just using the first member anyway, but we're about to plug it into the bottom layer of functions.) Signed-off-by: Greg Farnum --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index cf3e53ef2835..ced6a8f696ff 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1324,17 +1324,22 @@ void OSDMap::pg_to_raw_up(pg_t pg, vector *up, int *primary) const *primary = (up->empty() ? -1 : up->front()); } -void OSDMap::_pg_to_up_acting_osds(pg_t pg, vector *up, vector& acting) const +void OSDMap::_pg_to_up_acting_osds(pg_t pg, vector *up, int *up_primary, + vector *acting, int *acting_primary) const { const pg_pool_t *pool = get_pg_pool(pg.pool()); if (!pool) return; vector raw; vector *_up = (up ? up : new vector); - _pg_to_osds(*pool, pg, raw); - _raw_to_up_osds(pg, raw, *up); - if (!_get_temp_osds(*pool, pg, acting)) - acting = *_up; + _pg_to_osds(*pool, pg, *raw); + _raw_to_up_osds(pg, raw, *_up); + if (up_primary) + *up_primary = (_up->empty() ? -1 : _up->front()); + if (acting && !_get_temp_osds(*pool, pg, *acting)) + *acting = *_up; + if (acting_primary) + *acting_primary = (acting->empty() ? -1 : acting->front()); if (_up != up) delete _up; } diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index b150546e2420..580a3af5aa47 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -513,9 +513,12 @@ private: bool _get_temp_osds(const pg_pool_t& pool, pg_t pg, vector& temp) const; - /// map to up and acting. Only provides up if pointer is non-NULL - void _pg_to_up_acting_osds(pg_t pg, vector *up, - vector& acting) const; + /** + * map to up and acting. Fills in whatever fields are non-NULL, but + * the passed-in vectors must be empty. + */ + void _pg_to_up_acting_osds(pg_t pg, vector *up, int *up_primary, + vector *acting, int *acting_primary) const; public: /*** @@ -528,8 +531,7 @@ public: /// map a pg to its acting set. @return acting set size int pg_to_acting_osds(pg_t pg, vector *acting, int *acting_primary) const { - _pg_to_up_acting_osds(pg, NULL, *acting); - *acting_primary = (acting->empty() ? -1 : acting->front()); + _pg_to_up_acting_osds(pg, NULL, NULL, acting, acting_primary); return acting->size(); } int pg_to_acting_osds(pg_t pg, vector& acting) const { @@ -552,9 +554,7 @@ public: */ 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()); + _pg_to_up_acting_osds(pg, up, up_primary, acting, acting_primary); } void pg_to_up_acting_osds(pg_t pg, vector& up, vector& acting) const { int up_primary, acting_primary;