summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-11-17 01:55:00 +0100
committerSage Weil <sage@inktank.com>2012-12-08 18:17:51 +0100
commite227c70945f236811433fb2403056f0468530255 (patch)
tree152eb90aeefa3b5986dc9b0fa91cee7ee4daa31f
parentmon: Elector: init elector before each election (diff)
downloadceph-e227c70945f236811433fb2403056f0468530255.tar.xz
ceph-e227c70945f236811433fb2403056f0468530255.zip
crush/CrushWrapper: do not crash if you move an item with no current home
This will let us take an existing orphan and place it somewhere. Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--src/crush/CrushWrapper.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h
index 5f5da0ca02c..f77991cc314 100644
--- a/src/crush/CrushWrapper.h
+++ b/src/crush/CrushWrapper.h
@@ -556,8 +556,12 @@ private:
// get the parent bucket
crush_bucket *parent_bucket = get_bucket(parent_id);
- // remove the bucket from the parent
- crush_bucket_remove_item(parent_bucket, item);
+ if (!IS_ERR(parent_bucket)) {
+ // remove the bucket from the parent
+ crush_bucket_remove_item(parent_bucket, item);
+ } else if (PTR_ERR(parent_bucket) != -ENOENT) {
+ return PTR_ERR(parent_bucket);
+ }
// check that we're happy
int test_weight = 0;