]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crushtool: implement --rebuild-class-roots command 24502/head
authorSage Weil <sage@redhat.com>
Fri, 26 Oct 2018 17:40:32 +0000 (12:40 -0500)
committerSage Weil <sage@redhat.com>
Wed, 28 Nov 2018 02:36:43 +0000 (20:36 -0600)
This simply rebuilds the class roots.  Normally this should create no
change in the map since whatever was making changes to the map before
should have rebuild the shadow roots at that point.

Signed-off-by: Sage Weil <sage@redhat.com>
src/test/cli/crushtool/help.t
src/tools/crushtool.cc

index 4b2e056c89bace343318e106f772686922620d13..77460bd2c68e4848c994b1051b7db7e69064436d 100644 (file)
@@ -63,6 +63,8 @@
      -i mapfn --move       name --loc type name ...
                            move the given item to specified location
      -i mapfn --reweight   recalculate all bucket weights
+     -i mapfn --rebuild-class-roots
+                           rebuild the per-class shadow trees (normally a no-op)
      -i mapfn --create-simple-rule name root type mode
                            create crush rule <name> to start from <root>,
                            replicate across buckets of type <type>, using
index d6a01864ec697e548b3c0bab5798939132b6da50..918b341b5d9a09289d5a992176d8e5a362c5ce43 100644 (file)
@@ -171,6 +171,8 @@ void usage()
   cout << "   -i mapfn --move       name --loc type name ...\n"
        << "                         move the given item to specified location\n";
   cout << "   -i mapfn --reweight   recalculate all bucket weights\n";
+  cout << "   -i mapfn --rebuild-class-roots\n";
+  cout << "                         rebuild the per-class shadow trees (normally a no-op)\n";
   cout << "   -i mapfn --create-simple-rule name root type mode\n"
        << "                         create crush rule <name> to start from <root>,\n"
        << "                         replicate across buckets of type <type>, using\n"
@@ -388,6 +390,8 @@ int main(int argc, const char **argv)
   int verbose = 0;
   bool unsafe_tunables = false;
 
+  bool rebuild_class_roots = false;
+
   bool reweight = false;
   int add_item = -1;
   bool add_bucket = false;
@@ -552,6 +556,8 @@ int main(int argc, const char **argv)
       adjust = true;
     } else if (ceph_argparse_flag(args, i, "--reweight", (char*)NULL)) {
       reweight = true;
+    } else if (ceph_argparse_flag(args, i, "--rebuild-class-roots", (char*)NULL)) {
+      rebuild_class_roots = true;
     } else if (ceph_argparse_witharg(args, i, &add_item, err, "--add_item", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
@@ -821,7 +827,7 @@ int main(int argc, const char **argv)
   }
   if (!check && !compile && !decompile && !build && !test && !reweight && !adjust && !tree && !dump &&
       add_item < 0 && !add_bucket && !move_item && !add_rule && !del_rule && full_location < 0 &&
-      !reclassify &&
+      !reclassify && !rebuild_class_roots &&
       compare.empty() &&
       remove_name.empty() && reweight_name.empty()) {
     cerr << "no action specified; -h for help" << std::endl;
@@ -1164,6 +1170,14 @@ int main(int argc, const char **argv)
     crush.reweight(g_ceph_context);
     modified = true;
   }
+  if (rebuild_class_roots) {
+    int r = crush.rebuild_roots_with_classes();
+    if (r < 0) {
+      cerr << "failed to rebuidl roots with classes" << std::endl;
+      return EXIT_FAILURE;
+    }
+    modified = true;
+  }
 
   for (auto& i : set_subtree_class) {
     crush.set_subtree_class(i.first, i.second);