From: Sage Weil Date: Mon, 22 Feb 2021 20:06:00 +0000 (-0600) Subject: crush/CrushWrapper: update shadow trees on update_item() X-Git-Tag: v15.2.13~13^2~24^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cbb2df7bf5168d97835cb3b84bad1b71c5774cde;p=ceph.git crush/CrushWrapper: update shadow trees on update_item() insert_item() already does this, but update_item did not. Fixes: https://tracker.ceph.com/issues/48065 Signed-off-by: Sage Weil (cherry picked from commit 33dee7d7bf26e675ae2783de9c25ccce53cdb321) --- diff --git a/qa/standalone/crush/crush-classes.sh b/qa/standalone/crush/crush-classes.sh index 509585db7e6..558aabe6d93 100755 --- a/qa/standalone/crush/crush-classes.sh +++ b/qa/standalone/crush/crush-classes.sh @@ -57,6 +57,34 @@ function get_osds_up() { echo $osds } +function TEST_reweight_vs_classes() { + local dir=$1 + + # CrushWrapper::update_item (and ceph osd crush set) must rebuild the shadow + # tree too. https://tracker.ceph.com/issues/48065 + + run_mon $dir a || return 1 + run_osd $dir 0 || return 1 + run_osd $dir 1 || return 1 + run_osd $dir 2 || return 1 + + ceph osd crush set-device-class ssd osd.0 || return 1 + ceph osd crush class ls-osd ssd | grep 0 || return 1 + ceph osd crush set-device-class ssd osd.1 || return 1 + ceph osd crush class ls-osd ssd | grep 1 || return 1 + + ceph osd crush reweight osd.0 1 + + h=`hostname -s` + ceph osd crush dump | jq ".buckets[] | select(.name==\"$h\") | .items[0].weight" | grep 65536 + ceph osd crush dump | jq ".buckets[] | select(.name==\"$h~ssd\") | .items[0].weight" | grep 65536 + + ceph osd crush set 0 2 host=$h + + ceph osd crush dump | jq ".buckets[] | select(.name==\"$h\") | .items[0].weight" | grep 131072 + ceph osd crush dump | jq ".buckets[] | select(.name==\"$h~ssd\") | .items[0].weight" | grep 131072 +} + function TEST_classes() { local dir=$1 diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index ed766719508..923d0df415a 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1426,6 +1426,12 @@ int CrushWrapper::update_item( << ((float)old_iweight/(float)0x10000) << " -> " << weight << dendl; adjust_item_weight_in_loc(cct, item, iweight, loc); + ret = rebuild_roots_with_classes(cct); + if (ret < 0) { + ldout(cct, 0) << __func__ << " unable to rebuild roots with classes: " + << cpp_strerror(ret) << dendl; + return ret; + } ret = 1; } if (get_item_name(item) != name) {