]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: move 'pg map' to OSDMonitor (from PGMap)
authorSage Weil <sage@redhat.com>
Fri, 14 Apr 2017 18:16:50 +0000 (14:16 -0400)
committerSage Weil <sage@redhat.com>
Fri, 14 Apr 2017 18:16:50 +0000 (14:16 -0400)
1. this belongs on the mon, operating against the latest
osdmap.
2. it shouldn't go in PGMonitor because that is about to
be turned off.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/MgrCommands.h
src/mon/MonCommands.h
src/mon/Monitor.cc
src/mon/OSDMonitor.cc
src/mon/PGMap.cc

index d7335b27eadc5947daa0c2a061b535bdae869909..17de3a8c7bba18b6230ae58f8ad62a14ed96875e 100644 (file)
@@ -37,8 +37,6 @@ COMMAND("pg ls " \
         "name=pool,type=CephInt,req=false " \
        "name=states,type=CephChoices,strings=active|clean|down|scrubbing|degraded|inconsistent|peering|repair|recovering|backfill_wait|incomplete|stale|remapped|deep_scrub|backfill|backfill_toofull|recovery_wait|undersized|activating|peered,n=N,req=false ", \
        "list pg with specific pool, osd, state", "pg", "r", "cli,rest")
-COMMAND("pg map name=pgid,type=CephPgid", "show mapping of pg to osds", \
-       "pg", "r", "cli,rest")
 COMMAND("pg dump_stuck " \
        "name=stuckops,type=CephChoices,strings=inactive|unclean|stale|undersized|degraded,n=N,req=false " \
        "name=threshold,type=CephInt,req=false",
index 4e816890820bbd3dae643af971b84e214ff535a5..329d11369ad7c69fc502de3cfef9d6707b52bea9 100644 (file)
@@ -131,6 +131,9 @@ COMMAND("pg set_nearfull_ratio name=ratio,type=CephFloat,range=0.0|1.0", \
        "set ratio at which pgs are considered nearly full",            \
        "pg", "rw", "cli,rest")
 
+COMMAND("pg map name=pgid,type=CephPgid", "show mapping of pg to osds", \
+       "pg", "r", "cli,rest")
+
 /*
  * auth commands AuthMonitor.cc
  */
index a80ceaa95c6fd500a54f2ec99ef9bd51d84b3fa2..0f9354dee06ecbc6bee67e93aefa428c9816d697 100644 (file)
@@ -2920,7 +2920,7 @@ void Monitor::handle_command(MonOpRequestRef op)
     mdsmon()->dispatch(op);
     return;
   }
-  if (module == "osd") {
+  if (module == "osd" || prefix == "pg map") {
     osdmon()->dispatch(op);
     return;
   }
index 4e75d6a3c0f930e9f172ca78e8cb87f45dd836dd..e36ecae30d69cbb0c8bca36bedc0e89f7485097a 100644 (file)
@@ -3823,6 +3823,50 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
         << pg_vector_string(acting) << ", p" << acting_p << ")";
       rdata.append(ds);
     }
+
+  } else if (prefix == "pg map") {
+    pg_t pgid;
+    string pgidstr;
+    cmd_getval(g_ceph_context, cmdmap, "pgid", pgidstr);
+    if (!pgid.parse(pgidstr.c_str())) {
+      ss << "invalid pgid '" << pgidstr << "'";
+      r = -EINVAL;
+      goto reply;
+    }
+    vector<int> up, acting;
+    if (!osdmap.have_pg_pool(pgid.pool())) {
+      ss << "pg '" << pgidstr << "' does not exist";
+      r = -ENOENT;
+      goto reply;
+    }
+    pg_t mpgid = osdmap.raw_pg_to_pg(pgid);
+    osdmap.pg_to_up_acting_osds(pgid, up, acting);
+    if (f) {
+      f->open_object_section("pg_map");
+      f->dump_unsigned("epoch", osdmap.get_epoch());
+      f->dump_stream("raw_pgid") << pgid;
+      f->dump_stream("pgid") << mpgid;
+
+      f->open_array_section("up");
+      for (vector<int>::iterator it = up.begin(); it != up.end(); ++it)
+       f->dump_int("up_osd", *it);
+      f->close_section();
+
+      f->open_array_section("acting");
+      for (vector<int>::iterator it = acting.begin(); it != acting.end(); ++it)
+       f->dump_int("acting_osd", *it);
+      f->close_section();
+
+      f->close_section();
+      f->flush(rdata);
+    } else {
+      ds << "osdmap e" << osdmap.get_epoch()
+         << " pg " << pgid << " (" << mpgid << ")"
+         << " -> up " << up << " acting " << acting;
+      rdata.append(ds);
+    }
+    goto reply;
+
   } else if ((prefix == "osd scrub" ||
              prefix == "osd deep-scrub" ||
              prefix == "osd repair")) {
index 320309edd6c4578756375a79d8b916674729d1f5..582bd8b968544b1ae0073350f0256ff4382ace99 100644 (file)
@@ -2315,48 +2315,6 @@ int process_pg_map_command(
     return 0;
   }
 
-  if (prefix == "pg map") {
-    pg_t pgid;
-    string pgidstr;
-    cmd_getval(g_ceph_context, cmdmap, "pgid", pgidstr);
-    if (!pgid.parse(pgidstr.c_str())) {
-      *ss << "invalid pgid '" << pgidstr << "'";
-      return -EINVAL;
-    }
-    vector<int> up, acting;
-    if (!osdmap.have_pg_pool(pgid.pool())) {
-      *ss << "pg '" << pgidstr << "' does not exist";
-      return -ENOENT;
-    }
-    pg_t mpgid = osdmap.raw_pg_to_pg(pgid);
-    osdmap.pg_to_up_acting_osds(pgid, up, acting);
-    if (f) {
-      f->open_object_section("pg_map");
-      f->dump_unsigned("epoch", osdmap.get_epoch());
-      f->dump_stream("raw_pgid") << pgid;
-      f->dump_stream("pgid") << mpgid;
-
-      f->open_array_section("up");
-      for (vector<int>::iterator it = up.begin(); it != up.end(); ++it)
-       f->dump_int("up_osd", *it);
-      f->close_section();
-
-      f->open_array_section("acting");
-      for (vector<int>::iterator it = acting.begin(); it != acting.end(); ++it)
-       f->dump_int("acting_osd", *it);
-      f->close_section();
-
-      f->close_section();
-      f->flush(*odata);
-    } else {
-      ds << "osdmap e" << osdmap.get_epoch()
-         << " pg " << pgid << " (" << mpgid << ")"
-         << " -> up " << up << " acting " << acting;
-      odata->append(ds);
-    }
-    return 0;
-  }
-
   if (prefix == "pg debug") {
     string debugop;
     cmd_getval(g_ceph_context, cmdmap, "debugop", debugop,