Skip to content

Commit

Permalink
Merge pull request #21325 from xiexingguo/wip-fix-up-seg-error
Browse files Browse the repository at this point in the history
 crush/CrushWrapper: fix potential invalid use of iterator

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
xiexingguo committed Apr 12, 2018
2 parents 997aced + 4715594 commit 110015a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/crush/CrushWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3139,6 +3139,10 @@ int CrushWrapper::_choose_type_stack(
<< " w " << w << dendl;
vector<int> o;
auto tmpi = i;
if (i == orig.end()) {
ldout(cct, 10) << __func__ << " end of orig, break 0" << dendl;
break;
}
for (auto from : w) {
ldout(cct, 10) << " from " << from << dendl;
// identify leaves under each choice. we use this to check whether any of these
Expand Down Expand Up @@ -3182,13 +3186,15 @@ int CrushWrapper::_choose_type_stack(
ldout(cct, 10) << __func__ << " pos " << pos << " replace "
<< *i << " -> " << item << dendl;
replaced = true;
assert(i != orig.end());
++i;
break;
}
}
if (!replaced) {
ldout(cct, 10) << __func__ << " pos " << pos << " keep " << *i
<< dendl;
assert(i != orig.end());
o.push_back(*i);
++i;
}
Expand Down Expand Up @@ -3304,7 +3310,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)
Expand Down

0 comments on commit 110015a

Please sign in to comment.