]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: add 'osd crush set-all-straw-buckets-to-straw2' 18460/head
authorSage Weil <sage@redhat.com>
Sat, 21 Oct 2017 18:03:17 +0000 (13:03 -0500)
committerSage Weil <sage@redhat.com>
Mon, 23 Oct 2017 12:34:20 +0000 (07:34 -0500)
This is a common and recommended step that users should take once they
have clients that support straw2 (hammer!).  Let's make it easy.

This may result in a small amount of data movement, but usually it is
very little.

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

index c5c5fd57d008acdfee51daf5ead341760c841d63..28b6c48bb4377de859269df6dd2bfbfed41e6903 100644 (file)
@@ -534,6 +534,9 @@ COMMAND("osd crush add " \
        "name=args,type=CephString,n=N,goodchars=[A-Za-z0-9-_.=]", \
        "add or update crushmap position and weight for <name> with <weight> and location <args>", \
        "osd", "rw", "cli,rest")
+COMMAND("osd crush set-all-straw-buckets-to-straw2",
+        "convert all CRUSH current straw buckets to use the straw2 algorithm",
+       "osd", "rw", "cli,rest")
 COMMAND("osd crush set-device-class " \
         "name=class,type=CephString " \
        "name=ids,type=CephString,n=N", \
index 608a2e4b9ff11fe659522831b3218b073e56dd19..242062a841aef91bdb3332e36975abee4d306d24 100644 (file)
@@ -7111,6 +7111,26 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
     ss << osdmap.get_crush_version() + 1;
     goto update;
 
+  } else if (prefix == "osd crush set-all-straw-buckets-to-straw2") {
+    CrushWrapper newcrush;
+    _get_pending_crush(newcrush);
+    for (int b = 0; b < newcrush.get_max_buckets(); ++b) {
+      int bid = -1 - b;
+      if (newcrush.bucket_exists(bid) &&
+         newcrush.get_bucket_alg(bid) == CRUSH_BUCKET_STRAW) {
+       dout(20) << " bucket " << bid << " is straw, can convert" << dendl;
+       newcrush.bucket_set_alg(bid, CRUSH_BUCKET_STRAW2);
+      }
+    }
+    if (!validate_crush_against_features(&newcrush, ss)) {
+      err = -EINVAL;
+      goto reply;
+    }
+    pending_inc.crush.clear();
+    newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
+    wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
+                                             get_last_committed() + 1));
+    return true;
   } else if (prefix == "osd crush set-device-class") {
     string device_class;
     if (!cmd_getval(cct, cmdmap, "class", device_class)) {