Skip to content

Commit

Permalink
DAOS-16876 vos: remove DTX record after partial commit - b26
Browse files Browse the repository at this point in the history
Otherwise, the partial committed DTX entry will be re-committed when
reopen the container. Then access related dangling DTX record(s) may
trigger assertion and cause corruption.

Signed-off-by: Fan Yong <[email protected]>
  • Loading branch information
Nasf-Fan committed Feb 7, 2025
1 parent 3f77d9e commit 4841c63
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions src/vos/vos_dtx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* (C) Copyright 2019-2024 Intel Corporation.
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -208,6 +209,7 @@ dtx_act_ent_cleanup(struct vos_container *cont, struct vos_dtx_act_ent *dae,
dae->dae_oid_cnt = 0;
}

DAE_REC_OFF(dae) = UMOFF_NULL;
D_FREE(dae->dae_records);
dae->dae_rec_cap = 0;
DAE_REC_CNT(dae) = 0;
Expand Down Expand Up @@ -683,50 +685,61 @@ dtx_rec_release(struct vos_container *cont, struct vos_dtx_act_ent *dae, bool ab

if (dae->dae_records != NULL) {
D_ASSERT(DAE_REC_CNT(dae) > DTX_INLINE_REC_CNT);
D_ASSERT(!UMOFF_IS_NULL(dae_df->dae_rec_off));

for (i = DAE_REC_CNT(dae) - DTX_INLINE_REC_CNT - 1;
i >= 0; i--) {
rc = do_dtx_rec_release(umm, cont, dae,
dae->dae_records[i], abort);
for (i = DAE_REC_CNT(dae) - DTX_INLINE_REC_CNT - 1; i >= 0; i--) {
rc = do_dtx_rec_release(umm, cont, dae, dae->dae_records[i], abort);
if (rc != 0)
return rc;
}

rc = umem_free(umm, dae_df->dae_rec_off);
if (rc != 0)
return rc;

if (keep_act) {
rc = umem_tx_add_ptr(umm, &dae_df->dae_rec_off, sizeof(dae_df->dae_rec_off));
if (rc != 0)
return rc;

dae_df->dae_rec_off = UMOFF_NULL;
}

count = DTX_INLINE_REC_CNT;
} else {
D_ASSERT(DAE_REC_CNT(dae) <= DTX_INLINE_REC_CNT);

count = DAE_REC_CNT(dae);
}

for (i = count - 1; i >= 0; i--) {
rc = do_dtx_rec_release(umm, cont, dae, DAE_REC_INLINE(dae)[i],
abort);
if (rc != 0)
return rc;
}

if (!UMOFF_IS_NULL(dae_df->dae_rec_off)) {
rc = umem_free(umm, dae_df->dae_rec_off);
rc = do_dtx_rec_release(umm, cont, dae, DAE_REC_INLINE(dae)[i], abort);
if (rc != 0)
return rc;
}

if (keep_act) {
/* When re-commit partial committed DTX, the count can be zero. */
if (dae_df->dae_rec_cnt > 0) {
rc = umem_tx_add_ptr(umm, &dae_df->dae_rec_cnt,
sizeof(dae_df->dae_rec_cnt));
if (rc != 0)
return rc;

dae_df->dae_rec_cnt = 0;
}

/*
* If it is required to keep the active DTX entry, then it must be for partial
* commit. Let's mark it as DTE_PARTIAL_COMMITTED.
*/
if ((DAE_FLAGS(dae) & DTE_PARTIAL_COMMITTED))
return 0;

rc = umem_tx_add_ptr(umm, &dae_df->dae_rec_off, sizeof(dae_df->dae_rec_off));
if (rc != 0)
return rc;

rc = umem_tx_add_ptr(umm, &dae_df->dae_flags, sizeof(dae_df->dae_flags));
if (rc != 0)
return rc;

dae_df->dae_rec_off = UMOFF_NULL;
dae_df->dae_flags |= DTE_PARTIAL_COMMITTED;

return 0;
Expand Down

0 comments on commit 4841c63

Please sign in to comment.