Skip to content

Commit

Permalink
mon : add osdmap flags set and unset message when
Browse files Browse the repository at this point in the history
osdmap flags are already set and unset

Fixes: http://tracker.ceph.com/issues/15983

Signed-off-by: Vikhyat Umrao <vumrao@redhat.com>
  • Loading branch information
vumrao committed May 24, 2016
1 parent 45a1591 commit c606f49
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
12 changes: 12 additions & 0 deletions qa/workunits/cephtool/test.sh
Expand Up @@ -472,6 +472,18 @@ function test_tiering()
ceph osd pool delete basepoolA basepoolA --yes-i-really-really-mean-it
}

function test_osdmap_flag()
{
ceph osd set noout >& $TMPFILE || return 1
check_response "set noout"
ceph osd set noout >& $TMPFILE || return 1
expect_failure $TMPDIR "Error EINVAL: noout flag is already set"
ceph osd unset noout >& $TMPFILE || return 1
check_response "unset noout"
ceph osd unset noout >& $TMPFILE || return 1
expect_failure $TMPDIR "Error EINVAL: noout flag is not set"
}

function test_auth()
{
ceph auth add client.xx mon allow osd "allow *"
Expand Down
26 changes: 18 additions & 8 deletions src/mon/OSDMonitor.cc
Expand Up @@ -4806,10 +4806,15 @@ bool OSDMonitor::prepare_set_flag(MonOpRequestRef op, int flag)
ostringstream ss;
if (pending_inc.new_flags < 0)
pending_inc.new_flags = osdmap.get_flags();
pending_inc.new_flags |= flag;
ss << "set " << OSDMap::get_flag_string(flag);
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, ss.str(),
get_last_committed() + 1));
if (osdmap.test_flag(flag)) {
ss << OSDMap::get_flag_string(flag) << " flag is already set";
mon->reply_command(op, -EINVAL, ss.str(), get_last_committed());
} else {
pending_inc.new_flags |= flag;
ss << "set " << OSDMap::get_flag_string(flag);
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, ss.str(),
get_last_committed() + 1));
}
return true;
}

Expand All @@ -4819,10 +4824,15 @@ bool OSDMonitor::prepare_unset_flag(MonOpRequestRef op, int flag)
ostringstream ss;
if (pending_inc.new_flags < 0)
pending_inc.new_flags = osdmap.get_flags();
pending_inc.new_flags &= ~flag;
ss << "unset " << OSDMap::get_flag_string(flag);
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, ss.str(),
get_last_committed() + 1));
if (!osdmap.test_flag(flag)) {
ss << OSDMap::get_flag_string(flag) << " flag is not set";
mon->reply_command(op, -EINVAL, ss.str(), get_last_committed());
} else {
pending_inc.new_flags &= ~flag;
ss << "unset " << OSDMap::get_flag_string(flag);
wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, ss.str(),
get_last_committed() + 1));
}
return true;
}

Expand Down

0 comments on commit c606f49

Please sign in to comment.