From 917a26416c0cce2230dd01ed5fc8bb3dcc013f33 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 10 Dec 2019 08:55:46 -0800 Subject: [PATCH] Revert "tools: osdmaptool sync with balancer module behavior" This was the rules batching version of osdmaptool This reverts commit f165d4ca39b1edef4bf22a7597af79339c95026f. Signed-off-by: David Zafman (cherry picked from commit a92f48773e9c59d49ee248de1d7951e7c9d3ac25) --- src/test/cli/osdmaptool/upmap-out.t | 4 +- src/test/cli/osdmaptool/upmap.t | 4 +- src/tools/osdmaptool.cc | 60 +++++++---------------------- 3 files changed, 18 insertions(+), 50 deletions(-) diff --git a/src/test/cli/osdmaptool/upmap-out.t b/src/test/cli/osdmaptool/upmap-out.t index 6bafe38b11a73..8a167aba09a92 100644 --- a/src/test/cli/osdmaptool/upmap-out.t +++ b/src/test/cli/osdmaptool/upmap-out.t @@ -8,8 +8,8 @@ writing upmap command output to: c checking for upmap cleanups upmap, max-count 11, max deviation 1 - prepared 11 changes for pools(s) rbd - prepared 11 changes in total + pools rbd + prepared 11/11 changes $ cat c ceph osd pg-upmap-items 1.7 142 145 ceph osd pg-upmap-items 1.8 219 223 diff --git a/src/test/cli/osdmaptool/upmap.t b/src/test/cli/osdmaptool/upmap.t index 36746fbfff62d..8fa1a61031364 100644 --- a/src/test/cli/osdmaptool/upmap.t +++ b/src/test/cli/osdmaptool/upmap.t @@ -7,8 +7,8 @@ writing upmap command output to: c checking for upmap cleanups upmap, max-count 11, max deviation 1 - prepared 11 changes for pools(s) rbd - prepared 11 changes in total + pools rbd + prepared 11/11 changes $ cat c ceph osd pg-upmap-items 1.7 142 147 ceph osd pg-upmap-items 1.8 219 223 diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc index 0195ff74b096f..aaac510a74fe9 100644 --- a/src/tools/osdmaptool.cc +++ b/src/tools/osdmaptool.cc @@ -147,7 +147,6 @@ int main(int argc, const char **argv) std::set upmap_pools; int64_t pg_num = -1; bool test_map_pgs_dump_all = false; - bool debug = false; std::string val; std::ostringstream err; @@ -187,8 +186,6 @@ int main(int argc, const char **argv) createsimple = true; } else if (ceph_argparse_flag(args, i, "--health", (char*)NULL)) { health = true; - } else if (ceph_argparse_flag(args, i, "--debug", (char*)NULL)) { - debug = true; } else if (ceph_argparse_flag(args, i, "--with-default-pool", (char*)NULL)) { createpool = true; } else if (ceph_argparse_flag(args, i, "--create-from-conf", (char*)NULL)) { @@ -406,55 +403,27 @@ int main(int argc, const char **argv) cout << "No pools available" << std::endl; goto skip_upmap; } - if (debug) { - cout << "pools "; - for (auto& i: pools) - cout << osdmap.get_pool_name(i) << " "; - cout << std::endl; - } - map< int, set > pools_by_rule; - for (auto&i: pools) { - const string& pool_name = osdmap.get_pool_name(i); - const pg_pool_t *p = osdmap.get_pg_pool(i); - const int rule = p->get_crush_rule(); - if (!osdmap.crush->rule_exists(rule)) { - cout << " pool " << pool_name << " does not exist" << std::endl; - continue; - } - if (p->get_pg_num() > p->get_pg_num_target()) { - cout << "pool " << pool_name << " has pending PG(s) for merging, skipping for now" << std::endl; - continue; - } - if (debug) { - cout << "pool " << i << " rule " << rule << std::endl; - } - pools_by_rule[rule].emplace(i); - } - vector rules; - for (auto& r: pools_by_rule) - rules.push_back(r.first); std::random_device rd; - std::shuffle(rules.begin(), rules.end(), std::mt19937{rd()}); - if (debug) { - for (auto& r: rules) - cout << "rule: " << r << " " << pools_by_rule[r] << std::endl; - } + std::shuffle(pools.begin(), pools.end(), std::mt19937{rd()}); + cout << "pools "; + for (auto& i: pools) + cout << osdmap.get_pool_name(i) << " "; + cout << std::endl; int total_did = 0; - int available = upmap_max; - for (auto& r: rules) { - // Assume all PGs are active+clean - // available = upmap_max - (num_pg - num_pg_active_clean) + int left = upmap_max; + for (auto& i: pools) { + set one_pool; + one_pool.insert(i); int did = osdmap.calc_pg_upmaps( g_ceph_context, upmap_deviation, - available, pools_by_rule[r], + left, one_pool, &pending_inc); - cout << "prepared " << did << " changes for pools(s) "; - for (auto i: pools_by_rule[r]) - cout << osdmap.get_pool_name(i) << " "; - cout << std::endl; total_did += did; + left -= did; + if (left <= 0) + break; } - cout << "prepared " << total_did << " changes in total" << std::endl; + cout << "prepared " << total_did << "/" << upmap_max << " changes" << std::endl; if (total_did > 0) { print_inc_upmaps(pending_inc, upmap_fd); if (upmap_save) { @@ -464,7 +433,6 @@ int main(int argc, const char **argv) } } else { cout << "Unable to find further optimization, " - << "or pool(s) pg_num is decreasing, " << "or distribution is already perfect" << std::endl; } -- 2.39.5