]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/osdmaptool.cc: add ability to clean_temps
authorNeha Ojha <nojha@redhat.com>
Wed, 26 Aug 2020 18:08:03 +0000 (18:08 +0000)
committerNathan Cutler <ncutler@suse.com>
Tue, 29 Sep 2020 16:55:26 +0000 (18:55 +0200)
This is particularly useful for debugging purposes when clean_temps()
takes abnormally high amount of time due to flaws in crush rules etc.

Fixes: https://tracker.ceph.com/issues/47159
Signed-off-by: Neha Ojha <nojha@redhat.com>
(cherry picked from commit ab54d3821a61a4ff1ea9973c5f31ee86868b3009)

src/tools/osdmaptool.cc

index fbbcddafc6a9a4dbb01605175bd670f09942b4de..887086e55eb562b59006540702476299b20e52d9 100644 (file)
@@ -44,6 +44,7 @@ void usage()
   cout << "   --mark-out <osdid>      mark an osd as out (but do not persist)" << std::endl;
   cout << "   --with-default-pool     include default pool when creating map" << std::endl;
   cout << "   --clear-temp            clear pg_temp and primary_temp" << std::endl;
+  cout << "   --clean-temps           clean pg_temps" << std::endl;
   cout << "   --test-random           do random placements" << std::endl;
   cout << "   --test-map-pg <pgid>    map a pgid to osds" << std::endl;
   cout << "   --test-map-object <objectname> [--pool <poolid>] map an object to osds"
@@ -136,6 +137,7 @@ int main(int argc, const char **argv)
   bool mark_up_in = false;
   int marked_out = -1;
   bool clear_temp = false;
+  bool clean_temps = false;
   bool test_map_pgs = false;
   bool test_map_pgs_dump = false;
   bool test_random = false;
@@ -201,6 +203,8 @@ int main(int argc, const char **argv)
       marked_out = std::stoi(val);
     } else if (ceph_argparse_flag(args, i, "--clear-temp", (char*)NULL)) {
       clear_temp = true;
+    } else if (ceph_argparse_flag(args, i, "--clean-temps", (char*)NULL)) {
+      clean_temps = true;
     } else if (ceph_argparse_flag(args, i, "--test-map-pgs", (char*)NULL)) {
       test_map_pgs = true;
     } else if (ceph_argparse_flag(args, i, "--test-map-pgs-dump", (char*)NULL)) {
@@ -357,6 +361,14 @@ int main(int argc, const char **argv)
     cout << "clearing pg/primary temp" << std::endl;
     osdmap.clear_temp();
   }
+  if (clean_temps) {
+    cout << "cleaning pg temps" << std::endl;
+    OSDMap::Incremental pending_inc(osdmap.get_epoch()+1);
+    OSDMap tmpmap;
+    tmpmap.deepish_copy_from(osdmap);
+    tmpmap.apply_incremental(pending_inc);
+    OSDMap::clean_temps(g_ceph_context, osdmap, tmpmap, &pending_inc);
+  }
   int upmap_fd = STDOUT_FILENO;
   if (upmap || upmap_cleanup) {
     if (upmap_file != "-") {