]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: fix device_class_clone for unpopulated/empty weight-sets 22127/head
authorSage Weil <sage@redhat.com>
Mon, 21 May 2018 18:24:25 +0000 (13:24 -0500)
committerSage Weil <sage@redhat.com>
Mon, 21 May 2018 18:39:47 +0000 (13:39 -0500)
If the bucket is empty or does not have weight-set weights yet, avoid
crashing when populating the parent bucket.

Fixes: http://tracker.ceph.com/issues/23386
Signed-off-by: Sage Weil <sage@redhat.com>
qa/workunits/mon/crush_ops.sh
src/crush/CrushWrapper.cc

index 6c13b6990812534a92626776177ef8409d32a88b..aa287c79ce3a5f4ee62d4f591c6c1e3d8b6dc24f 100755 (executable)
@@ -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
index 5b5d21a2ec56bccbfdcaad1132e42f97d30f8223..c5be83571371f643c17ae1ce9f9a1de3ed1cede8 100644 (file)
@@ -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<int,map<int,vector<int>>> cmap_item_weight; // cargs -> bno -> weights
+  map<int,map<int,vector<int>>> cmap_item_weight; // cargs -> bno -> [bucket weight for each position]
   set<int> 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];
       }