From f134a14eff89ac160406753ea8577af1d6df3952 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Mon, 31 Jul 2017 17:24:55 +0800 Subject: [PATCH] crush: make 'remove_root' idempotent 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 --- src/crush/CrushWrapper.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index bcafc17804987..37d6f8a18a9a8 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -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) -- 2.39.5