-
Notifications
You must be signed in to change notification settings - Fork 340
DAOS-16661 common: PMDK error/warnings to VOS logging (#14923) #17595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
grom72
wants to merge
3
commits into
release/2.6
Choose a base branch
from
grom72/DAOS-16661-2.6
base: release/2.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| /** | ||
| * (C) Copyright 2024 Intel Corporation. | ||
| * (C) Copyright 2025 Google LLC | ||
| * (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause-Patent | ||
| */ | ||
| /** | ||
| * Connecting the PMDK's logging to DAOS logging. | ||
| * | ||
| * vos/pmdk_log.c | ||
| */ | ||
|
|
||
| #define D_LOGFAC DD_FAC(pmdk) | ||
|
|
||
| #ifdef DAOS_PMEM_BUILD | ||
| #include <daos/debug.h> | ||
| #include <daos/common.h> | ||
| #include <libpmemobj/log.h> | ||
| #include <libpmemobj.h> | ||
|
|
||
| #define PMDK_LOG_2_DAOS_LOG_INIT(PMDK_LEVEL, DAOS_LEVEL) \ | ||
| [PMDK_LEVEL] = {.level = DAOS_LEVEL, .saved_mask = &DD_FLAG(DAOS_LEVEL, D_LOGFAC)} | ||
|
|
||
| static struct { | ||
| int level; | ||
| int *saved_mask; | ||
| } pmemobj_log_level_2_daos_log[] = { | ||
| PMDK_LOG_2_DAOS_LOG_INIT(PMEMOBJ_LOG_LEVEL_HARK, DLOG_INFO), | ||
| PMDK_LOG_2_DAOS_LOG_INIT(PMEMOBJ_LOG_LEVEL_FATAL, DLOG_CRIT), | ||
| PMDK_LOG_2_DAOS_LOG_INIT(PMEMOBJ_LOG_LEVEL_ERROR, DLOG_ERR), | ||
| PMDK_LOG_2_DAOS_LOG_INIT(PMEMOBJ_LOG_LEVEL_WARNING, DLOG_WARN), | ||
| PMDK_LOG_2_DAOS_LOG_INIT(PMEMOBJ_LOG_LEVEL_NOTICE, DLOG_NOTE), | ||
| PMDK_LOG_2_DAOS_LOG_INIT(PMEMOBJ_LOG_LEVEL_INFO, DLOG_INFO), | ||
| PMDK_LOG_2_DAOS_LOG_INIT(PMEMOBJ_LOG_LEVEL_DEBUG, DLOG_DBG), | ||
| }; | ||
|
|
||
| #undef PMDK_LOG_2_DAOS_LOG_INIT | ||
|
|
||
| static void | ||
| pmdk_log_function(enum pmemobj_log_level level, const char *file_name, unsigned line_no, | ||
| const char *function_name, const char *message) | ||
| { | ||
| /* | ||
| * There is a set of handy macros for each of the message priorities | ||
| * that are used normally to report a message. They can't be used here | ||
| * directly since the file name, line number and the function name | ||
| * are provided via arguments to this callback function instead of | ||
| * via macro definitions (__FILE__, __LINE__, and __func__) as | ||
| * _D_LOG_NOCHECK() would like to consume them. So, the message here is | ||
| * provided a few macro-calls later via _D_DEBUG_W_SAVED_MASK() macro which allows | ||
| * to swap the _D_LOG_NOCHECK macro for a custom macro. | ||
| * | ||
| * D_ERROR(...) -> D_DEBUG(DLOG_ERR, ...) -> | ||
| * _D_DEBUG(_D_LOG_NOCHECK, DLOG_ERR, ...) -> | ||
| * _D_DEBUG_W_SAVED_MASK(_D_LOG_NOCHECK, DD_FLAG(DLOG_ERR, D_LOGFAC), DLOG_ERR, ...) | ||
| */ | ||
|
|
||
| /* | ||
| * A custom variant of _D_LOG_NOCHECK() which passes the file name, | ||
| * line number and the function name from the local variables. | ||
| */ | ||
| #define PMDK_LOG_FUNCTION_MAX_FILENAME 255 | ||
| #define PMDK_LOG_NOCHECK(mask, fmt, ...) \ | ||
| do { \ | ||
| char file_name_buff[PMDK_LOG_FUNCTION_MAX_FILENAME] = "pmdk/"; \ | ||
| char *local_file_name = file_name_buff + sizeof("pmdk/") - 1; \ | ||
| \ | ||
| /* normalize file path - remove leading "../" */ \ | ||
| while ((*file_name == '.') && (*(file_name + 1) == '.') && \ | ||
| (*(file_name + 2) == '/')) { \ | ||
| file_name += 3; \ | ||
| } \ | ||
| \ | ||
| /* simplify file path by removing cyclic pattern "src/../src" */ \ | ||
| if (strncmp(file_name, "src/../src", sizeof("src/../src") - 1) == 0) { \ | ||
| file_name += sizeof("src/../") - 1; \ | ||
| } \ | ||
| /* Add "pmdk/" prefix to file name */ \ | ||
| /* Prefix is needed to filter out PMDK messages in NLT results analysis */ \ | ||
| /* as it is implemented in https://github.com/daos-stack/pipeline-lib/pull/457 */ \ | ||
| \ | ||
| while ((local_file_name < file_name_buff + PMDK_LOG_FUNCTION_MAX_FILENAME - 1) && \ | ||
| (*file_name != '\0')) { \ | ||
| *(local_file_name++) = *(file_name++); \ | ||
| } \ | ||
| *local_file_name = '\0'; \ | ||
| d_log(mask, "%s:%d %s() " fmt, file_name_buff, line_no, function_name, \ | ||
| ##__VA_ARGS__); \ | ||
| } while (0) | ||
|
|
||
| int *saved_mask = pmemobj_log_level_2_daos_log[level].saved_mask; | ||
| _D_DEBUG_W_SAVED_MASK(PMDK_LOG_NOCHECK, *saved_mask, | ||
| pmemobj_log_level_2_daos_log[level].level, "%s\n", message); | ||
|
|
||
| #undef PMDK_LOG_NOCHECK | ||
| } | ||
|
|
||
| int | ||
| pmdk_log_attach(void) | ||
| { | ||
| int rc = pmemobj_log_set_function(pmdk_log_function); | ||
| if (rc == 0) { | ||
| return 0; | ||
| } else { | ||
| return daos_errno2der(errno); | ||
| } | ||
| } | ||
|
|
||
| #else | ||
|
|
||
| int | ||
| pmdk_log_attach(void) | ||
| { | ||
| ; | ||
| } | ||
|
|
||
| #endif /* DAOS_PMEM_BUILD */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /** | ||
| * (C) Copyright 2024 Intel Corporation. | ||
| * (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause-Patent | ||
| */ | ||
| /** | ||
| * Connecting the PMDK's logging to DAOS logging. | ||
| * vos/pmdk_log.h | ||
| */ | ||
|
|
||
| #ifndef __PMDK_LOG__ | ||
| #define __PMDK_LOG__ | ||
|
|
||
| int | ||
| pmdk_log_attach(void); | ||
|
|
||
| #endif /* __PMDK_LOG__ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.