From: Sage Weil Date: Thu, 14 Mar 2019 17:40:23 +0000 (-0500) Subject: crush/CrushWrapper: insert_item: make weight-set update optional (for leaves only) X-Git-Tag: v15.0.0~144^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5579f388af18c55d03cbf32c244488ee38169fc2;p=ceph.git crush/CrushWrapper: insert_item: make weight-set update optional (for leaves only) If it is a bucket, we should sum the weight-set values to weight the bucket in the subtrees. It only makes sense to reset the weight-set weights for leaf items. Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 6af6084207c..a11bf5297ba 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1055,7 +1055,8 @@ int CrushWrapper::get_leaves(const string &name, set *leaves) const int CrushWrapper::insert_item( CephContext *cct, int item, float weight, string name, - const map& loc) // typename -> bucketname + const map& loc, // typename -> bucketname + bool init_weight_sets) { ldout(cct, 5) << "insert_item item " << item << " weight " << weight << " name " << name << " loc " << loc << dendl; @@ -1155,7 +1156,8 @@ int CrushWrapper::insert_item( } // adjust the item's weight in location - if (adjust_item_weightf_in_loc(cct, item, weight, loc) > 0) { + if (adjust_item_weightf_in_loc(cct, item, weight, loc, + item >= 0 && init_weight_sets) > 0) { if (item >= crush->max_devices) { crush->max_devices = item + 1; ldout(cct, 5) << "insert_item max_devices now " << crush->max_devices diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 9cd19e96397..299ae35ca75 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -801,9 +801,12 @@ public: * @param weight item weight * @param name item name * @param loc location (map of type to bucket names) + * @param init_weight_sets initialize weight-set weights to weight (vs 0) * @return 0 for success, negative on error */ - int insert_item(CephContext *cct, int id, float weight, string name, const map& loc); + int insert_item(CephContext *cct, int id, float weight, string name, + const map& loc, + bool init_weight_sets=true); /** * move a bucket in the hierarchy to the given location