diff --git a/qa/workunits/mon/crush_ops.sh b/qa/workunits/mon/crush_ops.sh index 6c13b699081..aa287c79ce3 100755 --- a/qa/workunits/mon/crush_ops.sh +++ b/qa/workunits/mon/crush_ops.sh @@ -213,4 +213,15 @@ ceph osd pool rm cool cool --yes-i-really-really-mean-it ceph osd pool rm cold cold --yes-i-really-really-mean-it ceph osd crush weight-set rm-compat +# weight set vs device classes vs move +ceph osd crush weight-set create-compat +ceph osd crush add-bucket fooo host +ceph osd crush move fooo root=default +ceph osd crush add-bucket barr rack +ceph osd crush move barr root=default +ceph osd crush move fooo rack=barr +ceph osd crush rm fooo +ceph osd crush rm barr +ceph osd crush weight-set rm-compat + echo OK diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 5b5d21a2ec5..c5be8357137 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1573,7 +1573,7 @@ int CrushWrapper::populate_classes( // accumulate weight values for each carg and bucket as we go. because it is // depth first, we will have the nested bucket weights we need when we // finish constructing the containing buckets. - map>> cmap_item_weight; // cargs -> bno -> weights + map>> cmap_item_weight; // cargs -> bno -> [bucket weight for each position] set roots; find_nonshadow_roots(&roots); for (auto &r : roots) { @@ -2182,8 +2182,10 @@ int CrushWrapper::device_class_clone( int item = copy->items[i]; if (item >= 0) { n.weight_set[s].weights[i] = o.weight_set[s].weights[item_orig_pos[i]]; - } else { + } else if ((*cmap_item_weight)[w.first].count(item)) { n.weight_set[s].weights[i] = (*cmap_item_weight)[w.first][item][s]; + } else { + n.weight_set[s].weights[i] = 0; } bucket_weights[s] += n.weight_set[s].weights[i]; }