Skip to content

Commit

Permalink
DAOS-14788 container: refine task process in pmap_refresh_cb (#13491)
Browse files Browse the repository at this point in the history
should register completion callback before task reinit, or the complete
cb possibly cannot be triggered.
(issue reported by Zhao Zhen <[email protected]>)

Signed-off-by: Xuezhao Liu <[email protected]>
  • Loading branch information
liuxuezhao authored Dec 15, 2023
1 parent d53892d commit dd454a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/container/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,6 @@ pmap_refresh_cb(tse_task_t *task, void *data)
else
delay = 0;

rc = tse_task_reinit_with_delay(task, delay);
if (rc) {
D_ERROR(DF_UUID": pmap_refresh version (%d:%d), resched"
" failed, "DF_RC"\n", DP_UUID(pool->dp_pool),
pm_ver, cb_arg->pra_pm_ver, DP_RC(rc));
goto out;
}

rc = tse_task_register_comp_cb(task, pmap_refresh_cb, cb_arg,
sizeof(*cb_arg));
if (rc) {
Expand All @@ -690,6 +682,15 @@ pmap_refresh_cb(tse_task_t *task, void *data)
D_DEBUG(DB_TRACE, DF_UUID": pmap_refresh version (%d:%d), "
"in %d retry\n", DP_UUID(pool->dp_pool), pm_ver,
cb_arg->pra_pm_ver, cb_arg->pra_retry_nr);

rc = tse_task_reinit_with_delay(task, delay);
if (rc) {
D_ERROR(DF_UUID": pmap_refresh version (%d:%d), resched"
" failed, "DF_RC"\n", DP_UUID(pool->dp_pool),
pm_ver, cb_arg->pra_pm_ver, DP_RC(rc));
goto out;
}

return rc;
}
out:
Expand Down
9 changes: 5 additions & 4 deletions src/include/daos/tse.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,11 @@ tse_task_register_cbs(tse_task_t *task, tse_task_cb_t prep_cb,

/**
* Reinitialize a task and move it into the scheduler's initialize list. The
* task must have a body function to be reinserted into the scheduler. If the
* task is reintialzed in one of its completion CBs, that callback and the ones
* that have already executed will have been removed from the cb list and will
* need to be re-registered by the user after re-insertion.
* task must have a body function to be reinserted into the scheduler.
* Once the task being reinitialized, it possible be executed by other thread
* when it progresses the scheduler. So all accesses to the task must happen before
* the reinit call, for example task dependency/callback registration or task
* argument accessing.
*
* \param task [IN] Task to reinitialize
*
Expand Down

0 comments on commit dd454a9

Please sign in to comment.