Skip to content

Commit

Permalink
DAOS-16211 vos: Avoid race condition with discard (#15370)
Browse files Browse the repository at this point in the history
There is a possible race between aggregation deleting
the object tree and discard working on the same
object tree.  Add a check to avoid this race

Signed-off-by: Jeff Olivier <jeffolivier@google.com>
  • Loading branch information
jolivier23 committed Oct 30, 2024
1 parent bde13c3 commit 62815d8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/vos/vos_obj_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ oi_iter_check_punch(daos_handle_t ih)
{
struct vos_iterator *iter = vos_hdl2iter(ih);
struct vos_oi_iter *oiter = iter2oiter(iter);
struct vos_container *cont = oiter->oit_cont;
struct vos_obj_df *obj;
struct oi_delete_arg del_arg;
daos_unit_oid_t oid;
Expand All @@ -811,10 +812,22 @@ oi_iter_check_punch(daos_handle_t ih)
obj = (struct vos_obj_df *)rec_iov.iov_buf;
oid = obj->vo_id;

if (!vos_ilog_is_punched(vos_cont2hdl(oiter->oit_cont), &obj->vo_ilog, &oiter->oit_epr,
NULL, &oiter->oit_ilog_info))
if (!vos_ilog_is_punched(vos_cont2hdl(cont), &obj->vo_ilog, &oiter->oit_epr, NULL,
&oiter->oit_ilog_info))
return 0;

rc = vos_obj_hold(vos_obj_cache_current(cont->vc_pool->vp_sysdb), cont, oid,
&oiter->oit_epr, iter->it_bound, VOS_OBJ_AGGREGATE | VOS_OBJ_NO_HOLD,
DAOS_INTENT_PURGE, NULL, NULL);
if (rc != 0) {
/** -DER_BUSY means the object is in-use already. We will after a yield in this
* case.
*/
D_CDEBUG(rc == -DER_BUSY, DB_EPC, DLOG_ERR, "Hold check failed for " DF_UOID "\n",
DP_UOID(oid));
return rc;
}

/** Ok, ilog is fully punched, so we can move it to gc heap */
rc = umem_tx_begin(vos_cont2umm(oiter->oit_cont), NULL);
if (rc != 0)
Expand Down

0 comments on commit 62815d8

Please sign in to comment.