]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: refuse to add item >= max_devices
authorSage Weil <sage@newdream.net>
Tue, 23 Aug 2011 19:58:46 +0000 (12:58 -0700)
committerSage Weil <sage@newdream.net>
Tue, 23 Aug 2011 19:58:46 +0000 (12:58 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
src/crush/CrushWrapper.cc

index 796807ac453be1fb86999c58c10bca98f3b7ca3d..413f3926da8e7563425fd04d16cffbc29d457ce5 100644 (file)
@@ -64,7 +64,10 @@ int CrushWrapper::insert_item(int item, int weight, string name,
                                map<string,string>& loc)  // typename -> bucketname
 {
   cout << "insert_item item " << item << " weight " << weight
-         << " name " << name << " loc " << loc << std::endl;
+       << " name " << name << " loc " << loc << std::endl;
+
+  if (item >= get_max_devices())
+    return -ERANGE;
 
   if (name_exists(name.c_str())) {
     cerr << "error: device name '" << name << "' already exists as id "