Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon/OSDMonitor: rename outer name declaration to avoid shadowing #20032

Merged
merged 3 commits into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/admin_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ bool AdminSocket::do_accept()
stringstream errss;
cmdvec.push_back(cmd);
if (!cmdmap_from_json(cmdvec, &cmdmap, errss)) {
ldout(m_cct, 0) << "AdminSocket: " << errss.rdbuf() << dendl;
ldout(m_cct, 0) << "AdminSocket: " << errss.str() << dendl;
VOID_TEMP_FAILURE_RETRY(close(connection_fd));
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/common/cmdparse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ handle_bad_get(CephContext *cct, const string& k, const char *tname)

ostringstream oss;
oss << BackTrace(1);
lderr(cct) << oss.rdbuf() << dendl;
lderr(cct) << oss.str() << dendl;

if (status == 0)
free((char *)typestr);
}
Expand Down
50 changes: 30 additions & 20 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5981,7 +5981,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
if (err == 0) {
k = erasure_code->get_data_chunk_count();
} else {
ss << __func__ << " get_erasure_code failed: " << tmp.rdbuf();
ss << __func__ << " get_erasure_code failed: " << tmp.str();
return err;
}

Expand Down Expand Up @@ -7239,12 +7239,17 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
cmd_getval(cct, cmdmap, "prefix", prefix);

int64_t osdid;
string name;
bool osdid_present = cmd_getval(cct, cmdmap, "id", osdid);
string osd_name;
bool osdid_present = false;
if (prefix != "osd pg-temp" &&
prefix != "osd pg-upmap" &&
prefix != "osd pg-upmap-items") { // avoid commands with non-int id arg
osdid_present = cmd_getval(cct, cmdmap, "id", osdid);
}
if (osdid_present) {
ostringstream oss;
oss << "osd." << osdid;
name = oss.str();
osd_name = oss.str();
}

// Even if there's a pending state with changes that could affect
Expand Down Expand Up @@ -7775,7 +7780,8 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,

if (!osdmap.exists(osdid)) {
err = -ENOENT;
ss << name << " does not exist. Create it before updating the crush map";
ss << osd_name
<< " does not exist. Create it before updating the crush map";
goto reply;
}

Expand All @@ -7796,14 +7802,14 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
if (prefix == "osd crush set"
&& !_get_stable_crush().item_exists(osdid)) {
err = -ENOENT;
ss << "unable to set item id " << osdid << " name '" << name
ss << "unable to set item id " << osdid << " name '" << osd_name
<< "' weight " << weight << " at location " << loc
<< ": does not exist";
goto reply;
}

dout(5) << "adding/updating crush item id " << osdid << " name '"
<< name << "' weight " << weight << " at location "
<< osd_name << "' weight " << weight << " at location "
<< loc << dendl;
CrushWrapper newcrush;
_get_pending_crush(newcrush);
Expand All @@ -7812,10 +7818,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
if (prefix == "osd crush set" ||
newcrush.check_item_loc(cct, osdid, loc, (int *)NULL)) {
action = "set";
err = newcrush.update_item(cct, osdid, weight, name, loc);
err = newcrush.update_item(cct, osdid, weight, osd_name, loc);
} else {
action = "add";
err = newcrush.insert_item(cct, osdid, weight, name, loc);
err = newcrush.insert_item(cct, osdid, weight, osd_name, loc);
if (err == 0)
err = 1;
}
Expand All @@ -7824,15 +7830,15 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
goto reply;

if (err == 0 && !_have_pending_crush()) {
ss << action << " item id " << osdid << " name '" << name << "' weight "
<< weight << " at location " << loc << ": no change";
ss << action << " item id " << osdid << " name '" << osd_name
<< "' weight " << weight << " at location " << loc << ": no change";
goto reply;
}

pending_inc.crush.clear();
newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
ss << action << " item id " << osdid << " name '" << name << "' weight "
<< weight << " at location " << loc << " to crush map";
ss << action << " item id " << osdid << " name '" << osd_name << "' weight "
<< weight << " at location " << loc << " to crush map";
getline(ss, rs);
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
get_last_committed() + 1));
Expand All @@ -7843,7 +7849,8 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
// osd crush create-or-move <OsdName> <initial_weight> <loc1> [<loc2> ...]
if (!osdmap.exists(osdid)) {
err = -ENOENT;
ss << name << " does not exist. create it before updating the crush map";
ss << osd_name
<< " does not exist. create it before updating the crush map";
goto reply;
}

Expand All @@ -7861,22 +7868,25 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
map<string,string> loc;
CrushWrapper::parse_loc_map(argvec, &loc);

dout(0) << "create-or-move crush item name '" << name << "' initial_weight " << weight
<< " at location " << loc << dendl;
dout(0) << "create-or-move crush item name '" << osd_name
<< "' initial_weight " << weight << " at location " << loc
<< dendl;

CrushWrapper newcrush;
_get_pending_crush(newcrush);

err = newcrush.create_or_move_item(cct, osdid, weight, name, loc);
err = newcrush.create_or_move_item(cct, osdid, weight, osd_name, loc);
if (err == 0) {
ss << "create-or-move updated item name '" << name << "' weight " << weight
ss << "create-or-move updated item name '" << osd_name
<< "' weight " << weight
<< " at location " << loc << " to crush map";
break;
}
if (err > 0) {
pending_inc.crush.clear();
newcrush.encode(pending_inc.crush, mon->get_quorum_con_features());
ss << "create-or-move updating item name '" << name << "' weight " << weight
ss << "create-or-move updating item name '" << osd_name
<< "' weight " << weight
<< " at location " << loc << " to crush map";
getline(ss, rs);
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs,
Expand All @@ -7888,7 +7898,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
} else if (prefix == "osd crush move") {
do {
// osd crush move <name> <loc1> [<loc2> ...]

string name;
string args;
vector<string> argvec;
cmd_getval(cct, cmdmap, "name", name);
Expand Down
2 changes: 1 addition & 1 deletion src/osd/PG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3488,7 +3488,7 @@ void PG::read_state(ObjectStore *store)
cct->_conf->osd_ignore_stale_divergent_priors,
cct->_conf->osd_debug_verify_missing_on_start);
if (oss.tellp())
osd->clog->error() << oss.rdbuf();
osd->clog->error() << oss.str();

// log any weirdness
log_weirdness();
Expand Down