return *osdmap.crush;
}
-void OSDMonitor::_get_pending_crush(CrushWrapper& newcrush)
+CrushWrapper OSDMonitor::_get_pending_crush()
{
bufferlist bl;
if (pending_inc.crush.length())
osdmap.crush->encode(bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
auto p = bl.cbegin();
- newcrush.decode(p);
+ CrushWrapper crush;
+ crush.decode(p);
+ return crush;
}
void OSDMonitor::create_initial()
// Rewrite CRUSH rule IDs if they are using legacy "ruleset"
// structure.
if (osdmap.crush->has_legacy_rule_ids()) {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
// First, for all pools, work out which rule they really used
// by resolving ruleset to rule.
return ret;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
ret = newcrush.rename_bucket(srcname,
dstname,
return -EEXIST;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
ruleid = newcrush.get_rule_id(name);
if (ruleid != -ENOENT) {
// found it, use it
*crush_rule = ret;
} else {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
ret = newcrush.get_rule_id(rule_name);
if (ret != -ENOENT) {
return r;
}
if (g_conf()->mon_osd_crush_smoke_test) {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
ostringstream err;
CrushTester tester(newcrush, err);
tester.set_min_x(0);
out:
if (device_class.size()) {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (newcrush.get_max_devices() < *new_id + 1) {
newcrush.set_max_devices(*new_id + 1);
}
* the crush update we delayed from before.
*/
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
bool may_be_idempotent = false;
goto update;
} else if (prefix == "osd crush set-all-straw-buckets-to-straw2") {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
for (int b = 0; b < newcrush.get_max_buckets(); ++b) {
int bid = -1 - b;
if (newcrush.bucket_exists(bid) &&
bool stop = false;
vector<string> idvec;
cmd_getval(cmdmap, "ids", idvec);
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
set<int> updated;
for (unsigned j = 0; j < idvec.size() && !stop; j++) {
set<int> osds;
bool stop = false;
vector<string> idvec;
cmd_getval(cmdmap, "ids", idvec);
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
set<int> updated;
for (unsigned j = 0; j < idvec.size() && !stop; j++) {
ss << "class '" << device_class << "' already exists";
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (newcrush.class_exists(device_class)) {
ss << "class '" << device_class << "' already exists";
goto update;
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (!newcrush.class_exists(device_class)) {
err = 0; // make command idempotent
goto wait;
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (!newcrush.class_exists(srcname) && newcrush.class_exists(dstname)) {
// suppose this is a replay and return success
// so command is idempotent
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (newcrush.name_exists(name)) {
ss << "bucket '" << name << "' already exists";
goto update;
} else if (prefix == "osd crush weight-set create" ||
prefix == "osd crush weight-set create-compat") {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
int64_t pool;
int positions;
if (newcrush.has_non_straw2_buckets()) {
} else if (prefix == "osd crush weight-set rm" ||
prefix == "osd crush weight-set rm-compat") {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
int64_t pool;
if (prefix == "osd crush weight-set rm") {
string poolname;
cmd_getval(cmdmap, "pool", poolname);
cmd_getval(cmdmap, "item", item);
cmd_getval(cmdmap, "weight", weight);
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
int64_t pool;
if (prefix == "osd crush weight-set reweight") {
pool = osdmap.lookup_pg_pool_name(poolname.c_str());
dout(5) << "adding/updating crush item id " << osdid << " name '"
<< osd_name << "' weight " << weight << " at location "
<< loc << dendl;
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
string action;
if (prefix == "osd crush set" ||
<< "' initial_weight " << weight << " at location " << loc
<< dendl;
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
err = newcrush.create_or_move_item(cct, osdid, weight, osd_name, loc,
g_conf()->osd_crush_update_weight_set);
CrushWrapper::parse_loc_map(argvec, &loc);
dout(0) << "moving crush item name '" << name << "' to location " << loc << dendl;
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (!newcrush.name_exists(name)) {
err = -ENOENT;
bool force = false;
cmd_getval(cmdmap, "yes_i_really_mean_it", force);
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (!newcrush.name_exists(source)) {
ss << "source item " << source << " does not exist";
err = -ENOENT;
}
dout(5) << "linking crush item name '" << name << "' at location " << loc << dendl;
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (!newcrush.name_exists(name)) {
err = -ENOENT;
prefix == "osd crush unlink") {
do {
// osd crush rm <id> [ancestor]
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
string name;
cmd_getval(cmdmap, "name", name);
} while (false);
} else if (prefix == "osd crush reweight-all") {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
newcrush.reweight(cct);
pending_inc.crush.clear();
return true;
} else if (prefix == "osd crush reweight") {
// osd crush reweight <name> <weight>
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
string name;
cmd_getval(cmdmap, "name", name);
return true;
} else if (prefix == "osd crush reweight-subtree") {
// osd crush reweight <name> <weight>
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
string name;
cmd_getval(cmdmap, "name", name);
get_last_committed() + 1));
return true;
} else if (prefix == "osd crush tunables") {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
err = 0;
string profile;
get_last_committed() + 1));
return true;
} else if (prefix == "osd crush set-tunable") {
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
err = 0;
string tunable;
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (newcrush.rule_exists(name)) {
// The name is uniquely associated to a ruleid and the rule it contains
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (newcrush.rule_exists(name)) {
// The name is uniquely associated to a ruleid and the rule it contains
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (!newcrush.rule_exists(name)) {
ss << "rule " << name << " does not exist";
goto reply;
}
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (!newcrush.rule_exists(srcname) && newcrush.rule_exists(dstname)) {
// srcname does not exist and dstname already exists
// suppose this is a replay and return success
}
// remove any choose_args for this pool
- CrushWrapper newcrush;
- _get_pending_crush(newcrush);
+ CrushWrapper newcrush = _get_pending_crush();
if (newcrush.have_choose_args(pool)) {
dout(10) << __func__ << " removing choose_args for pool " << pool << dendl;
newcrush.rm_choose_args(pool);
{
dout(20) << __func__ << dendl;
*okay = false;
- CrushWrapper crush;
- _get_pending_crush(crush);
+ CrushWrapper crush = _get_pending_crush();
int dividing_id;
int retval = crush.get_validated_type_id(dividing_bucket, &dividing_id);
if (retval == -1) {