From 4dcef73369daf70d60b7ec43ca478d40f14e5c29 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 21 Oct 2017 13:03:17 -0500 Subject: [PATCH] mon/OSDMonitor: add 'osd crush set-all-straw-buckets-to-straw2' 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 --- src/mon/MonCommands.h | 3 +++ src/mon/OSDMonitor.cc | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index c5c5fd57d00..28b6c48bb43 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 with and location ", \ "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", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 608a2e4b9ff..242062a841a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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)) { -- 2.47.3