]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: insert_item: make weight-set update optional (for leaves only)
authorSage Weil <sage@redhat.com>
Thu, 14 Mar 2019 17:40:23 +0000 (12:40 -0500)
committerSage Weil <sage@redhat.com>
Fri, 22 Mar 2019 10:02:11 +0000 (05:02 -0500)
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 <sage@redhat.com>
(cherry picked from commit 5579f388af18c55d03cbf32c244488ee38169fc2)

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

index 4d4dea282e208867b0379e8a934a5d94122121a8..8b12c3db3abbdc84deb8bad091adb9c9814d4a9d 100644 (file)
@@ -1044,7 +1044,8 @@ int CrushWrapper::get_leaves(const string &name, set<int> *leaves) const
 
 int CrushWrapper::insert_item(
   CephContext *cct, int item, float weight, string name,
-  const map<string,string>& loc)  // typename -> bucketname
+  const map<string,string>& loc,  // typename -> bucketname
+  bool init_weight_sets)
 {
   ldout(cct, 5) << "insert_item item " << item << " weight " << weight
                << " name " << name << " loc " << loc << dendl;
@@ -1144,7 +1145,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
index fcd85160f7afdb4339fb5f9d9619031215d67fb4..0fd2b3723b95f6c91aeeaa4cc8b875fa0ee6d808 100644 (file)
@@ -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<string,string>& loc);
+  int insert_item(CephContext *cct, int id, float weight, string name,
+                 const map<string,string>& loc,
+                 bool init_weight_sets=true);
 
   /**
    * move a bucket in the hierarchy to the given location