Skip to content

Commit 447a182

Browse files
Merge pull request ceph#61461 from NitzanMordhai/wip-nitzan-ec-clay-profile-config-wrong-d
erasure-code: clay wrong d calculation
2 parents 4cf3abd + 600fcd3 commit 447a182

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# Ceph CLI commands and validation script for CLAY profile corner cases
4+
5+
# Variables
6+
PROFILE_NAME="test_clay_profile"
7+
8+
expect_false()
9+
{
10+
if "$@"; then
11+
echo "+++++ expected failure, but got success! cmd: $@"
12+
exit 1
13+
else
14+
echo "+++++ expected failure"
15+
echo -e "\n\n"
16+
fi
17+
}
18+
19+
expect_true()
20+
{
21+
if "$@"; then
22+
ceph osd erasure-code-profile rm "$PROFILE_NAME" > /dev/null 2>&1 || true
23+
echo -e "\n\n"
24+
else
25+
echo "+++++ function returned non-zero, we failed"
26+
exit 1
27+
fi
28+
}
29+
30+
ecp_create_test() {
31+
local k=$1
32+
local m=$2
33+
local d=$3
34+
local description=$4
35+
36+
echo "Testing with k=$k, m=$m, d=$d: $description"
37+
ceph osd erasure-code-profile set "$PROFILE_NAME" \
38+
plugin=clay \
39+
k=$k \
40+
m=$m \
41+
d=$d
42+
local result=$?
43+
if [ $result -ne 0 ]; then
44+
echo "Failed to create profile with k=$k, m=$m, d=$d"
45+
fi
46+
return $result
47+
}
48+
49+
# 1. Boundary Values for d
50+
expect_false ecp_create_test 3 2 3 "Lower boundary (should fail)"
51+
expect_true ecp_create_test 3 2 4 "Exact lower bound (should succeed)"
52+
expect_false ecp_create_test 3 2 5 "Exact upper bound (should failed)"
53+
54+
# 2. Invalid d Values
55+
expect_false ecp_create_test 3 2 -1 "Negative d (should fail)"
56+
expect_false ecp_create_test 3 2 0 "Zero d (should fail)"
57+
expect_false ecp_create_test 3 2 10 "Unreasonably large d (should fail)"
58+
59+
# 3. Invalid Total Number of Chunks
60+
expect_false ecp_create_test 250 5 255 "Exceeds total chunk limit (should fail)"
61+
62+
# 4. Valid but Edge Cases
63+
expect_false ecp_create_test 1 1 2 "Minimum viable configuration (should fail)"
64+
expect_false ecp_create_test 253 1 252 "Maximum viable configuration (should fail)"
65+
expect_true ecp_create_test 10 2 11 "Highly imbalanced configuration (should succeed)"
66+
67+
# 5. Invalid Techniques expected to fail
68+
expect_false ceph osd erasure-code-profile set "$PROFILE_NAME" \
69+
plugin=clay \
70+
k=3 \
71+
m=2 \
72+
d=4 \
73+
scalar_mds=isa \
74+
technique=liber8tion
75+
76+
# 6. Mixed Valid/Invalid Configurations
77+
expect_false ecp_create_test 3 2 0 "Invalid d with valid k and m (should fail)"
78+
expect_false ecp_create_test 0 2 3 "Valid d with invalid k (should fail)"
79+
expect_false ecp_create_test 3 0 4 "Valid d with invalid m (should fail)"
80+
81+
82+
expect_true ecp_create_test 10 5 13 "Valid configuration with padding (should succeed)"
83+
expect_false ecp_create_test 250 4 253 "Invalid configuration exceeding chunk limit (should fail)"
84+
expect_true ecp_create_test 12 3 14 "Configuration without padding (should succeed)"

src/erasure-code/clay/ErasureCodeClay.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ int ErasureCodeClay::parse(ErasureCodeProfile &profile,
266266
}
267267
}
268268
}
269-
if ((d < k) || (d > k + m - 1)) {
269+
if ((d < k + 1) || (d > k + m - 1)) {
270270
*ss << "value of d " << d
271-
<< " must be within [ " << k << "," << k+m-1 << "]" << std::endl;
271+
<< " must be within [" << k + 1 << "," << k + m - 1 << "]" << std::endl;
272272
err = -EINVAL;
273273
return err;
274274
}

0 commit comments

Comments
 (0)