Skip to content
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

DAOS-16661 common: Integrate PMDK logging system w/ VOS logging system. #14923

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
149320c
Integrate PMDK logging system w/ VOS logging system.
grom72 Aug 13, 2024
1011420
HARK is reported as INFO
grom72 Sep 3, 2024
f9b926d
Fix - force build
grom72 Sep 4, 2024
45e6548
Skip NLT tests as they blocks functional validation.
grom72 Sep 4, 2024
76fe5c6
Fix: apply git-format-clang chanhes
grom72 Sep 20, 2024
a516943
Test: re-run to remove failed Trivy build
grom72 Sep 25, 2024
224ea5c
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Oct 4, 2024
c445554
No error message on intentional pmemobj transaction abort
grom72 Oct 4, 2024
055c40f
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Oct 24, 2024
8f2b121
Fix merge
grom72 Oct 24, 2024
6a85d36
Fix: apply fix for https://github.com/pmem/pmdk/issues/6107
grom72 Oct 25, 2024
c5935f1
fix: skip NLT tests for full HW validation
grom72 Oct 28, 2024
3e73bd5
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Oct 31, 2024
ec17be3
Fix: apply fix for https://github.com/pmem/pmdk/issues/6126
grom72 Oct 31, 2024
9c1a53e
Fix: apply final fix for https://github.com/pmem/pmdk/issues/6126
grom72 Nov 5, 2024
4672438
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Nov 6, 2024
4c0b796
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-loging
grom72 Nov 18, 2024
a7ad9fa
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Jan 7, 2025
bd924f6
Update copyright info
grom72 Jan 7, 2025
f1e6c21
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Jan 16, 2025
7beccb8
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Jan 20, 2025
1d3f89a
Optimizing the use of the DD_FLAG() macro
jolivier23 Jan 29, 2025
13dd692
pmdk_log_function optimization
jolivier23 Jan 29, 2025
2b2b30c
Unified parameters naming convention
grom72 Jan 30, 2025
303a42d
pmemobj log to daos translation tab optimization
grom72 Jan 30, 2025
ce9fa93
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Jan 30, 2025
a20d8b5
Merge remote-tracking branch 'origin/master' into grom72/pmdk-w-logging
grom72 Feb 5, 2025
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
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
daos (2.7.100-6) unstable; urgency=medium
[ Tomasz Gromadzki ]
* pmemobj errors and warnings reported via DAOS logging system

-- Tomasz Gromadzki <[email protected]> Tue, 03 Sep 2024 12:00:00 +0200

