From: Ilya Dryomov Date: Fri, 28 Mar 2014 16:28:44 +0000 (+0200) Subject: OSDMonitor: add 'osd primary-temp ...' command X-Git-Tag: v0.79~39 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=63ac079302dea88080290ccaa21e0b5aa2e55653;p=ceph.git OSDMonitor: add 'osd primary-temp ...' command ceph osd primary-temp [] Examples: ceph osd primary-temp 0.2 4 # set primary_temp mapping for 0.2 to osd4 ceph osd primary-temp 0.2 # remove primary_temp mapping for 0.2 Signed-off-by: Ilya Dryomov Reviewed-by: Sage Weil --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 190be2aebad9..02228dd78c17 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -500,6 +500,11 @@ COMMAND("osd pg-temp " \ "name=id,type=CephString,n=N,req=false", \ "set pg_temp mapping pgid:[ [...]] (developers only)", \ "osd", "rw", "cli,rest") +COMMAND("osd primary-temp " \ + "name=pgid,type=CephPgid " \ + "name=id,type=CephString", \ + "set primary_temp mapping pgid:|-1 (developers only)", \ + "osd", "rw", "cli,rest") COMMAND("osd primary-affinity " \ "name=id,type=CephOsdName " \ "type=CephFloat,name=weight,range=0.0|1.0", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e4908fb7231c..dce55ef11b42 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4345,6 +4345,59 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m, pending_inc.new_pg_temp[pgid] = new_pg_temp; ss << "set " << pgid << " pg_temp mapping to " << new_pg_temp; goto update; + } else if (prefix == "osd primary-temp") { + string pgidstr; + if (!cmd_getval(g_ceph_context, cmdmap, "pgid", pgidstr)) { + ss << "unable to parse 'pgid' value '" + << cmd_vartype_stringify(cmdmap["pgid"]) << "'"; + err = -EINVAL; + goto reply; + } + pg_t pgid; + if (!pgid.parse(pgidstr.c_str())) { + ss << "invalid pgid '" << pgidstr << "'"; + err = -EINVAL; + goto reply; + } + PGMap& pg_map = mon->pgmon()->pg_map; + if (!pg_map.pg_stat.count(pgid)) { + ss << "pg " << pgid << " does not exist"; + err = -ENOENT; + goto reply; + } + + string id; + int32_t osd; + if (!cmd_getval(g_ceph_context, cmdmap, "id", id)) { + ss << "unable to parse 'id' value '" + << cmd_vartype_stringify(cmdmap["id"]) << "'"; + err = -EINVAL; + goto reply; + } + if (strcmp(id.c_str(), "-1")) { + osd = parse_osd_id(id.c_str(), &ss); + if (osd < 0) { + err = -EINVAL; + goto reply; + } + if (!osdmap.exists(osd)) { + ss << "osd." << osd << " does not exist"; + err = -ENOENT; + goto reply; + } + } else { + osd = -1; + } + + if (!g_conf->mon_osd_allow_primary_temp) { + ss << "you must enable 'mon osd allow primary temp = true' on the mons before you can set primary_temp mappings. note that this is for developers only: older clients/OSDs will break and there is no feature bit infrastructure in place."; + err = -EPERM; + goto reply; + } + + pending_inc.new_primary_temp[pgid] = osd; + ss << "set " << pgid << " primary_temp mapping to " << osd; + goto update; } else if (prefix == "osd primary-affinity") { int64_t id; if (!cmd_getval(g_ceph_context, cmdmap, "id", id)) {