From: Sage Weil Date: Fri, 26 Oct 2018 17:40:32 +0000 (-0500) Subject: crushtool: implement --rebuild-class-roots command X-Git-Tag: v14.1.0~788^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6fe1ea0dd58b087ceb88e3f3ca552a9f721b86ac;p=ceph.git crushtool: implement --rebuild-class-roots command 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 --- diff --git a/src/test/cli/crushtool/help.t b/src/test/cli/crushtool/help.t index 4b2e056c89ba..77460bd2c68e 100644 --- a/src/test/cli/crushtool/help.t +++ b/src/test/cli/crushtool/help.t @@ -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 to start from , replicate across buckets of type , using diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index d6a01864ec69..918b341b5d9a 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -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 to start from ,\n" << " replicate across buckets of 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);