]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_rbd: make sure stripe_unit is not larger than object size
authorJosh Durgin <josh.durgin@inktank.com>
Thu, 16 May 2013 22:19:46 +0000 (15:19 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Thu, 16 May 2013 22:19:46 +0000 (15:19 -0700)
Test a few other cases too.

backport: cuttlefish, bobtail
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/cls/rbd/cls_rbd.cc
src/test/cls_rbd/test_cls_rbd.cc

index 92349ea9304ddc58d2d1a231b3ee442b9eaa582d..c09f1ee604a71e2a1717feea7ee09d16757b62f4 100644 (file)
@@ -678,7 +678,7 @@ int set_stripe_unit_count(cls_method_context_t hctx, bufferlist *in, bufferlist
     CLS_ERR("failed to read the order off of disk: %s", strerror(r));
     return r;
   }
-  if ((1ull << order) % stripe_unit) {
+  if ((1ull << order) % stripe_unit || stripe_unit > (1ull << order)) {
     CLS_ERR("stripe unit %llu is not a factor of the object size %llu",
             (unsigned long long)stripe_unit, 1ull << order);
     return -EINVAL;
index 6308980f55febbfbe46e59342d7d291844b3bdc0..c147b43f4cbf468ef0f98d7b4d369cca4efe75b4 100644 (file)
@@ -906,6 +906,15 @@ TEST(cls_rbd, stripingv2)
   ASSERT_EQ(8192ull, su);
   ASSERT_EQ(456ull, sc);
 
+  // su must not be larger than an object
+  ASSERT_EQ(-EINVAL, set_stripe_unit_count(&ioctx, "bar", 1 << 23, 1));
+  // su must be a factor of object size
+  ASSERT_EQ(-EINVAL, set_stripe_unit_count(&ioctx, "bar", 511, 1));
+  // su and sc must be non-zero
+  ASSERT_EQ(-EINVAL, set_stripe_unit_count(&ioctx, "bar", 0, 1));
+  ASSERT_EQ(-EINVAL, set_stripe_unit_count(&ioctx, "bar", 1, 0));
+  ASSERT_EQ(-EINVAL, set_stripe_unit_count(&ioctx, "bar", 0, 0));
+
   ioctx.close();
   ASSERT_EQ(0, destroy_one_pool_pp(pool_name, rados));
 }