int err = ErasureCode::parse(profile, ss);
err |= to_int("k", profile, &k, DEFAULT_K, ss);
err |= to_int("m", profile, &m, DEFAULT_M, ss);
+ err |= sanity_check_k(k, ss);
if (matrixtype == kVandermonde) {
// these are verified safe values evaluated using the
chunk_mapping.clear();
err = -EINVAL;
}
+ err |= sanity_check_k(k, ss);
return err;
}
}
}
+TEST_F(IsaErasureCodeTest, sanity_check_k)
+{
+ ErasureCodeIsaDefault Isa(tcache);
+ ErasureCodeProfile profile;
+ profile["k"] = "1";
+ profile["m"] = "1";
+ ostringstream errors;
+ EXPECT_EQ(-EINVAL, Isa.init(profile, &errors));
+ EXPECT_NE(std::string::npos, errors.str().find("must be >= 2"));
+}
+
bool
DecodeAndVerify(ErasureCodeIsaDefault& Isa, map<int, bufferlist> °raded, set<int> want_to_decode, buffer::ptr* enc, int length)
{
> JerasureTypes;
TYPED_TEST_CASE(ErasureCodeTest, JerasureTypes);
+TYPED_TEST(ErasureCodeTest, sanity_check_k)
+{
+ TypeParam jerasure;
+ ErasureCodeProfile profile;
+ profile["k"] = "1";
+ profile["m"] = "1";
+ profile["packetsize"] = "8";
+ ostringstream errors;
+ EXPECT_EQ(-EINVAL, jerasure.init(profile, &errors));
+ EXPECT_NE(std::string::npos, errors.str().find("must be >= 2"));
+}
+
TYPED_TEST(ErasureCodeTest, encode_decode)
{
const char *per_chunk_alignments[] = { "false", "true" };
grep "$expected" || return 1
}
+function TEST_profile_k_sanity() {
+ local dir=$1
+ local profile=profile-sanity
+
+ run_mon $dir a || return 1
+
+ expect_failure $dir 'k must be a multiple of (k + m) / l' \
+ ./ceph osd erasure-code-profile set $profile \
+ plugin=lrc \
+ l=1 \
+ k=1 \
+ m=1 || return 1
+
+ expect_failure $dir 'k=1 must be >= 2' \
+ ./ceph osd erasure-code-profile set $profile \
+ plugin=isa \
+ k=1 \
+ m=1 || return 1
+
+ expect_failure $dir 'k=1 must be >= 2' \
+ ./ceph osd erasure-code-profile set $profile \
+ plugin=jerasure \
+ k=1 \
+ m=1 || return 1
+}
+
main osd-erasure-code-profile "$@"
# Local Variables: