]> 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>
Fri, 22 Mar 2019 10:02:05 +0000 (05:02 -0500)
This avoids clobbering weight-sets when you reweight, if the
adjust_weight_sets=false.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 46b72611f3e59ec24d944ba907ece4659180c0c5)

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

index 7135646ab44f41e5a42fbff8ab15d18c38c75972..4d4dea282e208867b0379e8a934a5d94122121a8 100644 (file)
@@ -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; 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 {
@@ -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;
 }
index 9cd19e96397f720688e736aff31bcb781ee09b63..fcd85160f7afdb4339fb5f9d9619031215d67fb4 100644 (file)
@@ -988,13 +988,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