]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: fix detach_bucket, remove_item[_under] vs weight-sets
authorSage Weil <sage@redhat.com>
Thu, 14 Mar 2019 17:37:49 +0000 (12:37 -0500)
committerSage Weil <sage@redhat.com>
Fri, 22 Mar 2019 10:02:01 +0000 (05:02 -0500)
Fix detach_bucket and remove_item[_under] so that they do not
clobber the buckets' weight-set summations.

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

src/crush/CrushWrapper.cc

index 6af6084207c6b6391f9ff56f0bbac4b25b2ff246..7135646ab44f41e5a42fbff8ab15d18c38c75972 100644 (file)
@@ -504,13 +504,8 @@ int CrushWrapper::remove_item(CephContext *cct, int item, bool unlink_only)
       if (id == item) {
        ldout(cct, 5) << "remove_item removing item " << item
                      << " from bucket " << b->id << dendl;
-       for (auto& p : choose_args) {
-         // weight down each weight-set to 0 before we remove the item
-         vector<int> weightv(get_choose_args_positions(p.second), 0);
-         choose_args_adjust_item_weight(cct, p.second, item, weightv, nullptr);
-       }
+       adjust_item_weight_in_bucket(cct, item, 0, b->id, true);
        bucket_remove_item(b, item);
-       adjust_item_weight(cct, b->id, b->weight);
        ret = 0;
       }
     }
@@ -583,14 +578,8 @@ int CrushWrapper::_remove_item_under(
     if (id == item) {
       ldout(cct, 5) << "_remove_item_under removing item " << item
                    << " from bucket " << b->id << dendl;
-      for (auto& p : choose_args) {
-       // weight down each weight-set to 0 before we remove the item
-       vector<int> weightv(get_choose_args_positions(p.second), 0);
-       _choose_args_adjust_item_weight_in_bucket(
-         cct, p.second, b->id, item, weightv, nullptr);
-      }
+      adjust_item_weight_in_bucket(cct, item, 0, b->id, true);
       bucket_remove_item(b, item);
-      adjust_item_weight(cct, b->id, b->weight);
       ret = 0;
     } else if (id < 0) {
       int r = remove_item_under(cct, item, id, unlink_only);
@@ -1222,13 +1211,7 @@ int CrushWrapper::detach_bucket(CephContext *cct, int item)
 
   if (!IS_ERR(parent_bucket)) {
     // zero out the bucket weight
-    bucket_adjust_item_weight(cct, parent_bucket, item, 0);
-    adjust_item_weight(cct, parent_bucket->id, parent_bucket->weight);
-    for (auto& p : choose_args) {
-      // weight down each weight-set to 0 before we remove the item
-      vector<int> weightv(get_choose_args_positions(p.second), 0);
-      choose_args_adjust_item_weight(cct, p.second, item, weightv, nullptr);
-    }
+    adjust_item_weight_in_bucket(cct, item, 0, parent_bucket->id, true);
 
     // remove the bucket from the parent
     bucket_remove_item(parent_bucket, item);