diff options
author | Samuel Just <sam.just@inktank.com> | 2013-04-26 17:16:53 -0700 |
---|---|---|
committer | Samuel Just <sam.just@inktank.com> | 2013-04-26 17:19:59 -0700 |
commit | 79280d9f4e5d33ffd12499a2d30d8e0875e3351a (patch) | |
tree | abaf70726ca7264e118c2cda59f5ccd3ceb3d92d | |
parent | e725c3e210b244e090d70c77d937c94f4f63a2be (diff) | |
download | ceph-79280d9f4e5d33ffd12499a2d30d8e0875e3351a.tar.gz |
OSDMonitor: when adding bucket, delay response if pending map has name
Fixes: #4836
Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r-- | src/mon/OSDMonitor.cc | 45 | ||||
-rw-r--r-- | src/mon/OSDMonitor.h | 2 |
2 files changed, 32 insertions, 15 deletions
diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e8a277a7b01..d46c28f6ff2 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -58,6 +58,15 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, OSDMap& osdmap) { << ").osd e" << osdmap.get_epoch() << " "; } +bool OSDMonitor::_have_pending_crush() +{ + return pending_inc.crush.length(); +} + +CrushWrapper &OSDMonitor::_get_stable_crush() +{ + return *osdmap.crush; +} void OSDMonitor::_get_pending_crush(CrushWrapper& newcrush) { @@ -2534,27 +2543,33 @@ bool OSDMonitor::prepare_command(MMonCommand *m) else if (m->cmd.size() == 5 && m->cmd[1] == "crush" && (m->cmd[2] == "add-bucket")) { do { // osd crush add-bucket <name> <type> + if (!_have_pending_crush() && + _get_stable_crush().name_exists(m->cmd[3])) { + ss << "bucket '" << m->cmd[3] << "' already exists"; + err = 0; + break; + } + CrushWrapper newcrush; _get_pending_crush(newcrush); - if (newcrush.name_exists(m->cmd[3])) { ss << "bucket '" << m->cmd[3] << "' already exists"; err = 0; - break; - } - int type = newcrush.get_type_id(m->cmd[4]); - if (type <= 0) { - ss << "type '" << m->cmd[4] << "' does not exist"; - err = -EINVAL; - break; - } - int bucketno = newcrush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT, - type, 0, NULL, NULL); - newcrush.set_item_name(bucketno, m->cmd[3]); + } else { + int type = newcrush.get_type_id(m->cmd[4]); + if (type <= 0) { + ss << "type '" << m->cmd[4] << "' does not exist"; + err = -EINVAL; + break; + } + int bucketno = newcrush.add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_DEFAULT, + type, 0, NULL, NULL); + newcrush.set_item_name(bucketno, m->cmd[3]); - pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush); - ss << "added bucket " << m->cmd[3] << " type " << m->cmd[4] << " to crush map"; + pending_inc.crush.clear(); + newcrush.encode(pending_inc.crush); + ss << "added bucket " << m->cmd[3] << " type " << m->cmd[4] << " to crush map"; + } getline(ss, rs); wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); return true; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 0034bb0baca..30fd09fa499 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -137,6 +137,8 @@ private: int thrash_last_up_osd; bool thrash(); + bool _have_pending_crush(); + CrushWrapper &_get_stable_crush(); void _get_pending_crush(CrushWrapper& newcrush); // svc |