From: Sage Weil Date: Sat, 21 May 2011 19:55:16 +0000 (-0700) Subject: osdmaptool: fail --import-crush if crush max_devices > osdmap max_osd X-Git-Tag: v0.29~42^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e9754d88ce9fd0df4ba835fef0f3b1d47e0245da;p=ceph.git osdmaptool: fail --import-crush if crush max_devices > osdmap max_osd Crush will spew non-deterministic badness if it walks off the end of the osd_weight vector. Signed-off-by: Sage Weil --- diff --git a/src/osdmaptool.cc b/src/osdmaptool.cc index a494453e29a5..a0d0b42a760b 100644 --- a/src/osdmaptool.cc +++ b/src/osdmaptool.cc @@ -159,10 +159,17 @@ int main(int argc, const char **argv) cerr << me << ": error reading crush map from " << import_crush << std::endl; exit(1); } + // validate CrushWrapper cw; bufferlist::iterator p = cbl.begin(); cw.decode(p); + + if (cw.get_max_devices() > osdmap.get_max_osd()) { + cerr << me << ": crushmap max_devices " << cw.get_max_devices() + << " > osdmap max_osd " << osdmap.get_max_osd() << std::endl; + exit(1); + } // apply OSDMap::Incremental inc;