]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMap: add primary out params to internal _pg_to_up_acting_osds function
authorGreg Farnum <greg@inktank.com>
Thu, 19 Dec 2013 22:39:05 +0000 (14:39 -0800)
committerGreg Farnum <greg@inktank.com>
Thu, 16 Jan 2014 00:33:07 +0000 (16:33 -0800)
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 <greg@inktank.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index cf3e53ef28354dd708e8575b84329caf5135084b..ced6a8f696ff98f210fea7a685d05b373f730ed8 100644 (file)
@@ -1324,17 +1324,22 @@ void OSDMap::pg_to_raw_up(pg_t pg, vector<int> *up, int *primary) const
   *primary = (up->empty() ? -1 : up->front());
 }
   
-void OSDMap::_pg_to_up_acting_osds(pg_t pg, vector<int> *up, vector<int>& acting) const
+void OSDMap::_pg_to_up_acting_osds(pg_t pg, vector<int> *up, int *up_primary,
+                                   vector<int> *acting, int *acting_primary) const
 {
   const pg_pool_t *pool = get_pg_pool(pg.pool());
   if (!pool)
     return;
   vector<int> raw;
   vector<int> *_up = (up ? up : new vector<int>);
-  _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;
 }
index b150546e242022f7491bd8f4c0d41a809430951e..580a3af5aa4764ae95171ba04fff2ce63ffa1dbd 100644 (file)
@@ -513,9 +513,12 @@ private:
 
   bool _get_temp_osds(const pg_pool_t& pool, pg_t pg, vector<int>& 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<int> *up,
-                             vector<int>& 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<int> *up, int *up_primary,
+                             vector<int> *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<int> *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<int>& acting) const {
@@ -552,9 +554,7 @@ public:
    */
   void pg_to_up_acting_osds(pg_t pg, vector<int> *up, int *up_primary,
                             vector<int> *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<int>& up, vector<int>& acting) const {
     int up_primary, acting_primary;