Skip to content

Commit

Permalink
OSDMonitor: add 'osd primary-temp ...' command
Browse files Browse the repository at this point in the history
ceph osd primary-temp <pgid> [<osd>]

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 <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
idryomov authored and Sage Weil committed Mar 31, 2014
1 parent 07dcffa commit 63ac079
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mon/MonCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ COMMAND("osd pg-temp " \
"name=id,type=CephString,n=N,req=false", \
"set pg_temp mapping pgid:[<id> [<id>...]] (developers only)", \
"osd", "rw", "cli,rest")
COMMAND("osd primary-temp " \
"name=pgid,type=CephPgid " \
"name=id,type=CephString", \
"set primary_temp mapping pgid:<id>|-1 (developers only)", \
"osd", "rw", "cli,rest")
COMMAND("osd primary-affinity " \
"name=id,type=CephOsdName " \
"type=CephFloat,name=weight,range=0.0|1.0", \
Expand Down
53 changes: 53 additions & 0 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 63ac079

Please sign in to comment.