} else if (prefix == "mds set_state") {
int64_t gid;
- if (!cmd_getval(g_ceph_context, cmdmap, "gid", gid))
+ if (!cmd_getval(g_ceph_context, cmdmap, "gid", gid)) {
+ ss << "error parsing 'gid' value '"
+ << cmd_vartype_stringify(cmdmap["gid"]) << "'";
+ r = -EINVAL;
goto out;
+ }
int64_t state;
- cmd_getval(g_ceph_context, cmdmap, "state", state);
+ if (!cmd_getval(g_ceph_context, cmdmap, "state", state)) {
+ ss << "error parsing 'state' string value '"
+ << cmd_vartype_stringify(cmdmap["state"]) << "'";
+ r = -EINVAL;
+ goto out;
+ }
if (!pending_mdsmap.is_dne_gid(gid)) {
MDSMap::mds_info_t& info = pending_mdsmap.get_info_gid(gid);
info.state = state;
} else if (prefix == "mds rm") {
int64_t gid;
- cmd_getval(g_ceph_context, cmdmap, "gid", gid);
+ if (!cmd_getval(g_ceph_context, cmdmap, "gid", gid)) {
+ ss << "error parsing 'gid' value '"
+ << cmd_vartype_stringify(cmdmap["gid"]) << "'";
+ r = -EINVAL;
+ goto out;
+ }
int state = pending_mdsmap.get_state_gid(gid);
if (state == 0) {
ss << "mds gid " << gid << " dne";
}
} else if (prefix == "mds rmfailed") {
int64_t w;
- cmd_getval(g_ceph_context, cmdmap, "who", w);
+ if (!cmd_getval(g_ceph_context, cmdmap, "who", w)) {
+ ss << "error parsing 'who' value '"
+ << cmd_vartype_stringify(cmdmap["who"]) << "'";
+ r = -EINVAL;
+ goto out;
+ }
pending_mdsmap.failed.erase(w);
stringstream ss;
ss << "removed failed mds." << w;
r = 0;
} else if (prefix == "mds compat rm_compat") {
int64_t f;
- cmd_getval(g_ceph_context, cmdmap, "feature", f);
+ if (!cmd_getval(g_ceph_context, cmdmap, "feature", f)) {
+ ss << "error parsing feature value '"
+ << cmd_vartype_stringify(cmdmap["feature"]) << "'";
+ r = -EINVAL;
+ goto out;
+ }
if (pending_mdsmap.compat.compat.contains(f)) {
ss << "removing compat feature " << f;
pending_mdsmap.compat.compat.remove(f);
}
} else if (prefix == "mds compat rm_incompat") {
int64_t f;
- cmd_getval(g_ceph_context, cmdmap, "feature", f);
+ if (!cmd_getval(g_ceph_context, cmdmap, "feature", f)) {
+ ss << "error parsing feature value '"
+ << cmd_vartype_stringify(cmdmap["feature"]) << "'";
+ r = -EINVAL;
+ goto out;
+ }
if (pending_mdsmap.compat.incompat.contains(f)) {
ss << "removing incompat feature " << f;
pending_mdsmap.compat.incompat.remove(f);
} else if (prefix == "mds newfs") {
MDSMap newmap;
int64_t metadata, data;
- cmd_getval(g_ceph_context, cmdmap, "metadata", metadata);
- cmd_getval(g_ceph_context, cmdmap, "data", data);
+ if (!cmd_getval(g_ceph_context, cmdmap, "metadata", metadata)) {
+ ss << "error parsing 'metadata' value '"
+ << cmd_vartype_stringify(cmdmap["metadata"]) << "'";
+ r = -EINVAL;
+ goto out;
+ }
+ if (!cmd_getval(g_ceph_context, cmdmap, "data", data)) {
+ ss << "error parsing 'data' value '"
+ << cmd_vartype_stringify(cmdmap["data"]) << "'";
+ r = -EINVAL;
+ goto out;
+ }
string sure;
cmd_getval(g_ceph_context, cmdmap, "sure", sure);
if (sure != "--yes-i-really-mean-it") {
}
} else if (prefix == "osd find") {
int64_t osd;
- cmd_getval(g_ceph_context, cmdmap, "id", osd);
+ if (!cmd_getval(g_ceph_context, cmdmap, "id", osd)) {
+ ss << "unable to parse osd id value '"
+ << cmd_vartype_stringify(cmdmap["id"]) << "'";
+ r = -EINVAL;
+ goto reply;
+ }
if (!osdmap.exists(osd)) {
ss << "osd." << osd << " does not exist";
r = -ENOENT;
f->flush(rdata);
} else if (prefix == "osd metadata") {
int64_t osd;
- cmd_getval(g_ceph_context, cmdmap, "id", osd);
+ if (!cmd_getval(g_ceph_context, cmdmap, "id", osd)) {
+ ss << "unable to parse osd id value '"
+ << cmd_vartype_stringify(cmdmap["id"]) << "'";
+ r = -EINVAL;
+ goto reply;
+ }
if (!osdmap.exists(osd)) {
ss << "osd." << osd << " does not exist";
r = -ENOENT;
}
double weight;
- cmd_getval(g_ceph_context, cmdmap, "weight", weight);
+ if (!cmd_getval(g_ceph_context, cmdmap, "weight", weight)) {
+ ss << "unable to parse weight value '"
+ << cmd_vartype_stringify(cmdmap["weight"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
string args;
vector<string> argvec;
}
double weight;
- cmd_getval(g_ceph_context, cmdmap, "weight", weight);
+ if (!cmd_getval(g_ceph_context, cmdmap, "weight", weight)) {
+ ss << "unable to parse weight value '"
+ << cmd_vartype_stringify(cmdmap["weight"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
string args;
vector<string> argvec;
break;
}
double w;
- cmd_getval(g_ceph_context, cmdmap, "weight", w);
+ if (!cmd_getval(g_ceph_context, cmdmap, "weight", w)) {
+ ss << "unable to parse weight value '"
+ << cmd_vartype_stringify(cmdmap["weight"]) << "'";
+ err = -EINVAL;
+ break;
+ }
err = newcrush.adjust_item_weightf(g_ceph_context, id, w);
if (err >= 0) {
} else if (prefix == "osd setmaxosd") {
int64_t newmax;
- cmd_getval(g_ceph_context, cmdmap, "newmax", newmax);
+ if (!cmd_getval(g_ceph_context, cmdmap, "newmax", newmax)) {
+ ss << "unable to parse 'newmax' value '"
+ << cmd_vartype_stringify(cmdmap["newmax"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
if (newmax > g_conf->mon_max_osd) {
err = -ERANGE;
} else if (prefix == "osd primary-affinity") {
int64_t id;
if (!cmd_getval(g_ceph_context, cmdmap, "id", id)) {
- ss << "invalid osd id";
+ ss << "invalid osd id value '"
+ << cmd_vartype_stringify(cmdmap["id"]) << "'";
err = -EINVAL;
goto reply;
}
double w;
- cmd_getval(g_ceph_context, cmdmap, "weight", w);
+ if (!cmd_getval(g_ceph_context, cmdmap, "weight", w)) {
+ ss << "unable to parse 'weight' value '"
+ << cmd_vartype_stringify(cmdmap["weight"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
long ww = (int)((double)CEPH_OSD_MAX_PRIMARY_AFFINITY*w);
if (ww < 0L) {
ss << "weight must be >= 0";
}
} else if (prefix == "osd reweight") {
int64_t id;
- cmd_getval(g_ceph_context, cmdmap, "id", id);
+ if (!cmd_getval(g_ceph_context, cmdmap, "id", id)) {
+ ss << "unable to parse osd id value '"
+ << cmd_vartype_stringify(cmdmap["id"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
double w;
- cmd_getval(g_ceph_context, cmdmap, "weight", w);
+ if (!cmd_getval(g_ceph_context, cmdmap, "weight", w)) {
+ ss << "unable to parse weight value '"
+ << cmd_vartype_stringify(cmdmap["weight"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
long ww = (int)((double)CEPH_OSD_IN*w);
if (ww < 0L) {
ss << "weight must be >= 0";
} else if (prefix == "osd lost") {
int64_t id;
- cmd_getval(g_ceph_context, cmdmap, "id", id);
+ if (!cmd_getval(g_ceph_context, cmdmap, "id", id)) {
+ ss << "unable to parse osd id value '"
+ << cmd_vartype_stringify(cmdmap["id"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
string sure;
if (!cmd_getval(g_ceph_context, cmdmap, "sure", sure) || sure != "--yes-i-really-mean-it") {
ss << "are you SURE? this might mean real, permanent data loss. pass "
goto reply;
}
int64_t size = 0;
- cmd_getval(g_ceph_context, cmdmap, "size", size);
+ if (!cmd_getval(g_ceph_context, cmdmap, "size", size)) {
+ ss << "unable to parse 'size' value '"
+ << cmd_vartype_stringify(cmdmap["size"]) << "'";
+ err = -EINVAL;
+ goto reply;
+ }
// make sure new tier is empty
const pool_stat_t& tier_stats =
mon->pgmon()->pg_map.get_pg_pool_sum_stat(tierpool_id);