From: Sage Weil Date: Sat, 25 Feb 2017 03:26:00 +0000 (-0500) Subject: mgr/DaemonServer: implement 'pg [scrub|deep-scrub|repair] ...' X-Git-Tag: v12.0.2~252^2~58 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=909fdcacf709c34a613283d4dfddd3d920b11847;p=ceph.git mgr/DaemonServer: implement 'pg [scrub|deep-scrub|repair] ...' Signed-off-by: Sage Weil --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index 85eed18f55c8..1f28257fbbdf 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -20,6 +20,7 @@ #include "messages/MCommand.h" #include "messages/MCommandReply.h" #include "messages/MPGStats.h" +#include "messages/MOSDScrub.h" #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mgr @@ -329,6 +330,55 @@ bool DaemonServer::handle_command(MCommand *m) f.close_section(); // command_descriptions goto out; } + + // ----------- + // PG commands + + else if (prefix == "pg scrub" || + prefix == "pg repair" || + prefix == "pg deep-scrub") { + string scrubop = prefix.substr(3, string::npos); + 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 out; + } + bool pg_exists = false; + cluster_state.with_osdmap([&](const OSDMap& osdmap) { + pg_exists = osdmap.pg_exists(pgid); + }); + if (!pg_exists) { + ss << "pg " << pgid << " dne"; + r = -ENOENT; + goto out; + } + int acting_primary = -1; + entity_inst_t inst; + cluster_state.with_osdmap([&](const OSDMap& osdmap) { + osdmap.pg_to_acting_osds(pgid, nullptr, &acting_primary); + if (acting_primary >= 0) { + inst = osdmap.get_inst(acting_primary); + } + }); + if (acting_primary == -1) { + ss << "pg " << pgid << " has no primary osd"; + r = -EAGAIN; + goto out; + } + vector pgs = { pgid }; + msgr->send_message(new MOSDScrub(monc->get_fsid(), + pgs, + scrubop == "repair", + scrubop == "deep-scrub"), + inst); + ss << "instructing pg " << pgid << " on osd." << acting_primary + << " (" << inst << ") to " << scrubop; + r = 0; + } + else { cluster_state.with_pgmap( [&](const PGMap& pg_map) {