]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: ceph_pg_upmaps() use any overfull when there are still underfull
authorDavid Zafman <dzafman@redhat.com>
Wed, 27 Nov 2019 18:48:30 +0000 (10:48 -0800)
committerDavid Zafman <dzafman@redhat.com>
Tue, 3 Dec 2019 01:55:22 +0000 (17:55 -0800)
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit f38d38398f33f64bd49f017b1c8e737452157c53)

src/osd/OSDMap.cc

index 48d8d0c2557a3881b70929afd27e4d37e920f6e5..2f85efa5a877b6f5f27e842f4694815c18d24bb0 100644 (file)
@@ -4258,19 +4258,21 @@ int OSDMap::calc_pg_upmaps(
     ldout(cct, 30) << "Top of loop #" << max+1 << dendl;
     // build overfull and underfull
     set<int> overfull;
+    set<int> more_overfull;
+    bool using_more_overfull = false;
     vector<int> underfull;
     vector<int> more_underfull;
     for (auto i = deviation_osd.rbegin(); i != deviation_osd.rend(); i++) {
         ldout(cct, 30) << " check " << i->first << " <= " << max_deviation << dendl;
-        if (i->first <= max_deviation)
+       if (i->first <= 0)
          break;
-       ldout(cct, 30) << " add overfull osd." << i->second << dendl;
-        overfull.insert(i->second);
+        if (i->first > max_deviation) {
+         ldout(cct, 30) << " add overfull osd." << i->second << dendl;
+          overfull.insert(i->second);
+       } else {
+          more_overfull.insert(i->second);
+       }
       }
-    if (overfull.empty()) {
-      ldout(cct, 20) << __func__ << " failed to build overfull" << dendl;
-      break;
-    }
 
     for (auto i = deviation_osd.begin(); i != deviation_osd.end(); i++) {
         ldout(cct, 30) << " check " << i->first << " >= " << -(int)max_deviation << dendl;
@@ -4283,10 +4285,15 @@ int OSDMap::calc_pg_upmaps(
           more_underfull.push_back(i->second);
        }
     }
-    if (underfull.empty() && more_underfull.empty()) {
-      ldout(cct, 20) << __func__ << " failed to build underfull and more_underfull" << dendl;
+    if (underfull.empty() && overfull.empty()) {
+      ldout(cct, 20) << __func__ << " failed to build overfull and underfull" << dendl;
       break;
     }
+    if (overfull.empty() && !underfull.empty()) {
+      ldout(cct, 20) << __func__ << " Using more_overfull since we still have underfull" << dendl;
+      overfull = more_overfull;
+      using_more_overfull = true;
+    }
 
     ldout(cct, 10) << " overfull " << overfull
                    << " underfull " << underfull
@@ -4313,7 +4320,7 @@ int OSDMap::calc_pg_upmaps(
                        << " deviation " << deviation
                       << dendl;
       ceph_assert(target > 0);
-      if (deviation <= max_deviation) {
+      if (!using_more_overfull && deviation <= max_deviation) {
        ldout(cct, 10) << " osd." << osd
                        << " target " << target
                        << " deviation " << deviation