From: Samuel Just Date: Sat, 27 Apr 2013 00:16:53 +0000 (-0700) Subject: OSDMonitor: when adding bucket, delay response if pending map has name X-Git-Tag: v0.61~53^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=79280d9f4e5d33ffd12499a2d30d8e0875e3351a;p=ceph.git OSDMonitor: when adding bucket, delay response if pending map has name Fixes: #4836 Signed-off-by: Samuel Just --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e8a277a7b01d..d46c28f6ff27 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 + 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 0034bb0baca4..30fd09fa4999 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