]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: disallow crush buckets of type 0
authorSage Weil <sage@inktank.com>
Wed, 5 Mar 2014 21:15:58 +0000 (13:15 -0800)
committerSage Weil <sage@inktank.com>
Wed, 5 Mar 2014 21:15:58 +0000 (13:15 -0800)
Prevent creation of buckets of type 0 ('osd', 'device', etc.), as they
will confusing the mapping algorithm.

Signed-off-by: Sage Weil <sage@inktank.com>
qa/workunits/mon/crush_ops.sh
src/crush/CrushWrapper.h
src/mon/OSDMonitor.cc
src/test/crush/TestCrushWrapper.cc

index d27e2f9dde45ced39aa2e6a06d5177e6935a6169..56a0d232d71248bc352f946fdd6c6fd672804449 100755 (executable)
@@ -29,6 +29,7 @@ ceph osd crush rule rm bar
 expect_false ceph osd crush rule rm replicated_ruleset
 
 # build a simple map
+expect_false ceph osd crush add-bucket foo osd
 ceph osd crush add-bucket foo root
 o1=`ceph osd create`
 o2=`ceph osd create`
index c43a245b20093280121b822b44539970194969ab..3b2e6e6979ac3cc00201fd5b71984c5d2cfbf1d7 100644 (file)
@@ -823,6 +823,8 @@ public:
   /* modifiers */
   int add_bucket(int bucketno, int alg, int hash, int type, int size,
                 int *items, int *weights, int *idout) {
+    if (type == 0)
+      return -EINVAL;
     crush_bucket *b = crush_make_bucket(alg, hash, type, size, items, weights);
     assert(b);
     return crush_add_bucket(crush, bucketno, b, idout);
index 7ad68c4ee15e71a37f45ce068db129fc6fb163e0..0ebc31a704432ed22762e2883e1e40fc50f9c48a 100644 (file)
@@ -3428,6 +3428,11 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m,
       err = -EINVAL;
       goto reply;
     }
+    if (type == 0) {
+      ss << "type '" << typestr << "' is for devices, not buckets";
+      err = -EINVAL;
+      goto reply;
+    }
     int bucketno;
     err = newcrush.add_bucket(0, CRUSH_BUCKET_STRAW,
                                       CRUSH_HASH_DEFAULT, type, 0, NULL,
index 73e0398bc2a70b704670e99e01d17d7c5551a794..e5472a05e1bdf0d1c8819d7b7d6d060321f3389b 100644 (file)
@@ -402,8 +402,9 @@ TEST(CrushWrapper, insert_item) {
   {
     // create an OSD bucket
     int osdno;
-    c->add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_RJENKINS1,
-                 OSD_TYPE, 0, NULL, NULL, &osdno);
+    int r = c->add_bucket(0, CRUSH_BUCKET_STRAW, CRUSH_HASH_RJENKINS1,
+                         10, 0, NULL, NULL, &osdno);
+    ASSERT_EQ(0, r);
     c->set_item_name(osdno, "myosd");
     map<string,string> loc;
     loc["root"] = "default";