From: Greg Farnum Date: Tue, 8 Dec 2020 23:28:50 +0000 (+0000) Subject: mon: fix some erroneous safety asserts in OSDMonitor::try_enable_stretch_mode X-Git-Tag: v16.1.0~91^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=208957e6d99f1dfe83e5601f6db80a90a96b62cd;p=ceph.git mon: fix some erroneous safety asserts in OSDMonitor::try_enable_stretch_mode This function asserts it is not committing in error cases, because it is supposed to be run first in a trial mode, and then in a commit mode. But I wanted the asserts to be more informative than that when they are printed, so I included the failure condition as an OR clause in the assert. Unfortunately, a few of them were either written wrong or became wrong due to code movement. Fix these so they are valid and convey the desired information. Reported-by: Ronen Friedman Signed-off-by: Greg Farnum --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e6d09366d04d..8c8babfd47d7 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -14369,7 +14369,7 @@ void OSDMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay, if (retval == -1) { ss << dividing_bucket << " is not a valid crush bucket type"; *errcode = -ENOENT; - ceph_assert(!commit || dividing_id != -1); + ceph_assert(!commit || retval != -1); return; } vector subtrees; @@ -14386,7 +14386,7 @@ void OSDMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay, if (new_crush_rule_result < 0) { ss << "unrecognized crush rule " << new_crush_rule; *errcode = new_crush_rule_result; - ceph_assert(!commit || new_crush_rule_result); + ceph_assert(!commit || (new_crush_rule_result > 0)); return; } __u8 new_rule = static_cast<__u8>(new_crush_rule_result); @@ -14406,7 +14406,7 @@ void OSDMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay, if (bucket_count != 2) { ss << "currently we only support 2-site stretch clusters!"; *errcode = -EINVAL; - ceph_assert(!commit); + ceph_assert(!commit || bucket_count == 2); return; } // TODO: check CRUSH rules for pools so that we are appropriately divided