Skip to content

Commit

Permalink
mon: add safety checks for 'mds rm <gid>' command
Browse files Browse the repository at this point in the history
- make sure the gid exists
- only remove it if it's inactive (state < 0)

Fixes: ceph#2188
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed May 5, 2012
1 parent 9d7ec04 commit b50a4c9
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/mon/MDSMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,23 @@ bool MDSMonitor::prepare_command(MMonCommand *m)
}
else if (m->cmd[1] == "rm" && m->cmd.size() == 3) {
uint64_t gid = atoll(m->cmd[2].c_str());
pending_mdsmap.mds_info.erase(gid);
stringstream ss;
ss << "removed mds gid " << gid;
string rs;
getline(ss, rs);
paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
return true;
int state = pending_mdsmap.get_state_gid(gid);
if (state == 0) {
ss << "mds gid " << gid << " dne";
r = 0;
} else if (state > 0) {
ss << "cannot remove active mds." << pending_mdsmap.get_info_gid(gid).name
<< " rank " << pending_mdsmap.get_info_gid(gid).rank;
r = -EBUSY;
} else {
pending_mdsmap.mds_info.erase(gid);
stringstream ss;
ss << "removed mds gid " << gid;
string rs;
getline(ss, rs);
paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, paxos->get_version()));
return true;
}
}
else if (m->cmd[1] == "rmfailed" && m->cmd.size() == 3) {
int w = atoi(m->cmd[2].c_str());
Expand Down

0 comments on commit b50a4c9

Please sign in to comment.