Skip to content

Commit

Permalink
DAOS-15391 pool: destroy container during reintegration discard (#13958
Browse files Browse the repository at this point in the history
…) (#14542)

Destroy the container in reintegration discard phase,
otherwise the orphan container might be left after reintegration
and causing trouble in reclaim phase.

Signed-off-by: Di Wang <di.wang@intel.com>
Co-authored-by: wangdi <di.wang@intel.com>
  • Loading branch information
NiuYawei and wangdi authored Jun 14, 2024
1 parent b0cfa63 commit 9aa17e4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/container/srv_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ cont_destroy_wait(struct ds_pool_child *child, uuid_t co_uuid)
* Called via dss_collective() to destroy the ds_cont object as well as the vos
* container.
*/
static int
int
cont_child_destroy_one(void *vin)
{
struct dsm_tls *tls = dsm_tls_get();
Expand Down Expand Up @@ -1260,6 +1260,19 @@ cont_child_destroy_one(void *vin)
return rc;
}

int
ds_cont_child_destroy(uuid_t pool_uuid, uuid_t cont_uuid)
{
struct cont_tgt_destroy_in destroy_in;
int rc;

uuid_copy(destroy_in.tdi_pool_uuid, pool_uuid);
uuid_copy(destroy_in.tdi_uuid, cont_uuid);
rc = cont_child_destroy_one(&destroy_in);

return rc;
}

int
ds_cont_tgt_destroy(uuid_t pool_uuid, uuid_t cont_uuid)
{
Expand Down
3 changes: 3 additions & 0 deletions src/include/daos_srv/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ void ds_cont_child_stop_all(struct ds_pool_child *pool_child);

int ds_cont_child_lookup(uuid_t pool_uuid, uuid_t cont_uuid,
struct ds_cont_child **ds_cont);
int
ds_cont_child_destroy(uuid_t pool_uuid, uuid_t cont_uuid);

void
ds_cont_child_reset_ec_agg_eph_all(struct ds_pool_child *pool_child);
/** initialize a csummer based on container properties. Will retrieve the
Expand Down
2 changes: 2 additions & 0 deletions src/pool/srv_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,8 @@ cont_discard_cb(daos_handle_t ih, vos_iter_entry_t *entry,

put:
ds_cont_child_put(cont);
if (rc == 0)
rc = ds_cont_child_destroy(arg->tgt_discard->pool_uuid, entry->ie_couuid);
return rc;
}

Expand Down
31 changes: 31 additions & 0 deletions src/tests/suite/daos_rebuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,34 @@ rebuild_delay_and_extend(void **state)
rebuild_io_verify(arg, update_oids, OBJ_NR);
}

static void
rebuild_cont_destroy_and_reintegrate(void **state)
{
test_arg_t *arg = *state;
daos_obj_id_t oids[OBJ_NR];
int rc;
int i;

if (!test_runable(arg, 6))
return;

for (i = 0; i < OBJ_NR; i++) {
oids[i] = daos_test_oid_gen(arg->coh, DAOS_OC_R3S_SPEC_RANK, 0, 0, arg->myrank);
oids[i] = dts_oid_set_rank(oids[i], 5);
}

rebuild_io(arg, oids, OBJ_NR);
rebuild_single_pool_rank(arg, 5, true);

rc = daos_cont_close(arg->coh, NULL);
assert_rc_equal(rc, 0);
arg->coh = DAOS_HDL_INVAL;

daos_cont_destroy(arg->pool.poh, arg->co_str, 0 /* force */, NULL /* ev */);
uuid_clear(arg->co_uuid);
reintegrate_single_pool_rank(arg, 5, true);
}

/** create a new pool/container for each test */
static const struct CMUnitTest rebuild_tests[] = {
{"REBUILD0: drop rebuild scan reply",
Expand Down Expand Up @@ -1623,6 +1651,9 @@ static const struct CMUnitTest rebuild_tests[] = {
rebuild_delay_and_reintegrate, rebuild_sub_setup, rebuild_sub_teardown},
{"REBUILD34: delay rebuild and extend",
rebuild_delay_and_extend, rebuild_sub_6nodes_rf1_setup, rebuild_sub_teardown},
{"REBUILD35: destroy container then reintegrate",
rebuild_cont_destroy_and_reintegrate, rebuild_sub_6nodes_rf1_setup,
rebuild_sub_teardown},
};

/* TODO: Enable aggregation once stable view rebuild is done. */
Expand Down

0 comments on commit 9aa17e4

Please sign in to comment.