From: Sage Weil Date: Thu, 23 Aug 2012 20:27:26 +0000 (-0700) Subject: osd: prefer acting osds in calc_acting() X-Git-Tag: v0.52~46 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1c3111f25bb8c61dd7c3b15cbe3e65c97f7e827f;p=ceph.git osd: prefer acting osds in calc_acting() 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 Reviewed-by: Samuel Just --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index a97593eb76b7..849dca4c3887 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1137,7 +1137,8 @@ bool PG::calc_acting(int& newest_update_osd_id, vector& 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::const_iterator i = up.begin(); i != up.end(); ++i) { @@ -1159,6 +1160,29 @@ bool PG::calc_acting(int& newest_update_osd_id, vector& want) const } } + for (vector::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::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::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& want) const vector::const_iterator up_it = find(up.begin(), up.end(), i->first); if (up_it != up.end()) continue; + vector::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;