From: Samuel Just Date: Tue, 29 Nov 2011 01:30:37 +0000 (-0800) Subject: CrushWrapper: ignore forcefeed if it does not exist X-Git-Tag: v0.40~240 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6fbab6da6942c238d40a6b4f1680a7e6da463289;p=ceph.git CrushWrapper: ignore forcefeed if it does not exist Signed-off-by: Samuel Just --- diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index df62b8abcc9b..67bb13e39465 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -114,7 +114,7 @@ public: build_rmaps(); return name_rmap.count(name); } - bool item_exists(int i) { + bool item_exists(int i) const { return name_map.count(i); } int get_item_id(const char *s) { @@ -387,10 +387,14 @@ public: void do_rule(int rule, int x, vector& out, int maxout, int forcefeed, const vector<__u32>& weight) const { int rawout[maxout]; - int numrep = crush_do_rule(crush, rule, x, rawout, maxout, - forcefeed, &weight[0]); - if (numrep < 0) - numrep = 0; // e.g., when forcefed device dne. + int numrep = -1; + if (item_exists(forcefeed)) + numrep = crush_do_rule(crush, rule, x, rawout, maxout, + forcefeed, &weight[0]); + else + numrep = crush_do_rule(crush, rule, x, rawout, maxout, + -1, &weight[0]); + assert(numrep >= 0); out.resize(numrep); for (int i=0; i