]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: make 'remove_root' idempotent
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 31 Jul 2017 09:24:55 +0000 (17:24 +0800)
committerSage Weil <sage@redhat.com>
Thu, 3 Aug 2017 21:26:26 +0000 (17:26 -0400)
We might use 'crush link' to link same host into
different roots, which as a result can cause different
shadow trees reference same hosts too.

This means we may need to destory the same buckets(hosts, racks, etc.)
multiple times during rebuilding all shadow trees and hence 'remove_root'
shall be idempotent.

Fixes: http://tracker.ceph.com/issues/20845
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/crush/CrushWrapper.cc

index bcafc17804987fe1f20050776db252aa4b26c6a2..37d6f8a18a9a80f964203b0a5c066538ffff1ba3 100644 (file)
@@ -369,8 +369,15 @@ int CrushWrapper::remove_root(int item, bool unused)
     return 0;
 
   crush_bucket *b = get_bucket(item);
-  if (IS_ERR(b))
-    return -ENOENT;
+  if (IS_ERR(b)) {
+    // should be idempotent
+    // e.g.: we use 'crush link' to link same host into
+    // different roots, which as a result can cause different
+    // shadow trees reference same hosts too. This means
+    // we may need to destory the same buckets(hosts, racks, etc.)
+    // multiple times during rebuilding all shadow trees.
+    return 0;
+  }
 
   for (unsigned n = 0; n < b->size; n++) {
     if (b->items[n] >= 0)