if (m->cmd[1] == "setcrushmap") {
dout(10) << "prepare_command setting new crush map" << dendl;
bufferlist data(m->get_data());
+ CrushWrapper crush;
try {
bufferlist::iterator bl(data.begin());
- CrushWrapper crush;
crush.decode(bl);
}
catch (const std::exception &e) {
ss << "Failed to parse crushmap: " << e.what();
goto out;
}
+
+ if (crush.get_max_devices() > osdmap.get_max_osd()) {
+ err = -ERANGE;
+ ss << "crushmap max_devices " << crush.get_max_devices()
+ << " > osdmap max_osd " << osdmap.get_max_osd();
+ goto out;
+ }
+
pending_inc.crush = data;
string rs = "set crush map";
paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
}
*/
else if (m->cmd[1] == "setmaxosd" && m->cmd.size() > 2) {
- pending_inc.new_max_osd = atoi(m->cmd[2].c_str());
+ int newmax = atoi(m->cmd[2].c_str());
+ if (newmax < osdmap.crush.get_max_devices()) {
+ err = -ERANGE;
+ ss << "cannot set max_osd to " << newmax << " which is < crush max_devices "
+ << osdmap.crush.get_max_devices();
+ goto out;
+ }
+
+ pending_inc.new_max_osd = newmax;
ss << "set new max_osd = " << pending_inc.new_max_osd;
getline(ss, rs);
paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));