From 3974c371ea49cedf96f09dca637e35b7ebc6ad5a Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Mon, 13 Mar 2023 12:13:58 -0400 Subject: [PATCH] mon/OSDMonitor: do not propose on error in prepare_update Fixes: https://tracker.ceph.com/issues/58972 Signed-off-by: Patrick Donnelly --- src/mon/OSDMonitor.cc | 605 +++++++++++++++++++++--------------------- 1 file changed, 300 insertions(+), 305 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 4ad44d0309d..4e3f862b77e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2726,7 +2726,7 @@ bool OSDMonitor::preprocess_query(MonOpRequestRef op) default: ceph_abort(); - return true; + return false; } } @@ -2765,7 +2765,7 @@ bool OSDMonitor::prepare_update(MonOpRequestRef op) } catch (const bad_cmd_get& e) { bufferlist bl; mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); - return true; + return false; /* nothing to propose */ } case CEPH_MSG_POOLOP: @@ -4014,7 +4014,7 @@ bool OSDMonitor::prepare_pg_ready_to_merge(MonOpRequestRef op) << " race with concurrent pg_num[_pending] update, will retry" << dendl; wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + return false; /* nothing to propose, yet */ } if (m->ready) { @@ -4395,7 +4395,7 @@ bool OSDMonitor::prepare_beacon(MonOpRequestRef op) send_latest(op, beacon->version+1); } dout(1) << " ignoring beacon from non-active osd." << from << dendl; - return false; + return false; /* nothing to propose */ } last_osd_report[from].first = ceph_clock_now(); @@ -4418,7 +4418,7 @@ bool OSDMonitor::prepare_beacon(MonOpRequestRef op) beacon->last_purged_snaps_scrub; return true; } else { - return false; + return false; /* nothing to propose */ } } @@ -9733,14 +9733,14 @@ bool OSDMonitor::prepare_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); mon.reply_command(op, -EINVAL, rs, get_last_committed()); - return true; + return false; /* nothing to propose */ } MonSession *session = op->get_session(); if (!session) { derr << __func__ << " no session" << dendl; mon.reply_command(op, -EACCES, "access denied", get_last_committed()); - return true; + return false; /* nothing to propose */ } return prepare_command_impl(op, cmdmap); @@ -9948,7 +9948,6 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, { op->mark_osdmon_event(__func__); auto m = op->get_req(); - bool ret = false; stringstream ss; string rs; bufferlist rdata; @@ -10008,8 +10007,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, (prefix == "osd crush set" && !osdid_present)) { if (pending_inc.crush.length()) { dout(10) << __func__ << " waiting for pending crush update " << dendl; - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } dout(10) << "prepare_command setting new crush map" << dendl; bufferlist data(m->get_data()); @@ -10021,7 +10019,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, catch (const std::exception &e) { err = -EINVAL; ss << "Failed to parse crushmap: " << e.what(); - goto reply; + goto reply_no_propose; } int64_t prior_version = 0; @@ -10039,25 +10037,25 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << dendl; err = 0; ss << osdmap.get_crush_version(); - goto reply; + goto reply_no_propose; } } if (prior_version != osdmap.get_crush_version()) { err = -EPERM; ss << "prior_version " << prior_version << " != crush version " << osdmap.get_crush_version(); - goto reply; + goto reply_no_propose; } } if (!validate_crush_against_features(&crush, ss)) { err = -EINVAL; - goto reply; + goto reply_no_propose; } err = osdmap.validate_crush_rules(&crush, &ss); if (err < 0) { - goto reply; + goto reply_no_propose; } if (g_conf()->mon_osd_crush_smoke_test) { @@ -10077,7 +10075,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << ": " << ess.str() << dendl; ss << "crush smoke test failed with " << r << ": " << ess.str(); err = r; - goto reply; + goto reply_no_propose; } dout(10) << __func__ << " crush somke test duration: " << duration << ", result: " << ess.str() << dendl; @@ -10099,7 +10097,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } if (!validate_crush_against_features(&newcrush, ss)) { err = -EINVAL; - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); @@ -10110,7 +10108,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, string device_class; if (!cmd_getval(cmdmap, "class", device_class)) { err = -EINVAL; // no value! - goto reply; + goto reply_no_propose; } bool stop = false; @@ -10163,7 +10161,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << dendl; err = newcrush.update_device_class(osd, device_class, name, &ss); if (err < 0) { - goto reply; + goto reply_no_propose; } if (err == 0 && !_have_pending_crush()) { if (!stop) { @@ -10207,7 +10205,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // ss has reason for failure ss << ", unable to parse osd id:\"" << idvec[j] << "\". "; err = -EINVAL; - goto reply; + goto reply_no_propose; } osds.insert(osd); } @@ -10230,7 +10228,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = newcrush.remove_device_class(cct, osd, &ss); if (err < 0) { // ss has reason for failure - goto reply; + goto reply_no_propose; } updated.insert(osd); } @@ -10248,18 +10246,18 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, string device_class; if (!cmd_getval(cmdmap, "class", device_class)) { err = -EINVAL; // no value! - goto reply; + goto reply_no_propose; } if (osdmap.require_osd_release < ceph_release_t::luminous) { ss << "you must complete the upgrade and 'ceph osd require-osd-release " << "luminous' before using crush device classes"; err = -EPERM; - goto reply; + goto reply_no_propose; } if (!_have_pending_crush() && _get_stable_crush().class_exists(device_class)) { ss << "class '" << device_class << "' already exists"; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); if (newcrush.class_exists(device_class)) { @@ -10276,18 +10274,18 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, string device_class; if (!cmd_getval(cmdmap, "class", device_class)) { err = -EINVAL; // no value! - goto reply; + goto reply_no_propose; } if (osdmap.require_osd_release < ceph_release_t::luminous) { ss << "you must complete the upgrade and 'ceph osd require-osd-release " << "luminous' before using crush device classes"; err = -EPERM; - goto reply; + goto reply_no_propose; } if (!osdmap.crush->class_exists(device_class)) { err = 0; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); @@ -10300,7 +10298,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (newcrush.class_is_in_use(class_id, &ts)) { err = -EBUSY; ss << "class '" << device_class << "' " << ts.str(); - goto reply; + goto reply_no_propose; } // check if class is used by any erasure-code-profiles @@ -10325,7 +10323,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = -EBUSY; ss << "class '" << device_class << "' is still referenced by erasure-code-profile(s): " << referenced_by; - goto reply; + goto reply_no_propose; } set osds; @@ -10334,7 +10332,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = newcrush.remove_device_class(cct, p, &ss); if (err < 0) { // ss has reason for failure - goto reply; + goto reply_no_propose; } } @@ -10344,7 +10342,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err < 0) { ss << "class '" << device_class << "' cannot be removed '" << cpp_strerror(err) << "'"; - goto reply; + goto reply_no_propose; } } @@ -10357,11 +10355,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, string srcname, dstname; if (!cmd_getval(cmdmap, "srcname", srcname)) { err = -EINVAL; - goto reply; + goto reply_no_propose; } if (!cmd_getval(cmdmap, "dstname", dstname)) { err = -EINVAL; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); @@ -10370,14 +10368,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // so command is idempotent ss << "already renamed to '" << dstname << "'"; err = 0; - goto reply; + goto reply_no_propose; } err = newcrush.rename_class(srcname, dstname); if (err < 0) { ss << "fail to rename '" << srcname << "' to '" << dstname << "' : " << cpp_strerror(err); - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); @@ -10401,7 +10399,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!_have_pending_crush() && _get_stable_crush().name_exists(name)) { ss << "bucket '" << name << "' already exists"; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); @@ -10414,12 +10412,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (type < 0) { ss << "type '" << typestr << "' does not exist"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (type == 0) { ss << "type '" << typestr << "' is for devices, not buckets"; err = -EINVAL; - goto reply; + goto reply_no_propose; } int bucketno; err = newcrush.add_bucket(0, 0, @@ -10427,12 +10425,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, NULL, &bucketno); if (err < 0) { ss << "add_bucket error: '" << cpp_strerror(err) << "'"; - goto reply; + goto reply_no_propose; } err = newcrush.set_item_name(bucketno, name); if (err < 0) { ss << "error setting bucket name to '" << name << "'"; - goto reply; + goto reply_no_propose; } if (!loc.empty()) { @@ -10441,7 +10439,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = newcrush.move_bucket(cct, bucketno, loc); if (err < 0) { ss << "error moving bucket '" << name << "' to location " << loc; - goto reply; + goto reply_no_propose; } } else { ss << "no need to move item id " << bucketno << " name '" << name @@ -10465,12 +10463,15 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, cmd_getval(cmdmap, "dstname", dstname); err = crush_rename_bucket(srcname, dstname, &ss); - if (err == -EALREADY) // equivalent to success for idempotency - err = 0; - if (err) - goto reply; - else + if (err) { + // equivalent to success for idempotency + if (err == -EALREADY) { + err = 0; + } + goto reply_no_propose; + } else { goto update; + } } else if (prefix == "osd crush weight-set create" || prefix == "osd crush weight-set create-compat") { if (_have_pending_crush()) { @@ -10483,7 +10484,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (newcrush.has_non_straw2_buckets()) { ss << "crush map contains one or more bucket(s) that are not straw2"; err = -EPERM; - goto reply; + goto reply_no_propose; } if (prefix == "osd crush weight-set create") { if (osdmap.require_min_compat_client != ceph_release_t::unknown && @@ -10494,7 +10495,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << "Try 'ceph osd set-require-min-compat-client luminous' " << "before using the new interface"; err = -EPERM; - goto reply; + goto reply_no_propose; } string poolname, mode; cmd_getval(cmdmap, "pool", poolname); @@ -10502,13 +10503,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool < 0) { ss << "pool '" << poolname << "' not found"; err = -ENOENT; - goto reply; + goto reply_no_propose; } cmd_getval(cmdmap, "mode", mode); if (mode != "flat" && mode != "positional") { ss << "unrecognized weight-set mode '" << mode << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } positions = mode == "flat" ? 1 : osdmap.get_pg_pool(pool)->get_size(); } else { @@ -10522,7 +10523,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "weight-set for pool '" << osdmap.get_pool_name(pool) << "' already created"; } - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); @@ -10539,7 +10540,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool < 0) { ss << "pool '" << poolname << "' not found"; err = -ENOENT; - goto reply; + goto reply_no_propose; } } else { pool = CrushWrapper::DEFAULT_CHOOSE_ARGS; @@ -10563,32 +10564,32 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool < 0) { ss << "pool '" << poolname << "' not found"; err = -ENOENT; - goto reply; + goto reply_no_propose; } if (!newcrush.have_choose_args(pool)) { ss << "no weight-set for pool '" << poolname << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } auto arg_map = newcrush.choose_args_get(pool); int positions = newcrush.get_choose_args_positions(arg_map); if (weight.size() != (size_t)positions) { ss << "must specify exact " << positions << " weight values"; err = -EINVAL; - goto reply; + goto reply_no_propose; } } else { pool = CrushWrapper::DEFAULT_CHOOSE_ARGS; if (!newcrush.have_choose_args(pool)) { ss << "no backward-compatible weight-set"; err = -ENOENT; - goto reply; + goto reply_no_propose; } } if (!newcrush.name_exists(item)) { ss << "item '" << item << "' does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } err = newcrush.choose_args_adjust_item_weightf( cct, @@ -10597,7 +10598,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, weight, &ss); if (err < 0) { - goto reply; + goto reply_no_propose; } err = 0; pending_inc.crush.clear(); @@ -10613,7 +10614,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = -ENOENT; ss << osd_name << " does not exist. Create it before updating the crush map"; - goto reply; + goto reply_no_propose; } double weight; @@ -10621,7 +10622,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse weight value '" << cmd_vartype_stringify(cmdmap.at("weight")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } string args; @@ -10636,7 +10637,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to set item id " << osdid << " name '" << osd_name << "' weight " << weight << " at location " << loc << ": does not exist"; - goto reply; + goto reply_no_propose; } dout(5) << "adding/updating crush item id " << osdid << " name '" @@ -10657,12 +10658,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } if (err < 0) - goto reply; + goto reply_no_propose; if (err == 0 && !_have_pending_crush()) { ss << action << " item id " << osdid << " name '" << osd_name << "' weight " << weight << " at location " << loc << ": no change"; - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); @@ -10681,7 +10682,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = -ENOENT; ss << osd_name << " does not exist. create it before updating the crush map"; - goto reply; + goto reply_no_propose; } double weight; @@ -10689,7 +10690,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse weight value '" << cmd_vartype_stringify(cmdmap.at("weight")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } string args; @@ -10779,12 +10780,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!newcrush.name_exists(source)) { ss << "source item " << source << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } if (!newcrush.name_exists(dest)) { ss << "dest item " << dest << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } int sid = newcrush.get_item_id(source); int did = newcrush.get_item_id(dest); @@ -10792,7 +10793,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (newcrush.get_immediate_parent_id(sid, &sparent) == 0 && !force) { ss << "source item " << source << " is not an orphan bucket; pass --yes-i-really-mean-it to proceed anyway"; err = -EPERM; - goto reply; + goto reply_no_propose; } if (newcrush.get_bucket_alg(sid) != newcrush.get_bucket_alg(did) && !force) { @@ -10800,13 +10801,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << "dest bucket alg " << crush_alg_name(newcrush.get_bucket_alg(did)) << "; pass --yes-i-really-mean-it to proceed anyway"; err = -EPERM; - goto reply; + goto reply_no_propose; } int r = newcrush.swap_bucket(cct, sid, did); if (r < 0) { ss << "failed to swap bucket contents: " << cpp_strerror(r); err = r; - goto reply; + goto reply_no_propose; } ss << "swapped bucket of " << source << " to " << dest; pending_inc.crush.clear(); @@ -10830,7 +10831,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!osdmap.crush->name_exists(name)) { err = -ENOENT; ss << "item " << name << " does not exist"; - goto reply; + goto reply_no_propose; } else { dout(5) << "resolved crush name '" << name << "' to id " << id << dendl; } @@ -10838,7 +10839,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "no need to move item id " << id << " name '" << name << "' to location " << loc << " in crush map"; err = 0; - goto reply; + goto reply_no_propose; } dout(5) << "linking crush item name '" << name << "' at location " << loc << dendl; @@ -10847,7 +10848,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!newcrush.name_exists(name)) { err = -ENOENT; ss << "item " << name << " does not exist"; - goto reply; + goto reply_no_propose; } else { int id = newcrush.get_item_id(name); if (!newcrush.check_item_loc(cct, id, loc, (int *)NULL)) { @@ -10860,7 +10861,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "cannot link item id " << id << " name '" << name << "' to location " << loc; - goto reply; + goto reply_no_propose; } } else { ss << "no need to move item id " << id << " name '" << name @@ -10950,27 +10951,27 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!newcrush.name_exists(name)) { err = -ENOENT; ss << "device '" << name << "' does not appear in the crush map"; - goto reply; + goto reply_no_propose; } int id = newcrush.get_item_id(name); if (id < 0) { ss << "device '" << name << "' is not a leaf in the crush map"; err = -EINVAL; - goto reply; + goto reply_no_propose; } double w; if (!cmd_getval(cmdmap, "weight", w)) { ss << "unable to parse weight value '" << cmd_vartype_stringify(cmdmap.at("weight")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } err = newcrush.adjust_item_weightf(cct, id, w, g_conf()->osd_crush_update_weight_set); if (err < 0) - goto reply; + goto reply_no_propose; pending_inc.crush.clear(); newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "reweighted item id " << id << " name '" << name << "' to " << w @@ -10988,27 +10989,27 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!newcrush.name_exists(name)) { err = -ENOENT; ss << "device '" << name << "' does not appear in the crush map"; - goto reply; + goto reply_no_propose; } int id = newcrush.get_item_id(name); if (id >= 0) { ss << "device '" << name << "' is not a subtree in the crush map"; err = -EINVAL; - goto reply; + goto reply_no_propose; } double w; if (!cmd_getval(cmdmap, "weight", w)) { ss << "unable to parse weight value '" << cmd_vartype_stringify(cmdmap.at("weight")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } err = newcrush.adjust_subtree_weightf(cct, id, w, g_conf()->osd_crush_update_weight_set); if (err < 0) - goto reply; + goto reply_no_propose; pending_inc.crush.clear(); newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "reweighted subtree id " << id << " name '" << name << "' to " << w @@ -11040,12 +11041,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "unrecognized profile '" << profile << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (!validate_crush_against_features(&newcrush, ss)) { err = -EINVAL; - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); @@ -11067,25 +11068,25 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = -EINVAL; ss << "failed to parse integer value " << cmd_vartype_stringify(cmdmap.at("value")); - goto reply; + goto reply_no_propose; } if (tunable == "straw_calc_version") { if (value != 0 && value != 1) { ss << "value must be 0 or 1; got " << value; err = -EINVAL; - goto reply; + goto reply_no_propose; } newcrush.set_straw_calc_version(value); } else { ss << "unrecognized tunable '" << tunable << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (!validate_crush_against_features(&newcrush, ss)) { err = -EINVAL; - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); @@ -11110,7 +11111,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // From the user point of view, the rule is more meaningfull. ss << "rule " << name << " already exists"; err = 0; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); @@ -11125,7 +11126,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, pg_pool_t::TYPE_REPLICATED, &ss); if (ruleno < 0) { err = ruleno; - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); @@ -11148,7 +11149,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // From the user point of view, the rule is more meaningfull. ss << "rule " << name << " already exists"; err = 0; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); @@ -11164,7 +11165,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, "firstn", pg_pool_t::TYPE_REPLICATED, &ss); if (ruleno < 0) { err = ruleno; - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); @@ -11184,7 +11185,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (erasure_code_profile_in_use(osdmap.pools, name, &ss)) { err = -EBUSY; - goto reply; + goto reply_no_propose; } if (osdmap.has_erasure_code_profile(name) || @@ -11203,7 +11204,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "erasure-code-profile " << name << " does not exist"; err = 0; - goto reply; + goto reply_no_propose; } } else if (prefix == "osd erasure-code-profile set") { @@ -11218,7 +11219,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, map profile_map; err = parse_erasure_code_profile(profile, &profile_map, &ss); if (err) - goto reply; + goto reply_no_propose; if (auto found = profile_map.find("crush-failure-domain"); found != profile_map.end()) { const auto& failure_domain = found->second; @@ -11227,7 +11228,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "erasure-code-profile " << profile_map << " contains an invalid failure-domain " << std::quoted(failure_domain); err = -EINVAL; - goto reply; + goto reply_no_propose; } } @@ -11235,7 +11236,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "erasure-code-profile " << profile_map << " must contain a plugin entry" << std::endl; err = -EINVAL; - goto reply; + goto reply_no_propose; } string plugin = profile_map["plugin"]; @@ -11245,18 +11246,18 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { err = normalize_profile(name, profile_map, force, &ss); if (err) - goto reply; + goto reply_no_propose; if (osdmap.has_erasure_code_profile(name)) { ErasureCodeProfile existing_profile_map = osdmap.get_erasure_code_profile(name); err = normalize_profile(name, existing_profile_map, force, &ss); if (err) - goto reply; + goto reply_no_propose; if (existing_profile_map == profile_map) { err = 0; - goto reply; + goto reply_no_propose; } if (!force) { err = -EPERM; @@ -11265,7 +11266,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << existing_profile_map << " is different from the proposed profile " << profile_map; - goto reply; + goto reply_no_propose; } } @@ -11284,7 +11285,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) goto wait; if (err) - goto reply; + goto reply_no_propose; string name, poolstr; cmd_getval(cmdmap, "name", name); string profile; @@ -11303,10 +11304,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, profile_map, &ss); if (err) - goto reply; + goto reply_no_propose; err = normalize_profile(name, profile_map, true, &ss); if (err) - goto reply; + goto reply_no_propose; dout(20) << "erasure code profile set " << profile << "=" << profile_map << dendl; pending_inc.set_erasure_code_profile(profile, profile_map); @@ -11321,15 +11322,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, case -EEXIST: // return immediately ss << "rule " << name << " already exists"; err = 0; - goto reply; - break; + goto reply_no_propose; case -EALREADY: // wait for pending to be proposed ss << "rule " << name << " already exists"; err = 0; break; default: // non recoverable error - goto reply; - break; + goto reply_no_propose; } } else { ss << "created rule " << name << " at " << rule; @@ -11347,7 +11346,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!osdmap.crush->rule_exists(name)) { ss << "rule " << name << " does not exist"; err = 0; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); @@ -11365,12 +11364,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (osdmap.crush_rule_in_use(ruleno)) { ss << "crush rule " << name << " (" << ruleno << ") is in use"; err = -EBUSY; - goto reply; + goto reply_no_propose; } err = newcrush.remove_rule(ruleno); if (err < 0) { - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); @@ -11389,12 +11388,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (srcname.empty() || dstname.empty()) { ss << "must specify both source rule name and destination rule name"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (srcname == dstname) { ss << "destination rule name is equal to source rule name"; err = 0; - goto reply; + goto reply_no_propose; } CrushWrapper newcrush = _get_pending_crush(); @@ -11404,13 +11403,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // (so this command is idempotent) ss << "already renamed to '" << dstname << "'"; err = 0; - goto reply; + goto reply_no_propose; } err = newcrush.rename_rule(srcname, dstname, &ss); if (err < 0) { // ss has reason for failure - goto reply; + goto reply_no_propose; } pending_inc.crush.clear(); newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); @@ -11425,14 +11424,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse 'newmax' value '" << cmd_vartype_stringify(cmdmap.at("newmax")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (newmax > g_conf()->mon_max_osd) { err = -ERANGE; ss << "cannot set max_osd to " << newmax << " which is > conf.mon_max_osd (" << g_conf()->mon_max_osd << ")"; - goto reply; + goto reply_no_propose; } // Don't allow shrinking OSD number as this will cause data loss @@ -11447,7 +11446,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = -EBUSY; ss << "cannot shrink max_osd to " << newmax << " because osd." << i << " (and possibly others) still in use"; - goto reply; + goto reply_no_propose; } } } @@ -11467,7 +11466,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse 'ratio' value '" << cmd_vartype_stringify(cmdmap.at("ratio")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (prefix == "osd set-full-ratio") pending_inc.new_full_ratio = n; @@ -11487,7 +11486,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!vno) { ss << "version " << v << " is not recognized"; err = -EINVAL; - goto reply; + goto reply_no_propose; } OSDMap newmap; newmap.deepish_copy_from(osdmap); @@ -11498,7 +11497,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "osdmap current utilizes features that require " << mvno << "; cannot set require_min_compat_client below that to " << vno; err = -EPERM; - goto reply; + goto reply_no_propose; } bool sure = false; cmd_getval(cmdmap, "yes_i_really_mean_it", sure); @@ -11536,7 +11535,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!ok) { ss << "; add --yes-i-really-mean-it to do it anyway"; err = -EPERM; - goto reply; + goto reply_no_propose; } } ss << "set require_min_compat_client to " << vno; @@ -11586,7 +11585,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "Not advisable to continue since no OSDs are up. Pass " << "--yes-i-really-mean-it if you really wish to continue."; err = -EPERM; - goto reply; + goto reply_no_propose; } // The release check here is required because for OSD_PGLOG_HARDLIMIT, // we are reusing a jewel feature bit that was retired in luminous. @@ -11597,7 +11596,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "not all up OSDs have OSD_PGLOG_HARDLIMIT feature"; err = -EPERM; - goto reply; + goto reply_no_propose; } } else { ss << "unrecognized flag '" << key << "'"; @@ -11645,74 +11644,74 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!rel) { ss << "unrecognized release " << release; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (rel == osdmap.require_osd_release) { // idempotent err = 0; - goto reply; + goto reply_no_propose; } if (osdmap.require_osd_release < ceph_release_t::pacific && !sure) { ss << "Not advisable to continue since current 'require_osd_release' " << "refers to a very old Ceph release. Pass " << "--yes-i-really-mean-it if you really wish to continue."; err = -EPERM; - goto reply; + goto reply_no_propose; } if (!osdmap.get_num_up_osds() && !sure) { ss << "Not advisable to continue since no OSDs are up. Pass " << "--yes-i-really-mean-it if you really wish to continue."; err = -EPERM; - goto reply; + goto reply_no_propose; } if (rel == ceph_release_t::pacific) { if (!mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_PACIFIC)) { ss << "not all mons are pacific"; err = -EPERM; - goto reply; + goto reply_no_propose; } if ((!HAVE_FEATURE(osdmap.get_up_osd_features(), SERVER_PACIFIC)) && !sure) { ss << "not all up OSDs have CEPH_FEATURE_SERVER_PACIFIC feature"; err = -EPERM; - goto reply; + goto reply_no_propose; } } else if (rel == ceph_release_t::quincy) { if (!mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_QUINCY)) { ss << "not all mons are quincy"; err = -EPERM; - goto reply; + goto reply_no_propose; } if ((!HAVE_FEATURE(osdmap.get_up_osd_features(), SERVER_QUINCY)) && !sure) { ss << "not all up OSDs have CEPH_FEATURE_SERVER_QUINCY feature"; err = -EPERM; - goto reply; + goto reply_no_propose; } } else if (rel == ceph_release_t::reef) { if (!mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_REEF)) { ss << "not all mons are reef"; err = -EPERM; - goto reply; + goto reply_no_propose; } if ((!HAVE_FEATURE(osdmap.get_up_osd_features(), SERVER_REEF)) && !sure) { ss << "not all up OSDs have CEPH_FEATURE_SERVER_REEF feature"; err = -EPERM; - goto reply; + goto reply_no_propose; } } else { ss << "not supported for this release"; err = -EPERM; - goto reply; + goto reply_no_propose; } if (rel < osdmap.require_osd_release) { ss << "require_osd_release cannot be lowered once it has been set"; err = -EPERM; - goto reply; + goto reply_no_propose; } pending_inc.new_require_osd_release = rel; goto update; @@ -11893,7 +11892,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unrecognized flag '" << f << "', must be one of " << "{noup,nodown,noin,noout}"; err = -EINVAL; - goto reply; + goto reply_no_propose; } } } else { @@ -11912,12 +11911,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (flags == 0) { ss << "must specify flag(s) {noup,nodwon,noin,noout} to set/unset"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (who.empty()) { ss << "must specify at least one or more targets to set/unset"; err = -EINVAL; - goto reply; + goto reply_no_propose; } set osds; set crush_nodes; @@ -11942,7 +11941,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (osds.empty() && crush_nodes.empty() && device_classes.empty()) { // ss has reason for failure err = -EINVAL; - goto reply; + goto reply_no_propose; } bool any = false; for (auto osd : osds) { @@ -12026,11 +12025,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, pg_t pgid; err = parse_pgid(cmdmap, ss, pgid); if (err < 0) - goto reply; + goto reply_no_propose; if (pending_inc.new_pg_temp.count(pgid)) { dout(10) << __func__ << " waiting for pending update on " << pgid << dendl; - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } vector id_vec; @@ -12045,7 +12043,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!osdmap.exists(osd)) { ss << "osd." << osd << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } new_pg_temp.push_back(osd); } @@ -12055,7 +12053,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "num of osds (" << new_pg_temp.size() <<") < pool min size (" << pool_min_size << ")"; err = -EINVAL; - goto reply; + goto reply_no_propose; } int pool_size = osdmap.get_pg_pool_size(pgid); @@ -12063,7 +12061,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "num of osds (" << new_pg_temp.size() <<") > pool size (" << pool_size << ")"; err = -EINVAL; - goto reply; + goto reply_no_propose; } pending_inc.new_pg_temp[pgid] = mempool::osdmap::vector( @@ -12075,7 +12073,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, pg_t pgid; err = parse_pgid(cmdmap, ss, pgid); if (err < 0) - goto reply; + goto reply_no_propose; int64_t osd; if (prefix == "osd primary-temp") { @@ -12083,12 +12081,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse 'id' value '" << cmd_vartype_stringify(cmdmap.at("id")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (!osdmap.exists(osd)) { ss << "osd." << osd << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } } else if (prefix == "osd rm-primary-temp") { @@ -12104,7 +12102,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << osdmap.require_min_compat_client << " < firefly, which is required for primary-temp"; err = -EPERM; - goto reply; + goto reply_no_propose; } pending_inc.new_primary_temp[pgid] = osd; @@ -12114,14 +12112,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, pg_t pgid; err = parse_pgid(cmdmap, ss, pgid); if (err < 0) - goto reply; + goto reply_no_propose; vector acting; int primary; osdmap.pg_to_acting_osds(pgid, &acting, &primary); if (primary < 0) { err = -EAGAIN; ss << "pg currently has no primary"; - goto reply; + goto reply_no_propose; } if (acting.size() > 1) { // map to just primary; it will map back to what it wants @@ -12142,7 +12140,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!done) { err = -EAGAIN; ss << "not enough up OSDs in the cluster to force repeer"; - goto reply; + goto reply_no_propose; } } goto update; @@ -12207,7 +12205,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << "Try 'ceph osd set-require-min-compat-client " << min_release_name << "' " << "before using the new interface"; err = -EPERM; - goto reply; + goto reply_no_propose; } //TODO: Should I add feature and test for upmap-primary? @@ -12215,11 +12213,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) goto wait; if (err < 0) - goto reply; + goto reply_no_propose; pg_t pgid; err = parse_pgid(cmdmap, ss, pgid); if (err < 0) - goto reply; + goto reply_no_propose; if (pending_inc.old_pools.count(pgid.pool())) { ss << "pool of " << pgid << " is pending removal"; err = -ENOENT; @@ -12237,8 +12235,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, pending_inc.old_pg_upmap.count(pgid)) { dout(10) << __func__ << " waiting for pending update on " << pgid << dendl; - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } break; @@ -12249,7 +12246,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (! pt->is_replicated()) { ss << "pg-upmap-primary is only supported for replicated pools"; err = -EINVAL; - goto reply; + goto reply_no_propose; } } // fall through @@ -12259,8 +12256,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, pending_inc.old_pg_upmap_items.count(pgid)) { dout(10) << __func__ << " waiting for pending update on " << pgid << dendl; - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } break; @@ -12276,7 +12272,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse 'id' value(s) '" << cmd_vartype_stringify(cmdmap.at("id")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } int pool_min_size = osdmap.get_pg_pool_min_size(pgid); @@ -12284,7 +12280,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "num of osds (" << id_vec.size() <<") < pool min size (" << pool_min_size << ")"; err = -EINVAL; - goto reply; + goto reply_no_propose; } int pool_size = osdmap.get_pg_pool_size(pgid); @@ -12292,7 +12288,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "num of osds (" << id_vec.size() <<") > pool size (" << pool_size << ")"; err = -EINVAL; - goto reply; + goto reply_no_propose; } vector new_pg_upmap; @@ -12300,7 +12296,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (osd != CRUSH_ITEM_NONE && !osdmap.exists(osd)) { ss << "osd." << osd << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } auto it = std::find(new_pg_upmap.begin(), new_pg_upmap.end(), osd); if (it != new_pg_upmap.end()) { @@ -12313,7 +12309,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (new_pg_upmap.empty()) { ss << "no valid upmap items(pairs) is specified"; err = -EINVAL; - goto reply; + goto reply_no_propose; } pending_inc.new_pg_upmap[pgid] = mempool::osdmap::vector( @@ -12336,13 +12332,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse 'id' value(s) '" << cmd_vartype_stringify(cmdmap.at("id")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (id_vec.size() % 2) { ss << "you must specify pairs of osd ids to be remapped"; err = -EINVAL; - goto reply; + goto reply_no_propose; } int pool_size = osdmap.get_pg_pool_size(pgid); @@ -12350,7 +12346,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "num of osd pairs (" << id_vec.size() / 2 <<") > pool size (" << pool_size << ")"; err = -EINVAL; - goto reply; + goto reply_no_propose; } vector> new_pg_upmap_items; @@ -12366,12 +12362,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!osdmap.exists(from)) { ss << "osd." << from << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } if (to != CRUSH_ITEM_NONE && !osdmap.exists(to)) { ss << "osd." << to << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } pair entry = make_pair(from, to); auto it = std::find(new_pg_upmap_items.begin(), @@ -12390,7 +12386,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (new_pg_upmap_items.empty()) { ss << "no valid upmap items(pairs) is specified"; err = -EINVAL; - goto reply; + goto reply_no_propose; } pending_inc.new_pg_upmap_items[pgid] = @@ -12414,12 +12410,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "invalid osd id value '" << cmd_vartype_stringify(cmdmap.at("id")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (id != CRUSH_ITEM_NONE && !osdmap.exists(id)) { ss << "osd." << id << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } vector acting; int primary; @@ -12427,7 +12423,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (id == primary) { ss << "osd." << id << " is already primary for pg " << pgid; err = -EINVAL; - goto reply; + goto reply_no_propose; } int found_idx = 0; for (int i = 1 ; i < (int)acting.size(); i++) { // skip 0 on purpose @@ -12439,7 +12435,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (found_idx == 0) { ss << "osd." << id << " is not in acting set for pg " << pgid; err = -EINVAL; - goto reply; + goto reply_no_propose; } vector new_acting(acting); new_acting[found_idx] = new_acting[0]; @@ -12453,7 +12449,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "can't change primary for pg " << pgid << " to osd." << id << " - illegal pg after the change"; err = -EINVAL; - goto reply; + goto reply_no_propose; } pending_inc.new_pg_upmap_primary[pgid] = id; //TO-REMOVE: @@ -12479,20 +12475,20 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "invalid osd id value '" << cmd_vartype_stringify(cmdmap.at("id")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } double w; if (!cmd_getval(cmdmap, "weight", w)) { ss << "unable to parse 'weight' value '" << cmd_vartype_stringify(cmdmap.at("weight")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } long ww = (int)((double)CEPH_OSD_MAX_PRIMARY_AFFINITY*w); if (ww < 0L) { ss << "weight must be >= 0"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (osdmap.require_min_compat_client != ceph_release_t::unknown && osdmap.require_min_compat_client < ceph_release_t::firefly) { @@ -12500,7 +12496,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << osdmap.require_min_compat_client << " < firefly, which is required for primary-affinity"; err = -EPERM; - goto reply; + goto reply_no_propose; } if (osdmap.exists(id)) { pending_inc.new_primary_affinity[id] = ww; @@ -12512,7 +12508,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "osd." << id << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } } else if (prefix == "osd reweight") { int64_t id; @@ -12520,20 +12516,20 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse osd id value '" << cmd_vartype_stringify(cmdmap.at("id")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } double w; if (!cmd_getval(cmdmap, "weight", w)) { ss << "unable to parse weight value '" << cmd_vartype_stringify(cmdmap.at("weight")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } long ww = (int)((double)CEPH_OSD_IN*w); if (ww < 0L) { ss << "weight must be >= 0"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (osdmap.exists(id)) { pending_inc.new_weight[id] = ww; @@ -12545,7 +12541,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "osd." << id << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } } else if (prefix == "osd reweightn") { map weights; @@ -12553,7 +12549,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err) { ss << "unable to parse 'weights' value '" << cmd_vartype_stringify(cmdmap.at("weights")) << "'"; - goto reply; + goto reply_no_propose; } pending_inc.new_weight.insert(weights.begin(), weights.end()); wait_for_finished_proposal( @@ -12566,7 +12562,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse osd id value '" << cmd_vartype_stringify(cmdmap.at("id")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } bool sure = false; cmd_getval(cmdmap, "yes_i_really_mean_it", sure); @@ -12574,15 +12570,15 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "are you SURE? this might mean real, permanent data loss. pass " "--yes-i-really-mean-it if you really do."; err = -EPERM; - goto reply; + goto reply_no_propose; } else if (!osdmap.exists(id)) { ss << "osd." << id << " does not exist"; err = -ENOENT; - goto reply; + goto reply_no_propose; } else if (!osdmap.is_down(id)) { ss << "osd." << id << " is not down"; err = -EBUSY; - goto reply; + goto reply_no_propose; } else { epoch_t e = osdmap.get_info(id).down_at; pending_inc.new_lost[id] = e; @@ -12626,7 +12622,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << cmd_vartype_stringify(cmdmap.at("id")) << ""; } err = -EINVAL; - goto reply; + goto reply_no_propose; } bool is_destroy = (prefix == "osd destroy-actual"); @@ -12643,26 +12639,26 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << "as deletion of cephx and lockbox keys. " << "Pass --yes-i-really-mean-it if you really do."; err = -EPERM; - goto reply; + goto reply_no_propose; } else if (!osdmap.exists(id)) { ss << "osd." << id << " does not exist"; err = 0; // idempotent - goto reply; + goto reply_no_propose; } else if (osdmap.is_up(id)) { ss << "osd." << id << " is not `down`."; err = -EBUSY; - goto reply; + goto reply_no_propose; } else if (is_destroy && osdmap.is_destroyed(id)) { ss << "destroyed osd." << id; err = 0; - goto reply; + goto reply_no_propose; } if (prefix == "osd purge-new" && (osdmap.get_state(id) & CEPH_OSD_NEW) == 0) { ss << "osd." << id << " is not new"; err = -EPERM; - goto reply; + goto reply_no_propose; } bool goto_reply = false; @@ -12683,7 +12679,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, paxos.unplug(); if (err < 0 || goto_reply) { - goto reply; + goto reply_no_propose; } if (is_destroy) { @@ -12724,7 +12720,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = get_json_str_map(param_json, ss, ¶m_map); if (err < 0) - goto reply; + goto reply_no_propose; dout(20) << __func__ << " osd new params " << param_map << dendl; @@ -12733,7 +12729,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, paxos.unplug(); if (err < 0) { - goto reply; + goto reply_no_propose; } if (f) { @@ -12745,7 +12741,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == EEXIST) { // idempotent operation err = 0; - goto reply; + goto reply_no_propose; } wait_for_finished_proposal(op, @@ -12762,7 +12758,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (cmd_id < 0) { ss << "invalid osd id value '" << cmd_id << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } dout(10) << " osd create got id " << cmd_id << dendl; } @@ -12773,7 +12769,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!uuid.parse(uuidstr.c_str())) { ss << "invalid uuid value '" << uuidstr << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } // we only care about the id if we also have the uuid, to // ensure the operation's idempotency. @@ -12784,11 +12780,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = prepare_command_osd_create(id, uuid, &new_id, ss); if (err < 0) { if (err == -EAGAIN) { - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } // a check has failed; reply to the user. - goto reply; + goto reply_no_propose; } else if (err == EEXIST) { // this is an idempotent operation; we can go ahead and reply. @@ -12802,7 +12797,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, rdata.append(ss); } err = 0; - goto reply; + goto reply_no_propose; } string empty_device_class; @@ -12850,14 +12845,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "Did you mean to specify \"osd blocklist range\"?"; err = -EINVAL; - goto reply; + goto reply_no_propose; } } entity_addr_t addr; if (!addr.parse(addrstr)) { ss << "unable to parse address " << addrstr; err = -EINVAL; - goto reply; + goto reply_no_propose; } else { if (range) { @@ -12865,18 +12860,18 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "You specified a range command, but " << addr << " does not parse as a CIDR range"; err = -EINVAL; - goto reply; + goto reply_no_propose; } addr.type = entity_addr_t::TYPE_CIDR; err = check_cluster_features(CEPH_FEATUREMASK_RANGE_BLOCKLIST, ss); if (err) { - goto reply; + goto reply_no_propose; } if ((addr.is_ipv4() && addr.get_nonce() > 32) || (addr.is_ipv6() && addr.get_nonce() > 128)) { ss << "Too many bits in range for that protocol!"; err = -EINVAL; - goto reply; + goto reply_no_propose; } } else { if (osdmap.require_osd_release >= ceph_release_t::nautilus) { @@ -12952,7 +12947,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } ss << addr << " isn't blocklisted"; err = 0; - goto reply; + goto reply_no_propose; } } } else if (prefix == "osd pool mksnap") { @@ -12962,7 +12957,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } string snapname; cmd_getval(cmdmap, "snap", snapname); @@ -12970,15 +12965,15 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (p->is_unmanaged_snaps_mode()) { ss << "pool " << poolstr << " is in unmanaged snaps mode"; err = -EINVAL; - goto reply; + goto reply_no_propose; } else if (p->snap_exists(snapname.c_str())) { ss << "pool " << poolstr << " snap " << snapname << " already exists"; err = 0; - goto reply; + goto reply_no_propose; } else if (p->is_tier()) { ss << "pool " << poolstr << " is a cache tier"; err = -EINVAL; - goto reply; + goto reply_no_propose; } pg_pool_t *pp = 0; if (pending_inc.new_pools.count(pool)) @@ -12994,7 +12989,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, dout(20) << "pool-level snapshots have been disabled for pools " "attached to an fs - poolid:" << pool << dendl; err = -EOPNOTSUPP; - goto reply; + goto reply_no_propose; } pp->add_snap(snapname.c_str(), ceph_clock_now()); pp->set_snap_epoch(pending_inc.epoch); @@ -13011,7 +13006,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } string snapname; cmd_getval(cmdmap, "snap", snapname); @@ -13019,11 +13014,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (p->is_unmanaged_snaps_mode()) { ss << "pool " << poolstr << " is in unmanaged snaps mode"; err = -EINVAL; - goto reply; + goto reply_no_propose; } else if (!p->snap_exists(snapname.c_str())) { ss << "pool " << poolstr << " snap " << snapname << " does not exist"; err = 0; - goto reply; + goto reply_no_propose; } pg_pool_t *pp = 0; if (pending_inc.new_pools.count(pool)) @@ -13062,7 +13057,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (poolstr[0] == '.' && !confirm) { ss << "pool names beginning with . are not allowed"; err = 0; - goto reply; + goto reply_no_propose; } int64_t pool_id = osdmap.lookup_pg_pool_name(poolstr); if (pool_id >= 0) { @@ -13074,7 +13069,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "pool '" << poolstr << "' already exists"; err = 0; } - goto reply; + goto reply_no_propose; } int pool_type; @@ -13085,7 +13080,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "unknown pool type '" << pool_type_str << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } bool implicit_rule_creation = false; @@ -13111,7 +13106,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, profile_map, &ss); if (err) - goto reply; + goto reply_no_propose; dout(20) << "erasure code profile " << erasure_code_profile << " set" << dendl; pending_inc.set_erasure_code_profile(erasure_code_profile, profile_map); goto wait; @@ -13139,7 +13134,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (interr.length()) { ss << "error parsing integer value '" << rule_name << "': " << interr; err = -EINVAL; - goto reply; + goto reply_no_propose; } } rule_name = erasure_code_profile; @@ -13153,17 +13148,16 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, int rule; err = get_crush_rule(rule_name, &rule, &ss); if (err == -EAGAIN) { - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } if (err) - goto reply; + goto reply_no_propose; } if (expected_num_objects < 0) { ss << "'expected_num_objects' must be non-negative"; err = -EINVAL; - goto reply; + goto reply_no_propose; } int64_t fast_read_param = cmd_getval_or(cmdmap, "fast_read", -1); @@ -13204,15 +13198,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, switch(err) { case -EEXIST: ss << "pool '" << poolstr << "' already exists"; - break; + err = 0; + goto reply_no_propose; case -EAGAIN: - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; case -ERANGE: - goto reply; + goto reply_no_propose; default: - goto reply; - break; + goto reply_no_propose; } } else { ss << "pool '" << poolstr << "' created"; @@ -13232,7 +13225,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool < 0) { ss << "pool '" << poolstr << "' does not exist"; err = 0; - goto reply; + goto reply_no_propose; } bool force_no_fake = false; @@ -13245,15 +13238,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << ". If you are *ABSOLUTELY CERTAIN* that is what you want, pass the pool name *twice*, " << "followed by --yes-i-really-really-mean-it."; err = -EPERM; - goto reply; + goto reply_no_propose; } err = _prepare_remove_pool(pool, &ss, force_no_fake); if (err == -EAGAIN) { - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } if (err < 0) - goto reply; + goto reply_no_propose; goto update; } else if (prefix == "osd pool rename") { string srcpoolstr, destpoolstr; @@ -13267,7 +13259,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (destpoolstr[0] == '.' && !confirm) { ss << "pool names beginning with . are not allowed"; err = 0; - goto reply; + goto reply_no_propose; } if (pool_src < 0) { if (pool_dst >= 0) { @@ -13284,12 +13276,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unrecognized pool '" << srcpoolstr << "'"; err = -ENOENT; } - goto reply; + goto reply_no_propose; } else if (pool_dst >= 0) { // source pool exists and so does the destination pool ss << "pool '" << destpoolstr << "' already exists"; err = -EEXIST; - goto reply; + goto reply_no_propose; } int ret = _prepare_rename_pool(pool_src, destpoolstr); @@ -13309,7 +13301,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) goto wait; if (err < 0) - goto reply; + goto reply_no_propose; getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, @@ -13320,14 +13312,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) goto wait; if (err) - goto reply; + goto reply_no_propose; string poolstr; cmd_getval(cmdmap, "pool", poolstr); int64_t pool_id = osdmap.lookup_pg_pool_name(poolstr); if (pool_id < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } string tierpoolstr; cmd_getval(cmdmap, "tierpool", tierpoolstr); @@ -13335,7 +13327,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (tierpool_id < 0) { ss << "unrecognized pool '" << tierpoolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); ceph_assert(p); @@ -13343,7 +13335,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ceph_assert(tp); if (!_check_become_tier(tierpool_id, tp, pool_id, p, &err, &ss)) { - goto reply; + goto reply_no_propose; } // make sure new tier is empty @@ -13354,27 +13346,26 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, !force_nonempty) { ss << "tier pool '" << tierpoolstr << "' is not empty; --force-nonempty to force"; err = -ENOTEMPTY; - goto reply; + goto reply_no_propose; } if (tp->is_erasure()) { ss << "tier pool '" << tierpoolstr << "' is an ec pool, which cannot be a tier"; err = -ENOTSUP; - goto reply; + goto reply_no_propose; } if ((!tp->removed_snaps.empty() || !tp->snaps.empty()) && (!force_nonempty || !g_conf()->mon_debug_unsafe_allow_tier_with_nonempty_snaps)) { ss << "tier pool '" << tierpoolstr << "' has snapshot state; it cannot be added as a tier without breaking the pool"; err = -ENOTEMPTY; - goto reply; + goto reply_no_propose; } // go pg_pool_t *np = pending_inc.get_new_pool(pool_id, p); pg_pool_t *ntp = pending_inc.get_new_pool(tierpool_id, tp); if (np->tiers.count(tierpool_id) || ntp->is_tier()) { - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } np->tiers.insert(tierpool_id); np->set_snap_epoch(pending_inc.epoch); // tier will update to our snap info @@ -13391,7 +13382,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool_id < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } string tierpoolstr; cmd_getval(cmdmap, "tierpool", tierpoolstr); @@ -13399,7 +13390,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (tierpool_id < 0) { ss << "unrecognized pool '" << tierpoolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); ceph_assert(p); @@ -13407,13 +13398,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ceph_assert(tp); if (!_check_remove_tier(pool_id, p, tp, &err, &ss)) { - goto reply; + goto reply_no_propose; } if (p->tiers.count(tierpool_id) == 0) { ss << "pool '" << tierpoolstr << "' is now (or already was) not a tier of '" << poolstr << "'"; err = 0; - goto reply; + goto reply_no_propose; } if (tp->tier_of != pool_id) { ss << "tier pool '" << tierpoolstr << "' is a tier of '" @@ -13421,12 +13412,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // be scary about it; this is an inconsistency and bells must go off << "THIS SHOULD NOT HAVE HAPPENED AT ALL"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (p->read_tier == tierpool_id) { ss << "tier pool '" << tierpoolstr << "' is the overlay for '" << poolstr << "'; please remove-overlay first"; err = -EBUSY; - goto reply; + goto reply_no_propose; } // go pg_pool_t *np = pending_inc.get_new_pool(pool_id, p); @@ -13434,8 +13425,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (np->tiers.count(tierpool_id) == 0 || ntp->tier_of != pool_id || np->read_tier == tierpool_id) { - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } np->tiers.erase(tierpool_id); ntp->clear_tier(); @@ -13448,14 +13438,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) goto wait; if (err) - goto reply; + goto reply_no_propose; string poolstr; cmd_getval(cmdmap, "pool", poolstr); int64_t pool_id = osdmap.lookup_pg_pool_name(poolstr); if (pool_id < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } string overlaypoolstr; cmd_getval(cmdmap, "overlaypool", overlaypoolstr); @@ -13463,7 +13453,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (overlaypool_id < 0) { ss << "unrecognized pool '" << overlaypoolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); ceph_assert(p); @@ -13472,19 +13462,19 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (p->tiers.count(overlaypool_id) == 0) { ss << "tier pool '" << overlaypoolstr << "' is not a tier of '" << poolstr << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } if (p->read_tier == overlaypool_id) { err = 0; ss << "overlay for '" << poolstr << "' is now (or already was) '" << overlaypoolstr << "'"; - goto reply; + goto reply_no_propose; } if (p->has_read_tier()) { ss << "pool '" << poolstr << "' has overlay '" << osdmap.get_pool_name(p->read_tier) << "'; please remove-overlay first"; err = -EINVAL; - goto reply; + goto reply_no_propose; } // go @@ -13508,18 +13498,18 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool_id < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); ceph_assert(p); if (!p->has_read_tier()) { err = 0; ss << "there is now (or already was) no overlay for '" << poolstr << "'"; - goto reply; + goto reply_no_propose; } if (!_check_remove_tier(pool_id, p, NULL, &err, &ss)) { - goto reply; + goto reply_no_propose; } // go @@ -13546,21 +13536,21 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) goto wait; if (err) - goto reply; + goto reply_no_propose; string poolstr; cmd_getval(cmdmap, "pool", poolstr); int64_t pool_id = osdmap.lookup_pg_pool_name(poolstr); if (pool_id < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); ceph_assert(p); if (!p->is_tier()) { ss << "pool '" << poolstr << "' is not a tier"; err = -EINVAL; - goto reply; + goto reply_no_propose; } string modestr; cmd_getval(cmdmap, "mode", modestr); @@ -13568,7 +13558,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (int(mode) < 0) { ss << "'" << modestr << "' is not a valid cache mode"; err = -EINVAL; - goto reply; + goto reply_no_propose; } bool sure = false; @@ -13578,7 +13568,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, mode == pg_pool_t::CACHEMODE_READFORWARD) { ss << "'" << modestr << "' is no longer a supported cache mode"; err = -EPERM; - goto reply; + goto reply_no_propose; } if ((mode != pg_pool_t::CACHEMODE_WRITEBACK && mode != pg_pool_t::CACHEMODE_NONE && @@ -13588,7 +13578,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "'" << modestr << "' is not a well-supported cache mode and may " << "corrupt your data. pass --yes-i-really-mean-it to force."; err = -EPERM; - goto reply; + goto reply_no_propose; } // pool already has this cache-mode set and there are no pending changes @@ -13598,7 +13588,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "set cache-mode for pool '" << poolstr << "'" << " to " << pg_pool_t::get_cache_mode_name(mode); err = 0; - goto reply; + goto reply_no_propose; } /* Mode description: @@ -13637,7 +13627,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << pg_pool_t::get_cache_mode_name(pg_pool_t::CACHEMODE_READPROXY) << "' allowed."; err = -EINVAL; - goto reply; + goto reply_no_propose; } if ((p->cache_mode == pg_pool_t::CACHEMODE_READFORWARD && (mode != pg_pool_t::CACHEMODE_WRITEBACK && @@ -13665,7 +13655,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << pg_pool_t::get_cache_mode_name(mode) << "' on pool '" << poolstr << "': dirty objects found"; err = -EBUSY; - goto reply; + goto reply_no_propose; } } // go @@ -13691,14 +13681,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) goto wait; if (err) - goto reply; + goto reply_no_propose; string poolstr; cmd_getval(cmdmap, "pool", poolstr); int64_t pool_id = osdmap.lookup_pg_pool_name(poolstr); if (pool_id < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } string tierpoolstr; cmd_getval(cmdmap, "tierpool", tierpoolstr); @@ -13706,7 +13696,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (tierpool_id < 0) { ss << "unrecognized pool '" << tierpoolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); ceph_assert(p); @@ -13714,7 +13704,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ceph_assert(tp); if (!_check_become_tier(tierpool_id, tp, pool_id, p, &err, &ss)) { - goto reply; + goto reply_no_propose; } int64_t size = 0; @@ -13722,7 +13712,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "unable to parse 'size' value '" << cmd_vartype_stringify(cmdmap.at("size")) << "'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } // make sure new tier is empty const pool_stat_t *pstats = @@ -13730,14 +13720,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pstats && pstats->stats.sum.num_objects != 0) { ss << "tier pool '" << tierpoolstr << "' is not empty"; err = -ENOTEMPTY; - goto reply; + goto reply_no_propose; } auto& modestr = g_conf().get_val("osd_tier_default_cache_mode"); pg_pool_t::cache_mode_t mode = pg_pool_t::get_cache_mode_from_str(modestr); if (int(mode) < 0) { ss << "osd tier cache default mode '" << modestr << "' is not a valid cache mode"; err = -EINVAL; - goto reply; + goto reply_no_propose; } HitSet::Params hsp; auto& cache_hit_set_type = @@ -13754,14 +13744,13 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "osd tier cache default hit set type '" << cache_hit_set_type << "' is not a known type"; err = -EINVAL; - goto reply; + goto reply_no_propose; } // go pg_pool_t *np = pending_inc.get_new_pool(pool_id, p); pg_pool_t *ntp = pending_inc.get_new_pool(tierpool_id, tp); if (np->tiers.count(tierpool_id) || ntp->is_tier()) { - wait_for_finished_proposal(op, new C_RetryMessage(this, op)); - return true; + goto wait; } np->tiers.insert(tierpool_id); np->read_tier = np->write_tier = tierpool_id; @@ -13789,7 +13778,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (pool_id < 0) { ss << "unrecognized pool '" << poolstr << "'"; err = -ENOENT; - goto reply; + goto reply_no_propose; } string field; @@ -13797,7 +13786,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (field != "max_objects" && field != "max_bytes") { ss << "unrecognized field '" << field << "'; should be 'max_bytes' or 'max_objects'"; err = -EINVAL; - goto reply; + goto reply_no_propose; } // val could contain unit designations, so we treat as a string @@ -13815,7 +13804,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!tss.empty()) { ss << "error parsing value '" << val << "': " << tss; err = -EINVAL; - goto reply; + goto reply_no_propose; } pg_pool_t *pi = pending_inc.get_new_pool(pool_id, osdmap.get_pg_pool(pool_id)); @@ -13839,7 +13828,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err == -EAGAIN) { goto wait; } else if (err < 0) { - goto reply; + goto reply_no_propose; } else { goto update; } @@ -13848,7 +13837,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, string pgidstr; err = parse_pgid(cmdmap, ss, pgid, pgidstr); if (err < 0) - goto reply; + goto reply_no_propose; bool sure = false; cmd_getval(cmdmap, "yes_i_really_mean_it", sure); if (!sure) { @@ -13858,7 +13847,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << "willing to accept that the data is permanently destroyed. Pass " << "--yes-i-really-mean-it to proceed."; err = -EPERM; - goto reply; + goto reply_no_propose; } bool creating_now; { @@ -13883,7 +13872,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else { ss << "pg " << pgid << " already creating"; err = 0; - goto reply; + goto reply_no_propose; } } else if (prefix == "osd force_healthy_stretch_mode") { bool sure = false; @@ -13893,12 +13882,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, "(probably two data centers or availability zones?) and may result in PGs " "going inactive until backfilling is complete. Pass --yes-i-really-mean-it to proceed."; err = -EPERM; - goto reply; + goto reply_no_propose; } try_end_recovery_stretch_mode(true); ss << "Triggering healthy stretch mode"; err = 0; - goto reply; + goto reply_no_propose; } else if (prefix == "osd force_recovery_stretch_mode") { bool sure = false; cmd_getval(cmdmap, "yes_i_really_mean_it", sure); @@ -13908,12 +13897,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, "availability zones?) and should have happened automatically" "Pass --yes-i-really-mean-it to proceed."; err = -EPERM; - goto reply; + goto reply_no_propose; } mon.go_recovery_stretch_mode(); ss << "Triggering recovery stretch mode"; err = 0; - goto reply; + goto reply_no_propose; } else if (prefix == "osd set-allow-crimson") { bool sure = false; @@ -13929,12 +13918,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << "If you are sure, add --yes-i-really-mean-it and add 'crimson' to " << "the experimental features config. This setting is irrevocable."; err = -EPERM; - goto reply; + goto reply_no_propose; } err = 0; if (osdmap.get_allow_crimson()) { - goto reply; + goto reply_no_propose; } else { pending_inc.set_allow_crimson(); goto update; @@ -13943,12 +13932,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = -EINVAL; } - reply: + reply_no_propose: getline(ss, rs); if (err < 0 && rs.length() == 0) rs = cpp_strerror(err); mon.reply_command(op, err, rs, rdata, get_last_committed()); - return ret; + return false; /* nothing to propose */ update: getline(ss, rs); @@ -13957,6 +13946,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, return true; wait: + // XXX + // Some osd commands split changes across two epochs. + // It seems this is mostly for crush rule changes. It doesn't need + // to be this way but it's a bit of work to fix that. For now, + // trigger a proposal by returning true and then retry the command + // to complete the operation. wait_for_finished_proposal(op, new C_RetryMessage(this, op)); return true; } -- 2.39.5