Skip to content

Commit 551f1c5

Browse files
committed
DAOS-18385 mgmt: new daos_fail_loc to simulate orphan pool shard
When create pool, if set daos_fail_loc as DAOS_CHK_ORPHAN_POOL_SHARD on server, then will generate orpahn pool shard on the specified rank via daos_fail_value. We can use that to simulate inconsistency for CR related test. Signed-off-by: Fan Yong <[email protected]>
1 parent ac24ca6 commit 551f1c5

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

src/include/daos/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* (C) Copyright 2015-2024 Intel Corporation.
3-
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
3+
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
@@ -927,6 +927,7 @@ enum {
927927
#define DAOS_CHK_FAIL_REPORT_POOL2 (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xb8)
928928
#define DAOS_CHK_ENGINE_DEATH (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xb9)
929929
#define DAOS_CHK_VERIFY_CONT_SHARDS (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xba)
930+
#define DAOS_CHK_ORPHAN_POOL_SHARD (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xbb)
930931

931932
#define DAOS_MGMT_FAIL_CREATE_QUERY (DAOS_FAIL_UNIT_TEST_GROUP_LOC | 0xe0)
932933

src/mgmt/srv_pool.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* (C) Copyright 2016-2024 Intel Corporation.
3-
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
3+
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
@@ -154,7 +154,7 @@ ds_mgmt_tgt_pool_create_ranks(uuid_t pool_uuid, d_rank_list_t *rank_list, size_t
154154
}
155155

156156
static int
157-
ds_mgmt_pool_svc_create(uuid_t pool_uuid, int ntargets, const char *group, d_rank_list_t *ranks,
157+
ds_mgmt_pool_svc_create(uuid_t pool_uuid, const char *group, d_rank_list_t *ranks,
158158
daos_prop_t *prop, d_rank_list_t **svc_list, size_t domains_nr,
159159
uint32_t *domains)
160160
{
@@ -170,10 +170,11 @@ ds_mgmt_create_pool(uuid_t pool_uuid, const char *group, d_rank_list_t *targets,
170170
size_t nvme_size, size_t meta_size, daos_prop_t *prop, d_rank_list_t **svcp,
171171
int domains_nr, uint32_t *domains)
172172
{
173-
d_rank_list_t *pg_ranks = NULL;
174-
d_rank_list_t *pg_targets = NULL;
175-
int rc;
176-
int rc_cleanup;
173+
d_rank_list_t *pg_ranks = NULL;
174+
d_rank_list_t *pg_targets = NULL;
175+
d_rank_list_t *dummy = NULL;
176+
int rc;
177+
int rc_cleanup;
177178

178179
D_DEBUG(DB_MGMT, DF_UUID ": create scm/meta/nvme sizes %ld/%ld/%ld\n", DP_UUID(pool_uuid),
179180
scm_size, meta_size, nvme_size);
@@ -213,16 +214,33 @@ ds_mgmt_create_pool(uuid_t pool_uuid, const char *group, d_rank_list_t *targets,
213214
D_GOTO(out, rc = -DER_OOG);
214215
}
215216

216-
rc = ds_mgmt_tgt_pool_create_ranks(pool_uuid, targets, scm_size, nvme_size, meta_size);
217+
/* Extend the targets list to simulate orphan pool shard. */
218+
if (DAOS_FAIL_CHECK(DAOS_CHK_ORPHAN_POOL_SHARD)) {
219+
d_rank_t rank;
220+
int i;
221+
222+
rank = daos_fail_value_get();
223+
if (!d_rank_in_rank_list(targets, rank)) {
224+
dummy = d_rank_list_alloc(targets->rl_nr + 1);
225+
D_ASSERT(dummy != NULL);
226+
227+
for (i = 0; i < targets->rl_nr; i++)
228+
dummy->rl_ranks[i] = targets->rl_ranks[i];
229+
dummy->rl_ranks[targets->rl_nr] = rank;
230+
}
231+
}
232+
233+
rc = ds_mgmt_tgt_pool_create_ranks(pool_uuid, dummy != NULL ? dummy : targets, scm_size,
234+
nvme_size, meta_size);
217235
if (rc != 0) {
218236
DL_ERROR(rc, DF_UUID ": creating pool on ranks failed", DP_UUID(pool_uuid));
219237
goto out_ranks;
220238
}
221239

222-
D_INFO(DF_UUID": creating targets on ranks succeeded\n", DP_UUID(pool_uuid));
240+
D_INFO(DF_UUID ": creating targets on %d ranks succeeded\n", DP_UUID(pool_uuid),
241+
dummy != NULL ? dummy->rl_nr : targets->rl_nr);
223242

224-
rc = ds_mgmt_pool_svc_create(pool_uuid, targets->rl_nr, group, targets, prop, svcp,
225-
domains_nr, domains);
243+
rc = ds_mgmt_pool_svc_create(pool_uuid, group, targets, prop, svcp, domains_nr, domains);
226244
if (rc) {
227245
D_ERROR("create pool "DF_UUID" svc failed: rc "DF_RC"\n",
228246
DP_UUID(pool_uuid), DP_RC(rc));
@@ -233,7 +251,8 @@ ds_mgmt_create_pool(uuid_t pool_uuid, const char *group, d_rank_list_t *targets,
233251
* round of RPCs.
234252
*/
235253
out_ranks:
236-
rc_cleanup = ds_mgmt_tgt_pool_destroy_ranks(pool_uuid, targets);
254+
rc_cleanup =
255+
ds_mgmt_tgt_pool_destroy_ranks(pool_uuid, dummy != NULL ? dummy : targets);
237256
if (rc_cleanup)
238257
D_ERROR(DF_UUID": failed to clean up failed pool: "DF_RC"\n",
239258
DP_UUID(pool_uuid), DP_RC(rc_cleanup));
@@ -247,6 +266,7 @@ ds_mgmt_create_pool(uuid_t pool_uuid, const char *group, d_rank_list_t *targets,
247266
out:
248267
d_rank_list_free(pg_targets);
249268
d_rank_list_free(pg_ranks);
269+
d_rank_list_free(dummy);
250270
D_DEBUG(DB_MGMT, "create pool "DF_UUID": "DF_RC"\n", DP_UUID(pool_uuid),
251271
DP_RC(rc));
252272
return rc;

0 commit comments

Comments
 (0)