Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAOS-5758 vos: Add garbage collection at container level
Browse files Browse the repository at this point in the history
Since DTX entries can still reference objects that are
being deletect by vos_obj_delete, we need to pass
a container handle when removing them so that any
DTX references can be removed upon deletion.

This change adds a container level garbage collection heap
so we can meet this requirement.   When a container is
destroyed, the collection of that container will move
any outstanding items to the pool level heap.

Signed-off-by: Jeff Olivier <jeffrey.v.olivier@intel.com>
jolivier23 committed Mar 13, 2021
1 parent 225c86a commit 4130002
Showing 7 changed files with 307 additions and 50 deletions.
82 changes: 82 additions & 0 deletions src/vos/tests/vts_gc.c
Original file line number Diff line number Diff line change
@@ -345,6 +345,86 @@ gc_obj_test(void **state)
assert_rc_equal(rc, 0);
}

static int
gc_obj_run_destroy(struct gc_test_args *args)
{
daos_unit_oid_t *oids;
daos_handle_t coh;
daos_handle_t poh;
int i;
int rc;
uuid_t cont_id;

poh = args->gc_ctx.tsc_poh;

uuid_generate(cont_id);

rc = vos_cont_create(poh, cont_id);
if (rc) {
print_error("failed to create container: %s\n",
d_errstr(rc));
return rc;
}

gc_add_stat(STAT_CONT);
rc = vos_cont_open(poh, cont_id, &coh);
if (rc) {
print_error("failed to open container: %s\n",
d_errstr(rc));
return rc;
}

D_ALLOC_ARRAY(oids, obj_per_cont);
if (!oids) {
print_error("failed to allocate oids\n");
return -DER_NOMEM;
}

rc = gc_obj_prepare(args, coh, oids);
if (rc)
goto out;

gc_print_stat();

for (i = 0; i < obj_per_cont; i++) {
rc = vos_obj_delete(coh, oids[i]);
if (rc) {
print_error("failed to delete objects: %s\n",
d_errstr(rc));
goto out;
}
}

rc = vos_cont_close(coh);
if (rc) {
print_error("failed to close container: %s\n",
d_errstr(rc));
return rc;
}

rc = vos_cont_destroy(poh, cont_id);
if (rc) {
print_error("failed to destroy container: %s\n",
d_errstr(rc));
return rc;
}

rc = gc_wait_check(args, true);
out:
D_FREE(oids);
return rc;
}

static void
gc_obj_test_destroy(void **state)
{
struct gc_test_args *args = *state;
int rc;

rc = gc_obj_run_destroy(args);
assert_rc_equal(rc, 0);
}

static void
gc_obj_bio_test(void **state)
{
@@ -484,6 +564,8 @@ static const struct CMUnitTest gc_tests[] = {
gc_obj_bio_test, gc_prepare, NULL},
{ "GC04: container garbage collecting",
gc_cont_test, gc_prepare, NULL},
{ "GC05: container garbage collecting with outstanding objects",
gc_obj_test_destroy, gc_prepare, NULL},
};

int
5 changes: 5 additions & 0 deletions src/vos/vos_container.c
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@ cont_df_rec_alloc(struct btr_instance *tins, d_iov_t *key_iov,
}
dbtree_close(hdl);

gc_init_cont(&tins->ti_umm, cont_df);
args->ca_cont_df = cont_df;
rec->rec_off = offset;
return 0;
@@ -188,6 +189,9 @@ cont_free_internal(struct vos_container *cont)

dbtree_close(cont->vc_btr_hdl);

if (!d_list_empty(&cont->vc_gc_link))
d_list_del(&cont->vc_gc_link);

for (i = 0; i < VOS_IOS_CNT; i++) {
if (cont->vc_hint_ctxt[i])
vea_hint_unload(cont->vc_hint_ctxt[i]);
@@ -368,6 +372,7 @@ vos_cont_open(daos_handle_t poh, uuid_t co_uuid, daos_handle_t *coh)
D_INIT_LIST_HEAD(&cont->vc_dtx_committed_tmp_list);
cont->vc_dtx_committed_count = 0;
cont->vc_dtx_committed_tmp_count = 0;
D_INIT_LIST_HEAD(&cont->vc_gc_link);

/* Cache this btr object ID in container handle */
rc = dbtree_open_inplace_ex(&cont->vc_cont_df->cd_obj_root,
Loading

0 comments on commit 4130002

Please sign in to comment.