]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMonitor: when thrashing, only generate valid temp pg mappings
authorSamuel Just <sam.just@inktank.com>
Tue, 25 Feb 2014 20:34:57 +0000 (12:34 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 25 Feb 2014 23:27:02 +0000 (15:27 -0800)
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 <sam.just@inktank.com>
src/mon/OSDMonitor.cc

index 26c588d603e994ef52149de285c5e40ccef84798..7febc5b7203c47819ca22e166feeac47d9239712 100644 (file)
@@ -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<int> 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<int>::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<int>::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;