From e2952afa04876f3b3d5b3e2f5c088a398cf2c890 Mon Sep 17 00:00:00 2001 From: Vikhyat Umrao Date: Sun, 22 May 2016 13:19:36 +0530 Subject: [PATCH] mon : add osdmap flags set and unset message when osdmap flags are already set and unset Fixes: http://tracker.ceph.com/issues/15983 Signed-off-by: Vikhyat Umrao --- qa/workunits/cephtool/test.sh | 12 ++++++++++++ src/mon/OSDMonitor.cc | 20 ++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) 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..dcfd8062d800f5 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4806,10 +4806,14 @@ 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)); + get_last_committed() + 1)); return true; } @@ -4819,10 +4823,14 @@ 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)); + get_last_committed() + 1)); return true; }