From: Samuel Just Date: Tue, 25 Feb 2014 20:34:57 +0000 (-0800) Subject: OSDMonitor: when thrashing, only generate valid temp pg mappings X-Git-Tag: v0.78~117^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc079eb3c5007932ca17b90291eaf6c0604e2a35;p=ceph.git OSDMonitor: when thrashing, only generate valid temp pg mappings Since backfill peers are no longer placed into the acting set, temp mappings will never exceed the pool size. Also, for ec pools, temp mappings will never be less than the pool size. Signed-off-by: Samuel Just --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 26c588d603e9..7febc5b7203c 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -353,18 +353,30 @@ bool OSDMonitor::thrash() while (n--) ++p; for (int i=0; i<50; i++) { + unsigned size = osdmap.get_pg_size(p->first); vector v; - for (int j=0; j<3; j++) { + bool have_real_osd = false; + for (int j=0; j < (int)size; j++) { o = rand() % osdmap.get_num_osds(); - if (osdmap.exists(o) && std::find(v.begin(), v.end(), o) == v.end()) + if (osdmap.exists(o) && std::find(v.begin(), v.end(), o) == v.end()) { + have_real_osd = true; v.push_back(o); + } + } + for (vector::iterator q = p->second.acting.begin(); + q != p->second.acting.end() && v.size() < size; + ++q) { + if (std::find(v.begin(), v.end(), *q) == v.end()) { + if (*q != CRUSH_ITEM_NONE) + have_real_osd = true; + v.push_back(*q); + } } - if (v.size() < 3) { - for (vector::iterator q = p->second.acting.begin(); q != p->second.acting.end(); ++q) - if (std::find(v.begin(), v.end(), *q) == v.end()) - v.push_back(*q); + if (osdmap.pg_is_ec(p->first)) { + while (v.size() < size) + v.push_back(CRUSH_ITEM_NONE); } - if (!v.empty()) + if (!v.empty() && have_real_osd) pending_inc.new_pg_temp[p->first] = v; dout(5) << "thrash_map pg " << p->first << " pg_temp remapped to " << v << dendl;