From 46b72611f3e59ec24d944ba907ece4659180c0c5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 14 Mar 2019 12:38:26 -0500 Subject: [PATCH] crush/CrushWrapper: use adjust_item_weight_in_bucket for subtree reweight This avoids clobbering weight-sets when you reweight, if the adjust_weight_sets=false. Signed-off-by: Sage Weil --- src/crush/CrushWrapper.cc | 8 +++----- src/crush/CrushWrapper.h | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 2b67947f893..8b12c3db3ab 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1528,7 +1528,8 @@ int CrushWrapper::adjust_item_weight_in_loc( return changed; } -int CrushWrapper::adjust_subtree_weight(CephContext *cct, int id, int weight) +int CrushWrapper::adjust_subtree_weight(CephContext *cct, int id, int weight, + bool update_weight_sets) { ldout(cct, 5) << __func__ << " " << id << " weight " << weight << dendl; crush_bucket *b = get_bucket(id); @@ -1544,7 +1545,7 @@ int CrushWrapper::adjust_subtree_weight(CephContext *cct, int id, int weight) for (unsigned i=0; isize; ++i) { int n = b->items[i]; if (n >= 0) { - bucket_adjust_item_weight(cct, b, n, weight); + adjust_item_weight_in_bucket(cct, n, weight, b->id, update_weight_sets); ++changed; ++local_changed; } else { @@ -1554,9 +1555,6 @@ int CrushWrapper::adjust_subtree_weight(CephContext *cct, int id, int weight) q.push_back(sub); } } - if (local_changed) { - adjust_item_weight(cct, b->id, b->weight); - } } return changed; } diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 299ae35ca75..0fd2b3723b9 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -991,13 +991,16 @@ public: crush_choose_arg_map& arg_map, vector *weightv); - int adjust_subtree_weight(CephContext *cct, int id, int weight); - int adjust_subtree_weightf(CephContext *cct, int id, float weight) { + int adjust_subtree_weight(CephContext *cct, int id, int weight, + bool update_weight_sets=true); + int adjust_subtree_weightf(CephContext *cct, int id, float weight, + bool update_weight_sets=true) { int r = validate_weightf(weight); if (r < 0) { return r; } - return adjust_subtree_weight(cct, id, (int)(weight * (float)0x10000)); + return adjust_subtree_weight(cct, id, (int)(weight * (float)0x10000), + update_weight_sets); } /// check if item id is present in the map hierarchy -- 2.39.5