]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "tools: osdmaptool sync with balancer module behavior"
authorDavid Zafman <dzafman@redhat.com>
Tue, 10 Dec 2019 16:55:46 +0000 (08:55 -0800)
committerDavid Zafman <dzafman@redhat.com>
Wed, 15 Jan 2020 21:23:53 +0000 (21:23 +0000)
This was the rules batching version of osdmaptool

This reverts commit f165d4ca39b1edef4bf22a7597af79339c95026f.

Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit a92f48773e9c59d49ee248de1d7951e7c9d3ac25)

src/test/cli/osdmaptool/upmap-out.t
src/test/cli/osdmaptool/upmap.t
src/tools/osdmaptool.cc

index 6bafe38b11a73460c2fd86a0eb4ee4784f4ca68f..8a167aba09a9281649828a080c4a70d453e21a8d 100644 (file)
@@ -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
index 36746fbfff62d605649d2bc8d4499a385149853a..8fa1a610313649a7a869a7997179e104b59aea2d 100644 (file)
@@ -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
index 0195ff74b096f2813fccb4cc821397dee515914b..aaac510a74fe9d3f13761db009d06b12e5059b51 100644 (file)
@@ -147,7 +147,6 @@ int main(int argc, const char **argv)
   std::set<std::string> 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<int64_t> > 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<int> 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<int64_t> 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;
     }