From dc079eb3c5007932ca17b90291eaf6c0604e2a35 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 25 Feb 2014 12:34:57 -0800 Subject: [PATCH] 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 --- src/mon/OSDMonitor.cc | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 26c588d603e99..7febc5b7203c4 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; -- 2.39.5