]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: add 'osd crush set-all-straw-buckets-to-straw2'
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 22:19:25 +0000 (17:19 -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>
(cherry picked from commit 928770513cbe3a244095e36dcb41c83c0724cfe9)

src/mon/MonCommands.h
src/mon/OSDMonitor.cc

index 946a95756d88b8c98b39ac16c93aa2ee2cd88521..cd005a1907e66765db369e97ef66d01657df802d 100644 (file)
@@ -548,6 +548,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 80d1871ae0824c7bf3b7ea65a0f1aa6e4333840b..c0f7f52ed767886e5f9e3cc5eda58e723da7c3d0 100644 (file)
@@ -7686,6 +7686,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)) {
+       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") {
     if (osdmap.require_osd_release < CEPH_RELEASE_LUMINOUS) {
       ss << "you must complete the upgrade and 'ceph osd require-osd-release "