diff options
author | Josh Durgin <josh.durgin@inktank.com> | 2013-05-16 15:19:46 -0700 |
---|---|---|
committer | Josh Durgin <josh.durgin@inktank.com> | 2013-05-16 15:36:56 -0700 |
commit | 82a16c32a37dc46e3019cedc2a5407ae34f806e2 (patch) | |
tree | f8e15ac212cb290ecadb243800da00319dd092c7 | |
parent | e0de00897468a434e94790a86fc812b77a59614c (diff) | |
download | ceph-82a16c32a37dc46e3019cedc2a5407ae34f806e2.tar.gz |
cls_rbd: make sure stripe_unit is not larger than object size
Test a few other cases too.
backport: cuttlefish, bobtail
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
(cherry picked from commit 810306a2a76eec1c232fd28ec9c351e827fa3031)
-rw-r--r-- | src/cls/rbd/cls_rbd.cc | 5 | ||||
-rw-r--r-- | src/test/cls_rbd/test_cls_rbd.cc | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index ad3402e17ba..2122ac1fd4d 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -675,8 +675,9 @@ 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) { - CLS_ERR("stripe unit %lld is not a factor of the object size %lld", stripe_unit, 1ull << order); + 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; } diff --git a/src/test/cls_rbd/test_cls_rbd.cc b/src/test/cls_rbd/test_cls_rbd.cc index 6308980f55f..c147b43f4cb 100644 --- a/src/test/cls_rbd/test_cls_rbd.cc +++ b/src/test/cls_rbd/test_cls_rbd.cc @@ -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)); } |