From 6f8b96a9fe4793906c74a571109a457aca7ca220 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 13 Nov 2014 10:59:22 -0800 Subject: [PATCH] crush/CrushWrapper: fix detach_bucket 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 --- src/crush/CrushWrapper.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index af7447a6d369..88388940d39a 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -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) { -- 2.47.3