]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: fix detach_bucket 2920/head
authorSage Weil <sage@redhat.com>
Thu, 13 Nov 2014 18:59:22 +0000 (10:59 -0800)
committerSage Weil <sage@redhat.com>
Thu, 13 Nov 2014 18:59:58 +0000 (10:59 -0800)
In commit 9850227d2f0ca2f692a154de2c14a0a08e751f08 we changed the call that
changed the weight of all instances of item to one that explicitly
changes it in the parent bucket, but parent_id may not be valid at the
call site.  Move this into the conditional block to fix.

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

index af7447a6d3692987700ed10f0a62fb89c2a4672b..88388940d39a2c9a4c0bfbc7ab1bd6f2dbb82abe 100644 (file)
@@ -779,11 +779,11 @@ private:
     // get the parent bucket
     crush_bucket *parent_bucket = get_bucket(parent_id);
 
-    // zero out the bucket weight
-    crush_bucket_adjust_item_weight(parent_bucket, item, 0);
-    adjust_item_weight(cct, parent_bucket->id, parent_bucket->weight);
-
     if (!IS_ERR(parent_bucket)) {
+      // zero out the bucket weight
+      crush_bucket_adjust_item_weight(parent_bucket, item, 0);
+      adjust_item_weight(cct, parent_bucket->id, parent_bucket->weight);
+
       // remove the bucket from the parent
       crush_bucket_remove_item(parent_bucket, item);
     } else if (PTR_ERR(parent_bucket) != -ENOENT) {