From 2af205859ddeaff4e2df32d936f5aa8c3769d42e Mon Sep 17 00:00:00 2001 From: songbaisen Date: Wed, 1 Jun 2016 17:51:39 +0800 Subject: [PATCH] osdmaptool: show all the pg map to osds info Signed-off-by:song baisen --- src/test/cli/osdmaptool/help.t | 1 + src/test/cli/osdmaptool/missing-argument.t | 1 + src/tools/osdmaptool.cc | 26 +++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/test/cli/osdmaptool/help.t b/src/test/cli/osdmaptool/help.t index d6d75470de8..aeebe1a6cdd 100644 --- a/src/test/cli/osdmaptool/help.t +++ b/src/test/cli/osdmaptool/help.t @@ -5,6 +5,7 @@ --import-crush replace osdmap's crush map with --test-map-pgs [--pool ] [--pg_num ] map all pgs --test-map-pgs-dump [--pool ] map all pgs + --test-map-pgs-dump-all [--pool ] map all pgs to osds --mark-up-in mark osds up and in (but do not persist) --clear-temp clear pg_temp and primary_temp --test-random do random placements diff --git a/src/test/cli/osdmaptool/missing-argument.t b/src/test/cli/osdmaptool/missing-argument.t index b872696b9cd..7227071dac2 100644 --- a/src/test/cli/osdmaptool/missing-argument.t +++ b/src/test/cli/osdmaptool/missing-argument.t @@ -5,6 +5,7 @@ --import-crush replace osdmap's crush map with --test-map-pgs [--pool ] [--pg_num ] map all pgs --test-map-pgs-dump [--pool ] map all pgs + --test-map-pgs-dump-all [--pool ] map all pgs to osds --mark-up-in mark osds up and in (but do not persist) --clear-temp clear pg_temp and primary_temp --test-random do random placements diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc index 803cf0696eb..634ac8fdd97 100644 --- a/src/tools/osdmaptool.cc +++ b/src/tools/osdmaptool.cc @@ -30,6 +30,7 @@ void usage() cout << " --import-crush replace osdmap's crush map with " << std::endl; cout << " --test-map-pgs [--pool ] [--pg_num ] map all pgs" << std::endl; cout << " --test-map-pgs-dump [--pool ] map all pgs" << std::endl; + cout << " --test-map-pgs-dump-all [--pool ] map all pgs to osds" << std::endl; cout << " --mark-up-in mark osds up and in (but do not persist)" << std::endl; cout << " --clear-temp clear pg_temp and primary_temp" << std::endl; cout << " --test-random do random placements" << std::endl; @@ -75,6 +76,7 @@ int main(int argc, const char **argv) bool test_map_pgs_dump = false; bool test_random = false; int64_t pg_num = -1; + bool test_map_pgs_dump_all = false; std::string val; std::ostringstream err; @@ -111,6 +113,8 @@ int main(int argc, const char **argv) test_map_pgs = true; } else if (ceph_argparse_flag(args, i, "--test-map-pgs-dump", (char*)NULL)) { test_map_pgs_dump = true; + } else if (ceph_argparse_flag(args, i, "--test-map-pgs-dump-all", (char*)NULL)) { + test_map_pgs_dump_all = true; } else if (ceph_argparse_flag(args, i, "--test-random", (char*)NULL)) { test_random = true; } else if (ceph_argparse_flag(args, i, "--clobber", (char*)NULL)) { @@ -326,7 +330,7 @@ int main(int argc, const char **argv) << ") acting (" << acting << ", p" << acting_primary << ")" << std::endl; } - if (test_map_pgs || test_map_pgs_dump) { + if (test_map_pgs || test_map_pgs_dump || test_map_pgs_dump_all) { if (pool != -1 && !osdmap.have_pg_pool(pool)) { cerr << "There is no pool " << pool << std::endl; exit(1); @@ -351,21 +355,31 @@ int main(int argc, const char **argv) for (unsigned i = 0; i < p->second.get_pg_num(); ++i) { pg_t pgid = pg_t(i, p->first); - vector osds; - int primary; + vector osds, raw, up, acting; + int primary, calced_primary, up_primary, acting_primary; if (test_random) { osds.resize(p->second.size); for (unsigned i=0; i