crush: rebuild shadow tree on "crush create-or-move/move"

This patch solves the problem below:

./bin/ceph osd crush move osd.0 root=foo rack=foo-rack host=foo-host
moved item id 0 name 'osd.0' to location {host=foo-host,rack=foo-rack,root=foo} in crush map

 ./bin/ceph osd crush rule create-replicated foo-rule foo host ssd
Error EINVAL: root foo has no devices with class ssd

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
xie xingguo 2017-07-25 14:15:24 +08:00
parent 10bf2a633f
commit f3a3180cca
2 changed files with 8 additions and 0 deletions

View File

@ -162,6 +162,8 @@ function TEST_mon_classes() {
if [ "$out" == "" ]; then
return 1
fi
ceph osd crush rule create-replicated foo-rule foo host abc || return 1
}
main crush-classes "$@"

View File

@ -953,6 +953,12 @@ int CrushWrapper::insert_item(
ldout(cct, 5) << "insert_item max_devices now " << crush->max_devices
<< dendl;
}
r = rebuild_roots_with_classes();
if (r < 0) {
ldout(cct, 0) << __func__ << " unable to rebuild roots with classes: "
<< cpp_strerror(r) << dendl;
return r;
}
return 0;
}