]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: For balancer crush needs the rule passed to get_parent_of_type()
authorDavid Zafman <dzafman@redhat.com>
Wed, 20 Nov 2019 06:21:00 +0000 (22:21 -0800)
committerDavid Zafman <dzafman@redhat.com>
Tue, 3 Dec 2019 01:36:02 +0000 (17:36 -0800)
Fixes: https://tracker.ceph.com/issues/42718
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 3eb69fd0cb15974e33e675babdd5d232d69c3c6d)

src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h

index 98a870b7cbed58a1fe7e03503813f74fe6f7714b..aef02f6560d3e219b8afa33e1ab750cb7d170004 100644 (file)
@@ -3708,7 +3708,8 @@ int CrushWrapper::_choose_type_stack(
   vector<int>::const_iterator& i,
   set<int>& used,
   vector<int> *pw,
-  int root_bucket) const
+  int root_bucket,
+  int rule) const
 {
   vector<int> w = *pw;
   vector<int> o;
@@ -3743,7 +3744,7 @@ int CrushWrapper::_choose_type_stack(
     int item = osd;
     for (int j = (int)stack.size() - 2; j >= 0; --j) {
       int type = stack[j].first;
-      item = get_parent_of_type(item, type);
+      item = get_parent_of_type(item, type, rule);
       ldout(cct, 10) << __func__ << " underfull " << osd << " type " << type
                     << " is " << item << dendl;
       if (!subtree_contains(root_bucket, item)) {
@@ -3778,7 +3779,7 @@ int CrushWrapper::_choose_type_stack(
       for (int pos = 0; pos < fanout; ++pos) {
        if (type > 0) {
          // non-leaf
-         int item = get_parent_of_type(*tmpi, type);
+         int item = get_parent_of_type(*tmpi, type, rule);
          o.push_back(item);
          int n = cum_fanout;
          while (n-- && tmpi != orig.end()) {
@@ -3850,13 +3851,13 @@ int CrushWrapper::_choose_type_stack(
                if (std::find(o.begin(), o.end(), alt) == o.end()) {
                  // see if alt has the same parent
                  if (j == 0 ||
-                     get_parent_of_type(o[pos], stack[j-1].first) ==
-                     get_parent_of_type(alt, stack[j-1].first)) {
+                     get_parent_of_type(o[pos], stack[j-1].first, rule) ==
+                     get_parent_of_type(alt, stack[j-1].first, rule)) {
                    if (j)
                      ldout(cct, 10) << "  replacing " << o[pos]
                                     << " (which has no underfull leaves) with " << alt
                                     << " (same parent "
-                                    << get_parent_of_type(alt, stack[j-1].first) << " type "
+                                    << get_parent_of_type(alt, stack[j-1].first, rule) << " type "
                                     << type << ")" << dendl;
                    else
                      ldout(cct, 10) << "  replacing " << o[pos]
@@ -3939,7 +3940,7 @@ int CrushWrapper::try_remap_rule(
         if (type > 0)
          type_stack.push_back(make_pair(0, 1));
        int r = _choose_type_stack(cct, type_stack, overfull, underfull, orig,
-                                  i, used, &w, root_bucket);
+                                  i, used, &w, root_bucket, ruleno);
        if (r < 0)
          return r;
        type_stack.clear();
@@ -3961,7 +3962,7 @@ int CrushWrapper::try_remap_rule(
       ldout(cct, 10) << " emit " << w << dendl;
       if (!type_stack.empty()) {
        int r = _choose_type_stack(cct, type_stack, overfull, underfull, orig,
-                                  i, used, &w, root_bucket);
+                                  i, used, &w, root_bucket, ruleno);
        if (r < 0)
          return r;
        type_stack.clear();
index 4faa54699d001707081d40cfa471906b6912cb65..05f928f190e36c624770b493fde8e60d262e3c55 100644 (file)
@@ -1547,7 +1547,8 @@ public:
     vector<int>::const_iterator& i,
     set<int>& used,
     vector<int> *pw,
-    int root_bucket) const;
+    int root_bucket,
+    int rule) const;
 
   int try_remap_rule(
     CephContext *cct,