]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: update shadow trees on update_item()
authorSage Weil <sage@newdream.net>
Mon, 22 Feb 2021 20:06:00 +0000 (14:06 -0600)
committerNathan Cutler <ncutler@suse.com>
Mon, 8 Mar 2021 17:06:54 +0000 (18:06 +0100)
insert_item() already does this, but update_item did not.

Fixes: https://tracker.ceph.com/issues/48065
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 33dee7d7bf26e675ae2783de9c25ccce53cdb321)

qa/standalone/crush/crush-classes.sh
src/crush/CrushWrapper.cc

index 509585db7e6a1837117593b9ce3fd1c6de2843df..558aabe6d93983858e82d158d76f168b9165aec4 100755 (executable)
@@ -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
 
index 2b11ce9ec131ef0a36125fd916c470686ced546e..1e87635c5cb054c02f867adf21687ac56e587d18 100644 (file)
@@ -1376,6 +1376,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) {