]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: use _pg_to_up_acting_osds() to get_pg_acting_primary() 14266/head
authorKefu Chai <kchai@redhat.com>
Fri, 31 Mar 2017 10:32:41 +0000 (18:32 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 31 Mar 2017 10:32:43 +0000 (18:32 +0800)
avoid unnecessary swap() call of vector<int> which will be dropped on
the floor after getting its first element, which can be retrieved using
another parameter using _pg_to_up_acting_osds() directly.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/osd/OSDMap.h

index 856793bdaa23c1c01c9d92c7720a79292cd1c4c8..eb0399edda6e949e0e12f40b1365dff8a446b267 100644 (file)
@@ -800,11 +800,9 @@ public:
 
   // pg -> acting primary osd
   int get_pg_acting_primary(pg_t pg) const {
-    vector<int> group;
-    int nrep = pg_to_acting_osds(pg, group);
-    if (nrep > 0)
-      return group[0];
-    return -1;  // we fail!
+    int primary = -1;
+    _pg_to_up_acting_osds(pg, nullptr, nullptr, nullptr, &primary);
+    return primary;
   }
 
   /*