]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osdmaptool: show all the pg map to osds info
authorsongbaisen <song.baisen@zte.com.cn>
Wed, 1 Jun 2016 09:51:39 +0000 (17:51 +0800)
committersongbaisen <song.baisen@zte.com.cn>
Wed, 30 Nov 2016 02:22:41 +0000 (10:22 +0800)
Signed-off-by:song baisen <song.baisen@zte.com.cn>

src/test/cli/osdmaptool/help.t
src/test/cli/osdmaptool/missing-argument.t
src/tools/osdmaptool.cc

index d6d75470de88cc2a3c312792dacf5820596897ae..aeebe1a6cdd06387d837b14a9959a5203ae81539 100644 (file)
@@ -5,6 +5,7 @@
      --import-crush <file>   replace osdmap's crush map with <file>
      --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs
      --test-map-pgs-dump [--pool <poolid>] map all pgs
+     --test-map-pgs-dump-all [--pool <poolid>] 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
index b872696b9cd593c993e439830d94596a630f70a1..7227071dac248af88378d324737de32cc6a565d7 100644 (file)
@@ -5,6 +5,7 @@
      --import-crush <file>   replace osdmap's crush map with <file>
      --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs
      --test-map-pgs-dump [--pool <poolid>] map all pgs
+     --test-map-pgs-dump-all [--pool <poolid>] 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
index 803cf0696eb28e42390c70a9ad06116e3daec6cc..634ac8fdd97472bde646fbacc84d550e96d0185b 100644 (file)
@@ -30,6 +30,7 @@ void usage()
   cout << "   --import-crush <file>   replace osdmap's crush map with <file>" << std::endl;
   cout << "   --test-map-pgs [--pool <poolid>] [--pg_num <pg_num>] map all pgs" << std::endl;
   cout << "   --test-map-pgs-dump [--pool <poolid>] map all pgs" << std::endl;
+  cout << "   --test-map-pgs-dump-all [--pool <poolid>] 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<int> osds;
-       int primary;
+       vector<int> 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<osds.size(); ++i) {
            osds[i] = rand() % osdmap.get_max_osd();
          }
          primary = osds[0];
-       } else {
+       } else if (test_map_pgs_dump_all) {
+         osdmap.pg_to_raw_osds(pgid, &raw, &calced_primary);
+         osdmap.pg_to_up_acting_osds(pgid, &up, &up_primary,
+                                &acting, &acting_primary);         
+       } else {
          osdmap.pg_to_acting_osds(pgid, &osds, &primary);
        }
        size[osds.size()]++;
 
-       if (test_map_pgs_dump)
+       if (test_map_pgs_dump) {
          cout << pgid << "\t" << osds << "\t" << primary << std::endl;
+       } else if (test_map_pgs_dump_all) {
+         cout << pgid << " raw (" << raw << ", p" << calced_primary
+              << ") up (" << up << ", p" << up_primary
+              << ") acting (" << acting << ", p" << acting_primary << ")"
+              << std::endl;
+       }
 
        for (unsigned i=0; i<osds.size(); i++) {
          //cout << " rep " << i << " on " << osds[i] << std::endl;
@@ -471,7 +485,7 @@ int main(int argc, const char **argv)
   if (!print && !tree && !modified &&
       export_crush.empty() && import_crush.empty() && 
       test_map_pg.empty() && test_map_object.empty() &&
-      !test_map_pgs && !test_map_pgs_dump) {
+      !test_map_pgs && !test_map_pgs_dump && !test_map_pgs_dump_all) {
     cerr << me << ": no action specified?" << std::endl;
     usage();
   }