From: Sage Weil Date: Thu, 14 Mar 2019 17:38:26 +0000 (-0500) Subject: crush/CrushWrapper: use adjust_item_weight_in_bucket for subtree reweight X-Git-Tag: v14.2.1~117^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=70009f444cb62af5d2bef3dba96a7d190c13df63;p=ceph.git 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 (cherry picked from commit 46b72611f3e59ec24d944ba907ece4659180c0c5) --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 7135646ab44f..4d4dea282e20 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1526,7 +1526,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); @@ -1542,7 +1543,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 { @@ -1552,9 +1553,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 9cd19e96397f..fcd85160f7af 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -988,13 +988,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