From dd454a99ed4b52117e72558766d8c8b0f9480933 Mon Sep 17 00:00:00 2001 From: Liu Xuezhao Date: Fri, 15 Dec 2023 09:49:41 +0800 Subject: [PATCH] DAOS-14788 container: refine task process in pmap_refresh_cb (#13491) should register completion callback before task reinit, or the complete cb possibly cannot be triggered. (issue reported by Zhao Zhen ) Signed-off-by: Xuezhao Liu --- src/container/cli.c | 17 +++++++++-------- src/include/daos/tse.h | 9 +++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/container/cli.c b/src/container/cli.c index 13856698082..590f689333b 100644 --- a/src/container/cli.c +++ b/src/container/cli.c @@ -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) { @@ -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: diff --git a/src/include/daos/tse.h b/src/include/daos/tse.h index 537ee1d645c..5ea85c06511 100644 --- a/src/include/daos/tse.h +++ b/src/include/daos/tse.h @@ -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 *