diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index 8ddfa30d1991fb..2b8fd766e5b6fc 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -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 + check_response "noout flag is already set" + ceph osd unset noout >& $TMPFILE || return 1 + check_response "unset noout" + ceph osd unset noout >& $TMPFILE || return 1 + check_response "noout flag is not set" +} + function test_auth() { ceph auth add client.xx mon allow osd "allow *" diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c9f46f054e1a00..13f57aeec72368 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4806,8 +4806,12 @@ 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); + if (osdmap.test_flag(flag)) { + ss << OSDMap::get_flag_string(flag) << " flag is already set"; + } 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; @@ -4819,8 +4823,12 @@ 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); + if (!osdmap.test_flag(flag)) { + ss << OSDMap::get_flag_string(flag) << " flag is not set"; + } 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;