brianjmurrell marked this conversation as resolved.
Show resolved Hide resolved
daos (2.7.100-5) unstable; urgency=medium
[ Michael MacDonald ]
* Add libdaos_self_test.so to client package
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Build-Depends: debhelper (>= 10),
python3-distro,
libabt-dev,
libucx-dev,
libpmemobj-dev (>= 2.0.0),
libpmemobj-dev (>= 2.1.0),
libfuse3-dev,
libprotobuf-c-dev,
libjson-c-dev,
Expand Down
2 changes: 2 additions & 0 deletions site_scons/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def define_components(reqs):
commands=[['make',
'all',
'NDCTL_ENABLE=n',
'PMEMOBJ_IGNORE_DIRTY_SHUTDOWN=y',
'PMEMOBJ_IGNORE_BAD_BLOCKS=y',
'BUILD_EXAMPLES=n',
'BUILD_BENCHMARKS=n',
'DOC=n',
Expand Down
3 changes: 2 additions & 1 deletion src/include/daos/debug.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2015-2023 Intel Corporation.
* (C) Copyright 2015-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -30,6 +30,7 @@
ACTION(common, common, arg) \
ACTION(tree, tree, arg) \
ACTION(vos, vos, arg) \
ACTION(pmdk, pmdk, arg) \
ACTION(client, client, arg) \
ACTION(server, server, arg) \
ACTION(rdb, rdb, arg) \
Expand Down
2 changes: 1 addition & 1 deletion src/vos/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FILES = ["evt_iter.c", "vos_common.c", "vos_iterator.c", "vos_io.c",
"vos_dtx.c", "vos_query.c", "vos_overhead.c",
"vos_dtx_iter.c", "vos_gc.c", "vos_ilog.c", "ilog.c", "vos_ts.c",
"lru_array.c", "vos_space.c", "sys_db.c",
"vos_csum_recalc.c", "vos_pool_scrub.c"]
"vos_csum_recalc.c", "vos_pool_scrub.c", "pmdk_log.c"]


def build_vos(env, standalone):
Expand Down
99 changes: 99 additions & 0 deletions src/vos/pmdk_log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* (C) Copyright 2024 Intel Corporation.
*
* 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>

static uint64_t pmemobj_log_level_2_dlog_prio[] = {
[PMEMOBJ_LOG_LEVEL_HARK] = DLOG_INFO, [PMEMOBJ_LOG_LEVEL_FATAL] = DLOG_CRIT,
[PMEMOBJ_LOG_LEVEL_ERROR] = DLOG_ERR, [PMEMOBJ_LOG_LEVEL_WARNING] = DLOG_WARN,
[PMEMOBJ_LOG_LEVEL_NOTICE] = DLOG_NOTE, [PMEMOBJ_LOG_LEVEL_INFO] = DLOG_INFO,
[PMEMOBJ_LOG_LEVEL_DEBUG] = DLOG_DBG,
};

static void
pmdk_log_function(enum pmemobj_log_level level, const char *file_name,
unsigned line_no, const char *function_name, const char *message)
{
uint64_t dlog_prio = pmemobj_log_level_2_dlog_prio[level];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one example where pulling in PMDK into DAOS would be useful.

Anyway, this can be improved to be more efficient.

Add the following

#define _D_DEBUG_EXPANDED(func, flag, flag_var, ...)

Have _D_DEBUG call this with DD_FLAG(flag, D_LOGFAC) as the flag var.

In your case, you can have a map like the one you have above to each flag var

e.g. &DD_FLAG(DLOG_INFO, D_LOGFAC)

And instead of calling _D_DEBUG, call _D_DEBUG_EXPANDED with *flag_var you saved.

Additionally, one might consider passing these variables down to the lower level (e..g. register_debug_callback(callback, &DD_FLAG(...)). The check can just be if (*flag != 0) inside of pmdk and the upper level will take care of caching the value for the next call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _D_DEBUG_W_SAVED_MASK macro (instead of _D_DEBUG_EXPANDED) has been added and the pmdk_log_function() has been adjusted.


/*
* 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() 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, ...)
*/

/*
* 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_NOCHECK(mask, fmt, ...) \
d_log(mask, "%s:%d %s() " fmt, file_name, line_no, function_name, ##__VA_ARGS__)

/*
* The calculated message priority can't be passed as an argument to
* the _D_DEBUG() since the argument's name is used to construct
* a variable name.
*/
#define PMDK_DLOG_CASE(DLOG_PRIO) \
case DLOG_PRIO: \
_D_DEBUG(PMDK_LOG_NOCHECK, DLOG_PRIO, "%s\n", message); \
break

switch (dlog_prio) {
PMDK_DLOG_CASE(DLOG_EMIT);
PMDK_DLOG_CASE(DLOG_CRIT);
PMDK_DLOG_CASE(DLOG_ERR);
PMDK_DLOG_CASE(DLOG_WARN);
PMDK_DLOG_CASE(DLOG_NOTE);
PMDK_DLOG_CASE(DLOG_INFO);
PMDK_DLOG_CASE(DLOG_DBG);
default:
D_ERROR("Not implemented dlog priority: %#x\n", (unsigned)dlog_prio);
_D_DEBUG(PMDK_LOG_NOCHECK, DLOG_EMIT, "%s\n", message);
}

#undef PMDK_DLOG_CASE
#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 */
17 changes: 17 additions & 0 deletions src/vos/pmdk_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* (C) Copyright 2024 Intel Corporation.
*
* 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__ */
7 changes: 7 additions & 0 deletions src/vos/vos_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <daos_srv/daos_engine.h>
#include <daos_srv/smd.h>
#include "vos_internal.h"
#include "pmdk_log.h"

struct vos_self_mode {
struct vos_tls *self_tls;
Expand Down Expand Up @@ -634,6 +635,12 @@ vos_mod_init(void)
if (vos_start_epoch == DAOS_EPOCH_MAX)
vos_start_epoch = d_hlc_get();

rc = pmdk_log_attach();
if (rc != 0) {
D_ERROR("PMDK log initialization error\n");
return rc;
}

rc = vos_pool_settings_init(bio_nvme_configured(SMD_DEV_TYPE_META));
if (rc != 0) {
D_ERROR("VOS pool setting initialization error\n");
Expand Down
2 changes: 1 addition & 1 deletion utils/build.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ component=daos
[commit_versions]
argobots=v1.1
fuse=fuse-3.16.2
pmdk=2.0.0
pmdk=2.1.0
isal=v2.30.0
isal_crypto=v2.23.0
spdk=v22.01.2
Expand Down
11 changes: 7 additions & 4 deletions utils/rpms/daos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

Name: daos
Version: 2.7.100
Release: 5%{?relval}%{?dist}
Release: 6%{?relval}%{?dist}
Summary: DAOS Storage Engine

License: BSD-2-Clause-Patent
Expand Down Expand Up @@ -49,7 +49,7 @@ BuildRequires: libabt-devel >= 1.0rc1
BuildRequires: libjson-c-devel
BuildRequires: boost-devel
%endif
BuildRequires: libpmemobj-devel >= 2.0.0
BuildRequires: libpmemobj-devel >= 2.1.0
%if (0%{?rhel} >= 8)
BuildRequires: fuse3-devel >= 3
%else
Expand Down Expand Up @@ -147,11 +147,11 @@ Requires: ndctl
# needed to set PMem configuration goals in BIOS through control-plane
%if (0%{?suse_version} >= 1500)
Requires: ipmctl >= 03.00.00.0423
Requires: libpmemobj1 >= 2.0.0-1.suse1500
Requires: libpmemobj1 >= 2.1.0-1.suse1500
Requires: libfabric1 >= %{libfabric_version}
%else
Requires: ipmctl >= 03.00.00.0468
Requires: libpmemobj >= 2.0.0-1%{?dist}
Requires: libpmemobj >= 2.1.0-1%{?dist}
%endif
Requires: libfabric >= %{libfabric_version}
Requires: mercury >= %{mercury_version}
Expand Down Expand Up @@ -592,6 +592,9 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent
# No files in a shim package

%changelog
* Tue Sep 03 2024 Tomasz Gromadzki <[email protected]> 2.7.100-6
- pmemobj errors and warnings reported via DAOS logging system

* Thu Aug 15 2024 Michael MacDonald <[email protected]> 2.7.100-5
- Add libdaos_self_test.so to client RPM

Expand Down
Loading