Skip to content

Commit

Permalink
DAOS-14845 vos: avoid TX_RESTART for modification with fixed epoch
Browse files Browse the repository at this point in the history
The ilog_tree_modify() logic should not return -DER_TX_RESTART
for the modification with fixed epoch, such as rebuild, ec_agg,
ec_rep and so on. Because related modification must has either
been committed or become committble under such case. Returning
-DER_ALREADY to make related modification to go ahead.

Required-githooks: true

Signed-off-by: Fan Yong <[email protected]>
  • Loading branch information
Nasf-Fan committed Jan 10, 2024
1 parent 1ec01fb commit 77f2a8a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
11 changes: 9 additions & 2 deletions src/vos/ilog.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019-2023 Intel Corporation.
* (C) Copyright 2019-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -81,6 +81,8 @@ struct ilog_context {
bool ic_in_txn;
/** version needs incrementing */
bool ic_ver_inc;
/** For operation with fixed epoch (rebuild, ec_agg, ec_rep, etc.) */
bool ic_fixed_epoch;
};

D_CASSERT(sizeof(struct ilog_id) == sizeof(struct ilog_tree));
Expand Down Expand Up @@ -401,7 +403,7 @@ ilog_create(struct umem_instance *umm, struct ilog_df *root)

int
ilog_open(struct umem_instance *umm, struct ilog_df *root,
const struct ilog_desc_cbs *cbs, daos_handle_t *loh)
const struct ilog_desc_cbs *cbs, bool fixed_epoch, daos_handle_t *loh)
{
struct ilog_context *lctx;
int rc;
Expand All @@ -412,6 +414,7 @@ ilog_open(struct umem_instance *umm, struct ilog_df *root,
if (rc != 0)
return rc;

lctx->ic_fixed_epoch = fixed_epoch;
*loh = ilog_lctx2hdl(lctx);

return 0;
Expand Down Expand Up @@ -575,6 +578,10 @@ check_equal(struct ilog_context *lctx, struct ilog_id *id_out, const struct ilog
return 0;

if (update) {
/* For operation with fixed epoch, related ilog must be committed or committble. */
if (lctx->ic_fixed_epoch)
return -DER_ALREADY;

rc = ilog_is_same_tx(lctx, id_out, is_equal);
if (rc != 0)
return rc;
Expand Down
7 changes: 4 additions & 3 deletions src/vos/ilog.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019-2023 Intel Corporation.
* (C) Copyright 2019-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -88,14 +88,15 @@ ilog_create(struct umem_instance *umm, struct ilog_df *root);
*
* \param umm[IN] The umem instance
* \param root[IN] A pointer to the allocated root
* \param cbs[in] Incarnation log transaction log callbacks
* \param cbs[IN] Incarnation log transaction log callbacks
* \param fixed_epoch[IN] It is for operation with fixed epoch or not
* \param loh[OUT] Returned open log handle
*
* \return 0 on success, error code on failure
*/
int
ilog_open(struct umem_instance *umm, struct ilog_df *root,
const struct ilog_desc_cbs *cbs, daos_handle_t *loh);
const struct ilog_desc_cbs *cbs, bool fixed_epoch, daos_handle_t *loh);

/** Close an open incarnation log handle
*
Expand Down
12 changes: 6 additions & 6 deletions src/vos/tests/vts_ilog.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019-2023 Intel Corporation.
* (C) Copyright 2019-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -504,7 +504,7 @@ ilog_test_update(void **state)
rc = ilog_create(umm, ilog);
LOG_FAIL(rc, 0, "Failed to create a new incarnation log\n");

rc = ilog_open(umm, ilog, &ilog_callbacks, &loh);
rc = ilog_open(umm, ilog, &ilog_callbacks, false, &loh);
LOG_FAIL(rc, 0, "Failed to open incarnation log\n");

version_cache_fetch(&version_cache, loh, true);
Expand Down Expand Up @@ -653,7 +653,7 @@ ilog_test_abort(void **state)
rc = ilog_create(umm, ilog);
LOG_FAIL(rc, 0, "Failed to create a new incarnation log\n");

rc = ilog_open(umm, ilog, &ilog_callbacks, &loh);
rc = ilog_open(umm, ilog, &ilog_callbacks, false, &loh);
LOG_FAIL(rc, 0, "Failed to open new incarnation log\n");
version_cache_fetch(&version_cache, loh, true);

Expand Down Expand Up @@ -765,7 +765,7 @@ ilog_test_persist(void **state)
rc = ilog_create(umm, ilog);
LOG_FAIL(rc, 0, "Failed to create a new incarnation log\n");

rc = ilog_open(umm, ilog, &ilog_callbacks, &loh);
rc = ilog_open(umm, ilog, &ilog_callbacks, false, &loh);
LOG_FAIL(rc, 0, "Failed to open incarnation log\n");
version_cache_fetch(&version_cache, loh, true);

Expand Down Expand Up @@ -849,7 +849,7 @@ ilog_test_aggregate(void **state)
rc = ilog_create(umm, ilog);
LOG_FAIL(rc, 0, "Failed to create a new incarnation log\n");

rc = ilog_open(umm, ilog, &ilog_callbacks, &loh);
rc = ilog_open(umm, ilog, &ilog_callbacks, false, &loh);
LOG_FAIL(rc, 0, "Failed to open incarnation log\n");

id.id_epoch = 1;
Expand Down Expand Up @@ -965,7 +965,7 @@ ilog_test_discard(void **state)
rc = ilog_create(umm, ilog);
LOG_FAIL(rc, 0, "Failed to create a new incarnation log\n");

rc = ilog_open(umm, ilog, &ilog_callbacks, &loh);
rc = ilog_open(umm, ilog, &ilog_callbacks, false, &loh);
LOG_FAIL(rc, 0, "Failed to open incarnation log\n");

id.id_epoch = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/vos/vos_dtx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019-2023 Intel Corporation.
* (C) Copyright 2019-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -529,7 +529,7 @@ dtx_ilog_rec_release(struct umem_instance *umm, struct vos_container *cont,
ilog = umem_off2ptr(umm, umem_off2offset(rec));

vos_ilog_desc_cbs_init(&cbs, vos_cont2hdl(cont));
rc = ilog_open(umm, ilog, &cbs, &loh);
rc = ilog_open(umm, ilog, &cbs, false, &loh);
if (rc != 0)
return rc;

Expand Down
6 changes: 3 additions & 3 deletions src/vos/vos_ilog.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019-2023 Intel Corporation.
* (C) Copyright 2019-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -428,7 +428,7 @@ int vos_ilog_update_(struct vos_container *cont, struct ilog_df *ilog,
}

vos_ilog_desc_cbs_init(&cbs, vos_cont2hdl(cont));
rc = ilog_open(vos_cont2umm(cont), ilog, &cbs, &loh);
rc = ilog_open(vos_cont2umm(cont), ilog, &cbs, dth == NULL, &loh);
if (rc != 0) {
D_ERROR("Could not open incarnation log: "DF_RC"\n", DP_RC(rc));
return rc;
Expand Down Expand Up @@ -525,7 +525,7 @@ vos_ilog_punch_(struct vos_container *cont, struct ilog_df *ilog,

punch_log:
vos_ilog_desc_cbs_init(&cbs, vos_cont2hdl(cont));
rc = ilog_open(vos_cont2umm(cont), ilog, &cbs, &loh);
rc = ilog_open(vos_cont2umm(cont), ilog, &cbs, dth == NULL, &loh);
if (rc != 0) {
D_ERROR("Could not open incarnation log: "DF_RC"\n", DP_RC(rc));
return rc;
Expand Down
4 changes: 2 additions & 2 deletions src/vos/vos_obj_index.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2023 Intel Corporation.
* (C) Copyright 2016-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -288,7 +288,7 @@ vos_oi_find_alloc(struct vos_container *cont, daos_unit_oid_t oid,
if (!log)
goto skip_log;
vos_ilog_desc_cbs_init(&cbs, vos_cont2hdl(cont));
rc = ilog_open(vos_cont2umm(cont), &obj->vo_ilog, &cbs, &loh);
rc = ilog_open(vos_cont2umm(cont), &obj->vo_ilog, &cbs, dth == NULL, &loh);
if (rc != 0)
return rc;

Expand Down

0 comments on commit 77f2a8a

Please sign in to comment.