From: Sage Weil Date: Fri, 16 Jan 2015 21:16:29 +0000 (-0800) Subject: crushtool: add --tree option X-Git-Tag: v0.93~227^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=04c09ed276dd12ff537987cbc0ceb0eded161e4e;p=ceph.git crushtool: add --tree option Signed-off-by: Sage Weil --- diff --git a/src/test/cli/crushtool/help.t b/src/test/cli/crushtool/help.t index a26bd12caf3b..7d549195206b 100644 --- a/src/test/cli/crushtool/help.t +++ b/src/test/cli/crushtool/help.t @@ -1,6 +1,7 @@ $ crushtool --help usage: crushtool ... --decompile|-d map decompile a crush map to source + --tree print map summary as a tree --compile|-c map.txt compile a map from source [-o outfile [--clobber]] specify output for for (de)compilation diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index bca05afce819..80438d85276f 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -86,6 +86,7 @@ void usage() { cout << "usage: crushtool ...\n"; cout << " --decompile|-d map decompile a crush map to source\n"; + cout << " --tree print map summary as a tree\n"; cout << " --compile|-c map.txt compile a map from source\n"; cout << " [-o outfile [--clobber]]\n"; cout << " specify output for for (de)compilation\n"; @@ -171,6 +172,7 @@ int main(int argc, const char **argv) bool decompile = false; bool test = false; bool display = false; + bool tree = false; int full_location = -1; bool write_to_file = false; int verbose = 0; @@ -229,6 +231,8 @@ int main(int argc, const char **argv) outfn = val; } else if (ceph_argparse_flag(args, i, "-v", "--verbose", (char*)NULL)) { verbose += 1; + } else if (ceph_argparse_flag(args, i, "--tree", (char*)NULL)) { + tree = true; } else if (ceph_argparse_flag(args, i, "--show_utilization", (char*)NULL)) { display = true; tester.set_output_utilization(true); @@ -442,7 +446,7 @@ int main(int argc, const char **argv) cerr << "cannot specify more than one of compile, decompile, and build" << std::endl; exit(EXIT_FAILURE); } - if (!compile && !decompile && !build && !test && !reweight && !adjust && + if (!compile && !decompile && !build && !test && !reweight && !adjust && !tree && add_item < 0 && full_location < 0 && remove_name.empty() && reweight_name.empty()) { cerr << "no action specified; -h for help" << std::endl; @@ -513,6 +517,11 @@ int main(int argc, const char **argv) cc.decompile(cout); } } + if (tree) { + ostringstream oss; + crush.dump_tree(&oss, NULL); + dout(1) << "\n" << oss.str() << dendl; + } if (compile) { crush.create(); @@ -631,8 +640,7 @@ int main(int argc, const char **argv) { ostringstream oss; - vector<__u32> weights(crush.get_max_devices(), 0x10000); - crush.dump_tree(weights, &oss, NULL); + crush.dump_tree(&oss, NULL); dout(1) << "\n" << oss.str() << dendl; }