]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMonitor: add 'osd primary-temp ...' command
authorIlya Dryomov <ilya.dryomov@inktank.com>
Fri, 28 Mar 2014 16:28:44 +0000 (18:28 +0200)
committerSage Weil <sage@inktank.com>
Mon, 31 Mar 2014 21:12:00 +0000 (14:12 -0700)
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 <ilya.dryomov@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/mon/MonCommands.h
src/mon/OSDMonitor.cc

index 190be2aebad984cf329995fbbad9d1d366636ed3..02228dd78c17619ffd6a62eba31899c3b2ed5af3 100644 (file)
@@ -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", \
index e4908fb7231ce84b04861ab2df0b2e5ff387f44e..dce55ef11b42d4d453701644e675e3e92f3fbf59 100644 (file)
@@ -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)) {