From: Sage Weil Date: Fri, 3 May 2013 22:26:22 +0000 (-0700) Subject: crush: return -1 on error from get_type_id X-Git-Tag: v0.63~65^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8894c5041d2dbd7408b428e5c2b3434aae2d697f;p=ceph.git crush: return -1 on error from get_type_id So we can distinguish between a bad type name and type 0. Fix both callers, too. Signed-off-by: Sage Weil --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 1fc86893e1d0..e8058d60a57e 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -641,8 +641,9 @@ int CrushWrapper::add_simple_rule(string name, string root_name, string failure_ int type = 0; if (failure_domain_name.length()) { type = get_type_id(failure_domain_name); - if (type <= 0) // bah, returns 0 on error; but its ok, device isn't a domain really + if (type < 0) { return -EINVAL; + } } int ruleset = 0; diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 9109156d066d..ac936336125c 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -166,7 +166,7 @@ public: build_rmaps(); if (type_rmap.count(name)) return type_rmap[name]; - return 0; + return -1; } const char *get_type_name(int t) const { std::map::const_iterator p = type_map.find(t); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index d46c28f6ff27..75105cadadf9 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2557,7 +2557,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) err = 0; } else { int type = newcrush.get_type_id(m->cmd[4]); - if (type <= 0) { + if (type < 0) { ss << "type '" << m->cmd[4] << "' does not exist"; err = -EINVAL; break;