From 3eb69fd0cb15974e33e675babdd5d232d69c3c6d Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 19 Nov 2019 22:21:00 -0800 Subject: [PATCH] osd: For balancer crush needs the rule passed to get_parent_of_type() Fixes: https://tracker.ceph.com/issues/42718 Signed-off-by: David Zafman --- src/crush/CrushWrapper.cc | 17 +++++++++-------- src/crush/CrushWrapper.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 9f68491c657..4b90fec6217 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -3847,7 +3847,8 @@ int CrushWrapper::_choose_type_stack( vector::const_iterator& i, set& used, vector *pw, - int root_bucket) const + int root_bucket, + int rule) const { vector w = *pw; vector o; @@ -3882,7 +3883,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)) { @@ -3917,7 +3918,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()) { @@ -3989,13 +3990,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] @@ -4078,7 +4079,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(); @@ -4100,7 +4101,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(); diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 4371a32ee0f..694d0fa561c 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -1595,7 +1595,8 @@ public: std::vector::const_iterator& i, std::set& used, std::vector *pw, - int root_bucket) const; + int root_bucket, + int rule) const; int try_remap_rule( CephContext *cct, -- 2.39.5