mirror of
https://github.com/ceph/ceph
synced 2025-04-01 14:51:13 +00:00
crush: fix "crush create-or-move/move" would drop osd's class
Was: ./bin/ceph osd tree ID CLASS WEIGHT TYPE NAME UP/DOWN REWEIGHT PRI-AFF -1 3.00000 root default -2 3.00000 host gitbuilder-ceph-rpm-centos7-amd64-basic 0 ssd 1.00000 osd.0 up 1.00000 1.00000 1 ssd 1.00000 osd.1 up 1.00000 1.00000 2 ssd 1.00000 osd.2 up 1.00000 1.00000 ./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 tree ID CLASS WEIGHT TYPE NAME UP/DOWN REWEIGHT PRI-AFF -7 1.00000 root foo -6 1.00000 rack foo-rack -5 1.00000 host foo-host 0 1.00000 osd.0 up 1.00000 1.00000 -1 2.00000 root default -2 2.00000 host gitbuilder-ceph-rpm-centos7-amd64-basic 1 ssd 1.00000 osd.1 up 1.00000 1.00000 2 ssd 1.00000 osd.2 up 1.00000 1.00000 Now: ./bin/ceph osd tree ID CLASS WEIGHT TYPE NAME UP/DOWN REWEIGHT PRI-AFF -1 3.00000 root default -2 3.00000 host gitbuilder-ceph-rpm-centos7-amd64-basic 0 ssd 1.00000 osd.0 up 1.00000 1.00000 1 ssd 1.00000 osd.1 up 1.00000 1.00000 2 ssd 1.00000 osd.2 up 1.00000 1.00000 ./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 tree ID CLASS WEIGHT TYPE NAME UP/DOWN REWEIGHT PRI-AFF -7 1.00000 root foo -6 1.00000 rack foo-rack -5 1.00000 host foo-host 0 ssd 1.00000 osd.0 up 1.00000 1.00000 -1 2.00000 root default -2 2.00000 host gitbuilder-ceph-rpm-centos7-amd64-basic 1 ssd 1.00000 osd.1 up 1.00000 1.00000 2 ssd 1.00000 osd.2 up 1.00000 1.00000 Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
parent
6af733464a
commit
10bf2a633f
@ -139,6 +139,13 @@ function TEST_mon_classes() {
|
||||
local dir=$1
|
||||
|
||||
run_mon $dir a || return 1
|
||||
run_osd $dir 0 || return 1
|
||||
run_osd $dir 1 || return 1
|
||||
run_osd $dir 2 || return 1
|
||||
|
||||
test "$(get_osds_up rbd SOMETHING)" == "1 2 0" || return 1
|
||||
add_something $dir SOMETHING || return 1
|
||||
|
||||
ceph osd crush class create CLASS || return 1
|
||||
ceph osd crush class create CLASS || return 1 # idempotent
|
||||
ceph osd crush class ls | grep CLASS || return 1
|
||||
@ -148,6 +155,13 @@ function TEST_mon_classes() {
|
||||
ceph osd crush class ls | grep CLASS || return 1
|
||||
ceph osd crush class rm CLASS || return 1
|
||||
expect_failure $dir ENOENT ceph osd crush class rm CLASS || return 1
|
||||
|
||||
ceph osd crush set-device-class abc osd.2 || return 1
|
||||
ceph osd crush move osd.2 root=foo rack=foo-rack host=foo-host || return 1
|
||||
out=`ceph osd tree |awk '$1 == 2 && $2 == "abc" {print $0}'`
|
||||
if [ "$out" == "" ]; then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
main crush-classes "$@"
|
||||
|
@ -371,7 +371,9 @@ bool CrushWrapper::_maybe_remove_last_instance(CephContext *cct, int item, bool
|
||||
ldout(cct, 5) << "_maybe_remove_last_instance removing name for item " << item << dendl;
|
||||
name_map.erase(item);
|
||||
have_rmaps = false;
|
||||
class_remove_item(item);
|
||||
if (item >= 0 && !unlink_only) {
|
||||
class_remove_item(item);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user