From 939bcbccb979a8a45a09ba4fa1d8d6659a54f6bd Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 10 Apr 2018 15:43:05 +0800 Subject: [PATCH] crush/CrushWrapper: don't bump up leaf stack if we are already of domain OSD Assume we have a pool of crush-failure-domain OSD, then the stack will look like: [ "0":"8" // stack[0] "0":"1" // stack[1] ] The above stack is error-prone because when passed to _choose_type_stack(), iterator **i** shall already point to orig.end() when stack[0] is done and might still get incremented while we continues to handle stack[1], and hence produce the following abnormal (**overflowed**) mapping results: ``` -36> 2018-04-06 23:06:35.041274 7f84692bd700 10 total_deviation 24.6667 overfull 4,5,6,7,8 underfull [2,0,3,9] -35> 2018-04-06 23:06:35.041278 7f84692bd700 10 osd.7 move 3 -34> 2018-04-06 23:06:35.041280 7f84692bd700 10 trying 2.0 -33> 2018-04-06 23:06:35.041310 7f84692bd700 10 2.0 [3,5,6,4,9,0,7,10] -> [1953720676,1683976050,1919120229,1769238633,838889071,3224629,101,2] -32> 2018-04-06 23:06:35.041317 7f84692bd700 10 2.0 pg_upmap_items [3,1953720676,5,1683976050,6,1919120229,4,1769238633,9,838889071,0,3224629,7,101,10,2] ``` See also: http://pulpito.ceph.com/yuriw-2018-04-06_21:35:03-rados-wip-yuri2-testing-2018-04-06-1946-luminous-distro-basic-smithi/2365151/ Signed-off-by: xie xingguo (cherry picked from commit 47155949856e50d03b50993423acedddd14546e2) --- src/crush/CrushWrapper.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 72cbbd7872e6d..86911348e563f 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -3281,7 +3281,8 @@ int CrushWrapper::try_remap_rule( if (numrep <= 0) numrep += maxout; type_stack.push_back(make_pair(type, numrep)); - type_stack.push_back(make_pair(0, 1)); + if (type > 0) + type_stack.push_back(make_pair(0, 1)); int r = _choose_type_stack(cct, type_stack, overfull, underfull, orig, i, used, &w); if (r < 0) -- 2.39.5