]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: do not crash if you move an item with no current home
authorSage Weil <sage@inktank.com>
Sat, 17 Nov 2012 00:55:00 +0000 (16:55 -0800)
committerSage Weil <sage@inktank.com>
Sat, 8 Dec 2012 17:17:51 +0000 (09:17 -0800)
This will let us take an existing orphan and place it somewhere.

Signed-off-by: Sage Weil <sage@inktank.com>
src/crush/CrushWrapper.h

index 5f5da0ca02cfb89256d3216e97e53857af8d4595..f77991cc314cb650448ad7bed03c259616f441ec 100644 (file)
@@ -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;