diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index cefcd8fee17f3..a8c017c29c5bb 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -1261,14 +1261,15 @@ class CrushWrapper { int find_rule(int ruleset, int type, int size) const { if (!crush) return -1; - if (!have_uniform_rules) { - return crush_find_rule(crush, ruleset, type, size); - } else { - if (ruleset < (int)crush->max_rules && - crush->rules[ruleset]) - return ruleset; - return -1; + if (have_uniform_rules && + ruleset < (int)crush->max_rules && + crush->rules[ruleset] && + crush->rules[ruleset]->mask.type == type && + crush->rules[ruleset]->mask.min_size <= size && + crush->rules[ruleset]->mask.max_size >= size) { + return ruleset; } + return crush_find_rule(crush, ruleset, type, size); } bool ruleset_exists(const int ruleset) const {