]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: use adjust_item_weight_in_bucket for subtree reweight
authorSage Weil <sage@redhat.com>
Thu, 14 Mar 2019 17:38:26 +0000 (12:38 -0500)
committerSage Weil <sage@redhat.com>
Wed, 20 Mar 2019 09:57:50 +0000 (04:57 -0500)
This avoids clobbering weight-sets when you reweight, if the
adjust_weight_sets=false.

Signed-off-by: Sage Weil <sage@redhat.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h

index 2b67947f893651845f1007ae1850dc812795f446..8b12c3db3abbdc84deb8bad091adb9c9814d4a9d 100644 (file)
@@ -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; i<b->size; ++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;
 }
index 299ae35ca75529729b615d3e727bce6b750ca373..0fd2b3723b95f6c91aeeaa4cc8b875fa0ee6d808 100644 (file)
@@ -991,13 +991,16 @@ public:
                       crush_choose_arg_map& arg_map,
                       vector<uint32_t> *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