From a4f7468cbcba99e99532dd22958b004908bfc115 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Mon, 22 Sep 2025 11:05:04 +0800 Subject: [PATCH] DAOS-17977 vos: new parameter acts for sys_db_trav_cb_t db_traverse() calls vos_iterate() to traverse the VOS_ITER_AKEY for related sysdb table. For each found item, it handles it via sys_db_trav_cb_t() that may remove such item from related sysdb table, such as for some CHK cleanup use case. If that happened, We will notify vos_iterate() logic via set "VOS_ITER_CB_DELETE" flag in the "acts" parameter; otherwise some item(s) in related sysdb table may be skipped in subsequent iteration. For CHK use case, that may affect new check instance to reset automatically. Test-tag: cat_recov Signed-off-by: Fan Yong --- src/bio/smd/smd_device.c | 2 +- src/bio/smd/smd_pool.c | 3 ++- src/bio/smd/tests/smd_ut.c | 3 ++- src/chk/chk_common.c | 11 +++++++---- src/chk/chk_internal.h | 7 ++++--- src/include/daos/sys_db.h | 5 +++-- src/tests/ftest/recovery/cat_recov_core.yaml | 2 +- src/vos/sys_db.c | 4 ++-- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/bio/smd/smd_device.c b/src/bio/smd/smd_device.c index 7993d538b4c..165d2dbf92a 100644 --- a/src/bio/smd/smd_device.c +++ b/src/bio/smd/smd_device.c @@ -219,7 +219,7 @@ smd_dev_get_by_tgt(uint32_t tgt_id, enum smd_dev_type st, struct smd_dev_info ** } static int -smd_dev_list_cb(struct sys_db *db, char *table, d_iov_t *key, void *args) +smd_dev_list_cb(struct sys_db *db, char *table, d_iov_t *key, void *args, unsigned *acts) { struct smd_trav_data *td = args; struct smd_dev_info *info; diff --git a/src/bio/smd/smd_pool.c b/src/bio/smd/smd_pool.c index 9b594212ba0..169e548b1c8 100644 --- a/src/bio/smd/smd_pool.c +++ b/src/bio/smd/smd_pool.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2018-2025 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -423,7 +424,7 @@ smd_rdb_get_blob_sz(uuid_t pool_id, uint64_t *blob_sz) } static int -smd_pool_list_cb(struct sys_db *db, char *table, d_iov_t *key, void *args) +smd_pool_list_cb(struct sys_db *db, char *table, d_iov_t *key, void *args, unsigned *acts) { struct smd_trav_data *td = args; struct smd_pool_info *info; diff --git a/src/bio/smd/tests/smd_ut.c b/src/bio/smd/tests/smd_ut.c index b7f264035d8..4f60bcef1a2 100644 --- a/src/bio/smd/tests/smd_ut.c +++ b/src/bio/smd/tests/smd_ut.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2018-2025 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -162,7 +163,7 @@ db_traverse(struct sys_db *db, char *table, sys_db_trav_cb_t cb, void *args) d_iov_t key; d_iov_set(&key, chain->uc_key, chain->uc_key_size); - cb(db, table, &key, args); + cb(db, table, &key, args, NULL); } return 0; } diff --git a/src/chk/chk_common.c b/src/chk/chk_common.c index 745d26a521f..0e270926e79 100644 --- a/src/chk/chk_common.c +++ b/src/chk/chk_common.c @@ -538,7 +538,7 @@ chk_pool_stop_all(struct chk_instance *ins, uint32_t status, int *ret) } int -chk_pools_pause_cb(struct sys_db *db, char *table, d_iov_t *key, void *args) +chk_pools_pause_cb(struct sys_db *db, char *table, d_iov_t *key, void *args, unsigned *acts) { struct chk_traverse_pools_args *ctpa = args; char *uuid_str = key->iov_buf; @@ -569,7 +569,7 @@ chk_pools_pause_cb(struct sys_db *db, char *table, d_iov_t *key, void *args) } int -chk_pools_cleanup_cb(struct sys_db *db, char *table, d_iov_t *key, void *args) +chk_pools_cleanup_cb(struct sys_db *db, char *table, d_iov_t *key, void *args, unsigned *acts) { struct chk_traverse_pools_args *ctpa = args; char *uuid_str = key->iov_buf; @@ -581,8 +581,11 @@ chk_pools_cleanup_cb(struct sys_db *db, char *table, d_iov_t *key, void *args) D_GOTO(out, rc = 0); rc = chk_bk_fetch_pool(&cbk, uuid_str); - if (rc == 0) + if (rc == 0) { rc = chk_bk_delete_pool(uuid_str); + if (rc == 0) + *acts |= VOS_ITER_CB_DELETE; + } out: return rc == -DER_NONEXIST ? 0 : rc; @@ -711,7 +714,7 @@ chk_pools_load_list(struct chk_instance *ins, uint64_t gen, uint32_t flags, } int -chk_pools_load_from_db(struct sys_db *db, char *table, d_iov_t *key, void *args) +chk_pools_load_from_db(struct sys_db *db, char *table, d_iov_t *key, void *args, unsigned *acts) { struct chk_traverse_pools_args *ctpa = args; struct chk_instance *ins = ctpa->ctpa_ins; diff --git a/src/chk/chk_internal.h b/src/chk/chk_internal.h index 2fd44ff623a..798154b2b2a 100644 --- a/src/chk/chk_internal.h +++ b/src/chk/chk_internal.h @@ -727,16 +727,17 @@ void chk_pool_stop_one(struct chk_instance *ins, uuid_t uuid, uint32_t status, u void chk_pool_stop_all(struct chk_instance *ins, uint32_t status, int *ret); -int chk_pools_pause_cb(struct sys_db *db, char *table, d_iov_t *key, void *args); +int chk_pools_pause_cb(struct sys_db *db, char *table, d_iov_t *key, void *args, unsigned *acts); -int chk_pools_cleanup_cb(struct sys_db *db, char *table, d_iov_t *key, void *args); +int chk_pools_cleanup_cb(struct sys_db *db, char *table, d_iov_t *key, void *args, unsigned *acts); int chk_pool_start_one(struct chk_instance *ins, uuid_t uuid, uint64_t gen); int chk_pools_load_list(struct chk_instance *ins, uint64_t gen, uint32_t flags, int pool_nr, uuid_t pools[], uint32_t *phase); -int chk_pools_load_from_db(struct sys_db *db, char *table, d_iov_t *key, void *args); +int chk_pools_load_from_db(struct sys_db *db, char *table, d_iov_t *key, void *args, + unsigned *acts); int chk_pools_update_bk(struct chk_instance *ins, uint32_t phase); diff --git a/src/include/daos/sys_db.h b/src/include/daos/sys_db.h index 850e9c4203a..91d85e735ab 100644 --- a/src/include/daos/sys_db.h +++ b/src/include/daos/sys_db.h @@ -1,5 +1,6 @@ /** * (C) Copyright 2022 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -12,8 +13,8 @@ #include struct sys_db; -typedef int (*sys_db_trav_cb_t)(struct sys_db *db, char *table, d_iov_t *key, - void *args); +typedef int (*sys_db_trav_cb_t)(struct sys_db *db, char *table, d_iov_t *key, void *args, + unsigned *acts); #define SYS_DB_NAME_SZ 32 diff --git a/src/tests/ftest/recovery/cat_recov_core.yaml b/src/tests/ftest/recovery/cat_recov_core.yaml index 6cba4c6caf3..23200a8b403 100644 --- a/src/tests/ftest/recovery/cat_recov_core.yaml +++ b/src/tests/ftest/recovery/cat_recov_core.yaml @@ -1,6 +1,6 @@ hosts: test_servers: 4 -timeout: 5400 +timeout: 5700 server_config: name: daos_server engines_per_host: 2 diff --git a/src/vos/sys_db.c b/src/vos/sys_db.c index afac65f2879..0675de420f2 100644 --- a/src/vos/sys_db.c +++ b/src/vos/sys_db.c @@ -1,5 +1,6 @@ /** * (C) Copyright 2020-2023 Intel Corporation. + * (C) Copyright 2025 Hewlett Packard Enterprise Development LP * * SPDX-License-Identifier: BSD-2-Clause-Patent */ @@ -278,8 +279,7 @@ db_trav_cb(daos_handle_t ih, vos_iter_entry_t *entry, vos_iter_type_t type, { struct db_trav_args *ta = data; - return ta->ta_cb(ta->ta_db, ta->ta_table, &entry->ie_key, - ta->ta_cb_args); + return ta->ta_cb(ta->ta_db, ta->ta_table, &entry->ie_key, ta->ta_cb_args, acts); } static int