]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crush/CrushTreeDumper.h
update sources to 12.2.7
[ceph.git] / ceph / src / crush / CrushTreeDumper.h
index 5bfbc14462369064abe66ba1cf07a07a904d4d25..931037cfdae13cc28f76e9d913fdf36f34e8fed2 100644 (file)
@@ -68,7 +68,7 @@ namespace CrushTreeDumper {
     explicit Dumper(const CrushWrapper *crush_,
                    const name_map_t& weight_set_names_)
       : crush(crush_), weight_set_names(weight_set_names_) {
-      crush->find_nonshadow_roots(roots);
+      crush->find_nonshadow_roots(&roots);
       root = roots.begin();
     }
     explicit Dumper(const CrushWrapper *crush_,
@@ -76,9 +76,9 @@ namespace CrushTreeDumper {
                     bool show_shadow)
       : crush(crush_), weight_set_names(weight_set_names_) {
       if (show_shadow) {
-        crush->find_roots(roots);
+        crush->find_roots(&roots);
       } else {
-        crush->find_nonshadow_roots(roots);
+        crush->find_nonshadow_roots(&roots);
       }
       root = roots.begin();
     }
@@ -127,16 +127,33 @@ namespace CrushTreeDumper {
       touched.insert(qi.id);
 
       if (qi.is_bucket()) {
-       // queue bucket contents...
+       // queue bucket contents, sorted by (class, name)
        int s = crush->get_bucket_size(qi.id);
+       map<string,pair<int,float>> sorted;
        for (int k = s - 1; k >= 0; k--) {
          int id = crush->get_bucket_item(qi.id, k);
          if (should_dump(id)) {
-           qi.children.push_back(id);
-           push_front(Item(id, qi.id, qi.depth + 1,
-                           crush->get_bucket_item_weightf(qi.id, k)));
+           string sort_by;
+           if (id >= 0) {
+             const char *c = crush->get_item_class(id);
+             sort_by = c ? c : "";
+             sort_by += "_";
+             char nn[80];
+             snprintf(nn, sizeof(nn), "osd.%08d", id);
+             sort_by += nn;
+           } else {
+             sort_by = "_";
+             sort_by += crush->get_item_name(id);
+           }
+           sorted[sort_by] = make_pair(
+             id, crush->get_bucket_item_weightf(qi.id, k));
          }
        }
+       for (auto p = sorted.rbegin(); p != sorted.rend(); ++p) {
+         qi.children.push_back(p->second.first);
+         push_front(Item(p->second.first, qi.id, qi.depth + 1,
+                         p->second.second));
+       }
       }
       return true;
     }
@@ -191,7 +208,7 @@ namespace CrushTreeDumper {
        if (b &&
            bidx < (int)cmap.size &&
            cmap.args[bidx].weight_set &&
-           cmap.args[bidx].weight_set_size >= 1) {
+           cmap.args[bidx].weight_set_positions >= 1) {
          int bpos;
          for (bpos = 0;
               bpos < (int)cmap.args[bidx].weight_set[0].size &&
@@ -207,7 +224,7 @@ namespace CrushTreeDumper {
          }
          f->open_array_section(name.c_str());
          for (unsigned opos = 0;
-              opos < cmap.args[bidx].weight_set_size;
+              opos < cmap.args[bidx].weight_set_positions;
               ++opos) {
            float w = (float)cmap.args[bidx].weight_set[opos].weights[bpos] /
              (float)0x10000;