]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: prefer acting osds in calc_acting()
authorSage Weil <sage@inktank.com>
Thu, 23 Aug 2012 20:27:26 +0000 (13:27 -0700)
committerSage Weil <sage@inktank.com>
Thu, 23 Aug 2012 20:27:26 +0000 (13:27 -0700)
We currently prefer up osds, and then pull sequentially from peer_info
(strays we know about at the time).  This adds an additional preference
for the current acting, which means we can avoid changes to acting when
they are largely useless.

In particular, I observed that we chose [5,3] and later (when recovery
completed) chose [5,1] because we had since heard about an eligible stray
on 1.  That switch was basically a waste...

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
src/osd/PG.cc

index a97593eb76b74aecf01e10861265d247cb08041f..849dca4c38874c1fd40666aae071feb555fcf4f5 100644 (file)
@@ -1137,7 +1137,8 @@ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const
   unsigned usable = 1;
   unsigned backfill = 0;
 
-  // select replicas that have log contiguity with primary
+  // select replicas that have log contiguity with primary.
+  // prefer up, then acting, then any peer_info osds 
   for (vector<int>::const_iterator i = up.begin();
        i != up.end();
        ++i) {
@@ -1159,6 +1160,29 @@ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const
     }
   }
 
+  for (vector<int>::const_iterator i = acting.begin();
+       i != acting.end();
+       ++i) {
+    if (usable >= get_osdmap()->get_pg_size(info.pgid))
+      break;
+
+    // skip up osds we already considered above
+    if (*i == primary->first)
+      continue;
+    vector<int>::const_iterator up_it = find(up.begin(), up.end(), *i);
+    if (up_it != up.end())
+      continue;
+
+    const pg_info_t &cur_info = all_info.find(*i)->second;
+    if (cur_info.is_incomplete() || cur_info.last_update < primary->second.log_tail) {
+      dout(10) << " osd." << *i << " (stray) REJECTED " << cur_info << dendl;
+    } else {
+      want.push_back(*i);
+      dout(10) << " osd." << *i << " (stray) accepted " << cur_info << dendl;
+      usable++;
+    }
+  }
+
   for (map<int,pg_info_t>::const_iterator i = all_info.begin();
        i != all_info.end();
        ++i) {
@@ -1171,6 +1195,9 @@ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const
     vector<int>::const_iterator up_it = find(up.begin(), up.end(), i->first);
     if (up_it != up.end())
       continue;
+    vector<int>::const_iterator acting_it = find(acting.begin(), acting.end(), i->first);
+    if (acting_it != acting.end())
+      continue;
 
     if (i->second.is_incomplete() || i->second.last_update < primary->second.log_tail) {
       dout(10) << " osd." << i->first << " (stray) REJECTED " << i->second << dendl;