summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-05-10 15:19:35 +0000
committerGerrit Code Review <review@openstack.org>2017-05-10 15:19:35 +0000
commit345f1a93a2300b1dc7f8ec8ef0fabd24615d82b5 (patch)
tree6cbbccceea9cfb67ecd1af4b2207bab6a7823b90
parent7c4ef60c9d9e69dd23e43ec59d6c03e139a32723 (diff)
parent842b4a9bd71f0ee6390bf3ace71666a9acc017fd (diff)
Merge "Jerasure: Handle initialization errors correctly"
-rw-r--r--src/backends/jerasure/jerasure_rs_cauchy.c10
-rw-r--r--test/liberasurecode_test.c32
2 files changed, 34 insertions, 8 deletions
diff --git a/src/backends/jerasure/jerasure_rs_cauchy.c b/src/backends/jerasure/jerasure_rs_cauchy.c
index 3a0365a..82d796a 100644
--- a/src/backends/jerasure/jerasure_rs_cauchy.c
+++ b/src/backends/jerasure/jerasure_rs_cauchy.c
@@ -357,17 +357,21 @@ static void * jerasure_rs_cauchy_init(struct ec_backend_args *args,
357 } 357 }
358 desc->bitmatrix = desc->jerasure_matrix_to_bitmatrix(k, m, w, desc->matrix); 358 desc->bitmatrix = desc->jerasure_matrix_to_bitmatrix(k, m, w, desc->matrix);
359 if (NULL == desc->bitmatrix) { 359 if (NULL == desc->bitmatrix) {
360 goto error; 360 goto bitmatrix_error;
361 } 361 }
362 desc->schedule = desc->jerasure_smart_bitmatrix_to_schedule(k, m, w, desc->bitmatrix); 362 desc->schedule = desc->jerasure_smart_bitmatrix_to_schedule(k, m, w, desc->bitmatrix);
363 if (NULL == desc->schedule) { 363 if (NULL == desc->schedule) {
364 goto error; 364 goto schedule_error;
365 } 365 }
366 366
367 return desc; 367 return desc;
368 368
369schedule_error:
370 free(desc->bitmatrix);
371bitmatrix_error:
372 free(desc->matrix);
369error: 373error:
370 free_rs_cauchy_desc(desc); 374 free(desc);
371 return NULL; 375 return NULL;
372} 376}
373 377
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index 16507ec..566bd48 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -1428,8 +1428,7 @@ static void test_decode_with_missing_multi_data_parity(
1428 } 1428 }
1429} 1429}
1430 1430
1431static void test_decode_reconstruct_specific_error_case( 1431static void test_isa_l_rs_vand_decode_reconstruct_specific_error_case()
1432 const ec_backend_id_t be_id, struct ec_args *args)
1433{ 1432{
1434 struct ec_args specific_1010_args = { 1433 struct ec_args specific_1010_args = {
1435 .k = 10, 1434 .k = 10,
@@ -1523,6 +1522,25 @@ static void test_decode_reconstruct_specific_error_case(
1523 free(skips); 1522 free(skips);
1524} 1523}
1525 1524
1525static void test_jerasure_rs_cauchy_init_failure()
1526{
1527 struct ec_args bad_args = {
1528 .k = 10,
1529 .m = 10,
1530 .w = 4,
1531 };
1532 // NB: (k + m) > (1 << w) => too many frags!
1533
1534 int desc = -1;
1535 desc = liberasurecode_instance_create(
1536 EC_BACKEND_JERASURE_RS_CAUCHY, &bad_args);
1537 if (-EBACKENDNOTAVAIL == desc) {
1538 fprintf (stderr, "Backend library not available!\n");
1539 return;
1540 }
1541 assert(-EBACKENDINITERR == desc);
1542}
1543
1526static void test_simple_encode_decode(const ec_backend_id_t be_id, 1544static void test_simple_encode_decode(const ec_backend_id_t be_id,
1527 struct ec_args *args) 1545 struct ec_args *args)
1528{ 1546{
@@ -2003,6 +2021,10 @@ struct testcase testcases[] = {
2003 test_verify_stripe_metadata_frag_idx_invalid, 2021 test_verify_stripe_metadata_frag_idx_invalid,
2004 EC_BACKEND_JERASURE_RS_CAUCHY, CHKSUM_CRC32, 2022 EC_BACKEND_JERASURE_RS_CAUCHY, CHKSUM_CRC32,
2005 .skip = false}, 2023 .skip = false},
2024 {"test_jerasure_rs_cauchy_init_failure",
2025 test_jerasure_rs_cauchy_init_failure,
2026 EC_BACKENDS_MAX, 0,
2027 .skip = false},
2006 // ISA-L rs_vand tests 2028 // ISA-L rs_vand tests
2007 {"create_and_destroy_backend", 2029 {"create_and_destroy_backend",
2008 test_create_and_destroy_backend, 2030 test_create_and_destroy_backend,
@@ -2064,10 +2086,10 @@ struct testcase testcases[] = {
2064 test_verify_stripe_metadata_frag_idx_invalid, 2086 test_verify_stripe_metadata_frag_idx_invalid,
2065 EC_BACKEND_ISA_L_RS_VAND, CHKSUM_CRC32, 2087 EC_BACKEND_ISA_L_RS_VAND, CHKSUM_CRC32,
2066 .skip = false}, 2088 .skip = false},
2067 {"test_isa_l_decode_reconstruct_specific_error_case", 2089 {"test_isa_l_rs_vand_decode_reconstruct_specific_error_case",
2068 test_decode_reconstruct_specific_error_case, 2090 test_isa_l_rs_vand_decode_reconstruct_specific_error_case,
2069 EC_BACKENDS_MAX, 0, // note this test is using ISA-L in hard coded 2091 EC_BACKENDS_MAX, 0, // note this test is using ISA-L in hard coded
2070 .skip = false}, 2092 .skip = false},
2071 // ISA-L rs cauchy tests 2093 // ISA-L rs cauchy tests
2072 {"create_and_destroy_backend", 2094 {"create_and_destroy_backend",
2073 test_create_and_destroy_backend, 2095 test_create_and_destroy_backend,