Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/common/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4613,9 +4613,9 @@ btr_class_feats_init(unsigned int tree_class, uint64_t *tree_feats, struct btr_c

#define TREE_CLASS_STR "Tree class... "
#define TREE_FEATURES_STR "Tree features... "
#define INVALID_CLASS_FMT "Invalid class id: %d\n"
#define UNREGISTERED_CLASS_FMT "Unregistered class id %d\n"
#define UNSUPPORTED_FEATURES_FMT "Unsupported features " DF_X64 "/" DF_X64 "\n"
#define INVALID_CLASS_FMT "Invalid class id: %d"
#define UNREGISTERED_CLASS_FMT "Unregistered class id %d"
#define UNSUPPORTED_FEATURES_FMT "Unsupported features " DF_X64 "/" DF_X64
#define OK_STR "ok.\n"

/**
Expand Down Expand Up @@ -4654,14 +4654,14 @@ btr_class_init(umem_off_t root_off, struct btr_root *root, unsigned int tree_cla
CK_PRINTF(ck, TREE_CLASS_STR);
if (tree_class >= BTR_TYPE_MAX || DAOS_FAIL_CHECK(DAOS_FAULT_BTREE_OPEN_INV_CLASS)) {
CK_APPENDFL_ERR(ck, INVALID_CLASS_FMT, tree_class);
D_DEBUG(DB_TRACE, INVALID_CLASS_FMT, tree_class);
D_DEBUG(DB_TRACE, INVALID_CLASS_FMT "\n", tree_class);
return -DER_INVAL;
}

tc = &btr_class_registered[tree_class];
if (tc->tc_ops == NULL || DAOS_FAIL_CHECK(DAOS_FAULT_BTREE_OPEN_UNREG_CLASS)) {
CK_APPENDFL_ERR(ck, UNREGISTERED_CLASS_FMT, tree_class);
D_DEBUG(DB_TRACE, UNREGISTERED_CLASS_FMT, tree_class);
D_DEBUG(DB_TRACE, UNREGISTERED_CLASS_FMT "\n", tree_class);
return -DER_NONEXIST;
}
CK_APPENDL_OK(ck);
Expand All @@ -4670,7 +4670,7 @@ btr_class_init(umem_off_t root_off, struct btr_root *root, unsigned int tree_cla
rc = btr_class_feats_init(tree_class, tree_feats, tc);
if (rc != DER_SUCCESS) {
CK_APPENDFL_ERR(ck, UNSUPPORTED_FEATURES_FMT, *tree_feats, tc->tc_feats);
D_ERROR(UNSUPPORTED_FEATURES_FMT, *tree_feats, tc->tc_feats);
D_ERROR(UNSUPPORTED_FEATURES_FMT "\n", *tree_feats, tc->tc_feats);
return rc;
}
CK_APPENDL_OK(ck);
Expand Down
14 changes: 13 additions & 1 deletion src/include/daos/checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ ck_common_printf(struct checker *ck, const char *fmt, ...)
++(ck)->ck_status.errors_num; \
}

#define CK_RC_SET(ck, rc) \
if (IS_CHECKER(ck)) { \
if ((ck)->ck_status.rc == DER_SUCCESS) \
(ck)->ck_status.rc = (rc); \
}

#define CK_APPENDFL_ERR(ck, fmt, ...) \
do { \
CK_PRINTF_WO_PREFIX(ck, CHECKER_ERROR_INFIX fmt "\n", ##__VA_ARGS__); \
Expand Down Expand Up @@ -169,10 +175,16 @@ ck_common_printf(struct checker *ck, const char *fmt, ...)

#define CK_PRINTF_ERR(ck, fmt, ...) \
do { \
CK_PRINTF(ck, fmt, ##__VA_ARGS__); \
CK_PRINTF(ck, CHECKER_ERROR_INFIX fmt, ##__VA_ARGS__); \
CK_ERR_NUM_INC(ck); \
} while (0)

#define CK_PRINTF_WARN(ck, fmt, ...) \
do { \
CK_PRINTF(ck, CHECKER_WARNING_INFIX fmt, ##__VA_ARGS__); \
CK_WARN_NUM_INC(ck); \
} while (0)

/**
* An assert while run without a checker. A checker message otherwise.
*
Expand Down
27 changes: 17 additions & 10 deletions src/utils/dlck/cmds/dlck_cmd_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#define REPORT_RESULT(CK, PREFIX_FMT, TGT_ID, UUID, RC, WARN_NUM) \
do { \
if (RC == DER_SUCCESS && WARN_NUM > 0) { \
CK_PRINTF(CK, PREFIX_FMT CHECKER_OK_INFIX DLCK_WARNINGS_NUM_FMT ".\n", \
CK_PRINTF(CK, \
PREFIX_FMT ": " CHECKER_OK_INFIX DLCK_WARNINGS_NUM_FMT ".\n", \
TGT_ID, DP_UUID(UUID), WARN_NUM); \
} else { \
CK_PRINTFL_RC(CK, RC, PREFIX_FMT, TGT_ID, DP_UUID(UUID)); \
Expand Down Expand Up @@ -62,10 +63,12 @@ obj_process(daos_handle_t ih, vos_iter_entry_t *entry, vos_iter_type_t type,
struct checker *ck = bndl->ck;
int rc;

CK_PRINTF(ck, CK_OID_FMT "...\n", DP_UOID(entry->ie_oid));
CK_INDENT(ck, rc = vos_iter_check(ih, ck));
CK_PRINTFL_RC(ck, rc, CK_OID_FMT, DP_UOID(entry->ie_oid));
dlck_status_set(&bndl->xa->status, &ck->ck_status);
if (bndl->xa->ctrl->scope.objects) {
CK_PRINTF(ck, CK_OID_FMT "...\n", DP_UOID(entry->ie_oid));
CK_INDENT(ck, rc = vos_iter_check(ih, ck));
CK_PRINTFL_RC(ck, rc, CK_OID_FMT, DP_UOID(entry->ie_oid));
dlck_status_set(&bndl->xa->status, &ck->ck_status);
}

/** continue checking other objects even if this one failed */
return 0;
Expand Down Expand Up @@ -116,13 +119,14 @@ cont_process(daos_handle_t ih, vos_iter_entry_t *entry, vos_iter_type_t type,
struct xstream_arg *xa = bndl->xa;
struct checker *main_ck = &xa->ctrl->checker;
struct checker *ck = bndl->ck;
struct checker *eff_ck = xa->ctrl->scope.containers ? ck : NULL;
bool fi_reenable;
const uint64_t exp_fail_locs[] = {DLCK_FAULT_CONT_DOES_NOT_EXIST, 0};
daos_handle_t coh;
int rc;

checker_fi_entry(exp_fail_locs, &fi_reenable);
rc = vos_cont_open_ex(param->ip_hdl, entry->ie_couuid, ck, &coh);
rc = vos_cont_open_ex(param->ip_hdl, entry->ie_couuid, eff_ck, &coh);
CONT_REPORT_RESULT(main_ck, xa->xs->tgt_id, entry->ie_couuid, rc,
ck->ck_status.warnings_num);
checker_fi_exit(fi_reenable);
Expand Down Expand Up @@ -175,6 +179,7 @@ static void
pool_process(struct xstream_arg *xa, struct dlck_file *file, struct checker *ck)
{
struct checker *main_ck = &xa->ctrl->checker;
struct checker *eff_ck = xa->ctrl->scope.pools ? ck : NULL;
char *path = NULL;
bool fi_reenable;
const uint64_t exp_fail_locs[] = {DLCK_FAULT_POOL_NVME_HEALTH,
Expand Down Expand Up @@ -213,21 +218,23 @@ pool_process(struct xstream_arg *xa, struct dlck_file *file, struct checker *ck)
}

checker_fi_entry(exp_fail_locs, &fi_reenable);
rc = vos_pool_open_metrics(path, file->po_uuid, DLCK_POOL_OPEN_FLAGS, NULL, ck, &poh);
rc = vos_pool_open_metrics(path, file->po_uuid, DLCK_POOL_OPEN_FLAGS, NULL, eff_ck, &poh);
checker_fi_exit(fi_reenable);
POOL_REPORT_RESULT(main_ck, xa->xs->tgt_id, file->po_uuid, rc, ck->ck_status.warnings_num);
/** vos_pool_open_metrics() is fully instrumented, so rc is already accounted for in the
* checker's status. */
dlck_status_set(&xa->status, &ck->ck_status);

report:
POOL_REPORT_RESULT(main_ck, xa->xs->tgt_id, file->po_uuid, rc, ck->ck_status.warnings_num);
if (rc == DER_SUCCESS) {
conts_process(xa, poh, ck);
(void)vos_pool_close(poh);
}
if (path != NULL) {
D_FREE(path);
}
return;

report:
POOL_REPORT_RESULT(main_ck, xa->xs->tgt_id, file->po_uuid, rc, ck->ck_status.warnings_num);
}

/**
Expand Down
21 changes: 19 additions & 2 deletions src/utils/dlck/dlck_args.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -60,11 +60,28 @@ parser(int key, char *arg, struct argp_state *state)

static struct argp argp = {empty_options, parser, NULL /** usage */, doc, children};

void
dlck_env(struct dlck_control *ctrl)
{
char *env;

/**
* Provide an environment variable to disable checking of specific scopes.
* When no environment variable is set, the corresponding scope will be checked.
*/
ctrl->scope.pools = d_agetenv_str(&env, "DLCK_CHECK_NO_POOLS") != DER_SUCCESS;
ctrl->scope.containers = d_agetenv_str(&env, "DLCK_CHECK_NO_CONTAINERS") != DER_SUCCESS;
ctrl->scope.objects = d_agetenv_str(&env, "DLCK_CHECK_NO_OBJECTS") != DER_SUCCESS;
}

void
dlck_args_parse(int argc, char *argv[], struct dlck_control *ctrl)
{
error_t ret = argp_parse(&argp, argc, argv, ARGP_IN_ORDER, 0, ctrl);
error_t ret;

dlck_env(ctrl);

ret = argp_parse(&argp, argc, argv, ARGP_IN_ORDER, 0, ctrl);
if (ret != 0) {
D_ERROR("Parsing arguments failed: %d", ret);
exit(ret);
Expand Down
7 changes: 7 additions & 0 deletions src/utils/dlck/dlck_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ dlck_args_files_num(struct dlck_args_files *files)
return num;
}

struct dlck_check_scope {
bool pools;
bool containers;
bool objects;
};

/**
* @struct dlck_control
*
Expand All @@ -114,6 +120,7 @@ struct dlck_control {
/** in */
struct dlck_args_common common;
struct dlck_args_files files;
struct dlck_check_scope scope;
struct dlck_args_engine engine;
/** checker */
struct checker checker;
Expand Down
3 changes: 1 addition & 2 deletions src/utils/dlck/dlck_pool.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -36,7 +36,6 @@ dlck_pool_mkdir(const char *storage_path, uuid_t po_uuid, struct checker *ck)
}
if (rc != 0 && errno != EEXIST) {
rc = daos_errno2der(errno);
CK_PRINTFL_RC(ck, rc, "Cannot create a pool directory: %s", path);
} else {
rc = DER_SUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/dlck/tests/dlck_checker_macros_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ test_CK_PRINTF_ERR(void **state)
{
struct checker *ck = *state;

EXPECT_CHECKER_VFPRINTF("%sworker %d: %s\n", "-> worker 42: failed\n");
EXPECT_CHECKER_VFPRINTF("%serror: worker %d: %s\n", "-> error: worker 42: failed\n");
CK_PRINTF_ERR(ck, "worker %d: %s\n", 42, "failed");
assert_int_equal(ck->ck_status.errors_num, INITIAL_ERRORS + 1);

EXPECT_CHECKER_VFPRINTF("%sworker %d: %s\n", "-> worker 43: corrupted\n");
EXPECT_CHECKER_VFPRINTF("%serror: worker %d: %s\n", "-> error: worker 43: corrupted\n");
CK_PRINTF_ERR(ck, "worker %d: %s\n", 43, "corrupted");
assert_int_equal(ck->ck_status.errors_num, INITIAL_ERRORS + 2);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/dlck/tests/fault_injection_dlck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fault_config:
# - id: 131600 # DAOS_FAULT_GC_TREE_FEATURES
# - id: 131593 # DAOS_FAULT_POOL_EXT_PADDING
# - id: 131594 # DAOS_FAULT_POOL_EXT_RESERVED
# - id: 131344 # DLCK_FAULT_CONT_DOES_NOT_EXIST
# - id: 131346 # DLCK_FAULT_CONT_DOES_NOT_EXIST
# - id: 131841 # DAOS_FAULT_CONT_OPEN_UUID
# - id: 131842 # DAOS_FAULT_CONT_INV_PAD
# - id: 131843 # DAOS_FAULT_CONT_INV_USED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Create pools directories... ok.
Start targets... ok.
Wait for targets to stop...
[0] pool {{UUID}} check result: ok.
[0] container {{UUID}} check resultok (1 warning(s)).
[0] container {{UUID}} check result: ok (1 warning(s)).
Wait for targets to stop: ok.
Stop the engine... ok.
===============================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
VOS file allocation: ok.
Check pool:
path: {{STORAGE}}/{{UUID}}/vos-0
uuid: {{UUID}}
- NVMe devices (if applicable): ok.
- Open the pool: ok.
- Magic... ok.
- Version... ok.
- UUID... ok.
- Containers tree...
-- Tree class... ok.
-- Tree features... ok.
-- Node (off=0xa7a4c0)... ok.
- Containers tree: ok.
- Pool extension (off=0x400550)... ok.
- Garbage collector's tree...
-- Tree class... ok.
-- Tree features... ok.
-- Empty tree
- Garbage collector's tree: ok.
Check pool: ok.
Check container:
uuid: {{UUID}}
- uuid... ok.
- Padding (cd_pad)... warning: non-zero (0)
ok.
- Padding (cd_used)... ok.
- Reserved (cd_reserv_upgrade)... ok.
- Object index tree...
Expand Down Expand Up @@ -63,17 +42,3 @@ ok.
-- DTX blob (off=0x514650)... ok.
- Active DTX blob list: ok.
Check container: ok.
Check oid: 1185667690.2136093645.0.0...
- Dkey tree...
-- Tree class... ok.
-- Tree features... ok.
-- Node (off=0xb01880)... ok.
- Dkey tree: ok.
Check oid: 1185667690.2136093645.0.0: ok.
Check oid: 471378945.1581695481.0.0...
- Dkey tree...
-- Tree class... ok.
-- Tree features... ok.
-- Node (off=0xb016a0)... ok.
- Dkey tree: ok.
Check oid: 471378945.1581695481.0.0: ok.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Create pools directories... ok.
Start targets... ok.
Wait for targets to stop...
[0] pool {{UUID}} check result: ok.
[0] container {{UUID}} check resultok (1 warning(s)).
[0] container {{UUID}} check result: ok (1 warning(s)).
Wait for targets to stop: ok.
Stop the engine... ok.
===============================
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
VOS file allocation: ok.
Check pool:
path: {{STORAGE}}/{{UUID}}/vos-0
uuid: {{UUID}}
- NVMe devices (if applicable): ok.
- Open the pool: ok.
- Magic... ok.
- Version... ok.
- UUID... ok.
- Containers tree...
-- Tree class... ok.
-- Tree features... ok.
-- Node (off=0xa7a4c0)... ok.
- Containers tree: ok.
- Pool extension (off=0x400550)... ok.
- Garbage collector's tree...
-- Tree class... ok.
-- Tree features... ok.
-- Empty tree
- Garbage collector's tree: ok.
Check pool: ok.
Check container:
uuid: {{UUID}}
- uuid... ok.
- Padding (cd_pad)... ok.
- Padding (cd_used)... ok.
- Reserved (cd_reserv_upgrade)... warning: non-zero (0)
ok.
- Object index tree...
-- Tree class... ok.
-- Tree features... ok.
Expand Down Expand Up @@ -63,17 +42,3 @@ ok.
-- DTX blob (off=0x514650)... ok.
- Active DTX blob list: ok.
Check container: ok.
Check oid: 1185667690.2136093645.0.0...
- Dkey tree...
-- Tree class... ok.
-- Tree features... ok.
-- Node (off=0xb01880)... ok.
- Dkey tree: ok.
Check oid: 1185667690.2136093645.0.0: ok.
Check oid: 471378945.1581695481.0.0...
- Dkey tree...
-- Tree class... ok.
-- Tree features... ok.
-- Node (off=0xb016a0)... ok.
- Dkey tree: ok.
Check oid: 471378945.1581695481.0.0: ok.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Create pools directories... ok.
Start targets... ok.
Wait for targets to stop...
[0] pool {{UUID}} check result: ok.
[0] container {{UUID}} check resultok (1 warning(s)).
[0] container {{UUID}} check result: ok (1 warning(s)).
Wait for targets to stop: ok.
Stop the engine... ok.
===============================
Expand Down
Loading
Loading