Skip to content

Commit

Permalink
Integrate PMDK logging system w/ VOS logging system.
Browse files Browse the repository at this point in the history
To enable new message in log in NLT.
Allow-unstable-test: true

Priority: 2

Required-githooks: true

Co-authored-by: Jan Michalski <jan.michalski@intel.com>
Co-authored-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>

Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
  • Loading branch information
grom72 committed Sep 3, 2024
1 parent 46e6383 commit 149320c
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 8 deletions.
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
daos (2.7.100-5) unstable; urgency=medium
[ Tomasz Gromadzki ]
* pmemobj errors and warnings reported via DAOS logging system

-- Tomasz Gromadzki <tomasz.gromadzki@intel.com> Tue, 03 Sep 2024 12:00:00 +0200

[ 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_EMIT, [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];

/*
* 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 <tomasz.gromadzki@intel.com> 2.7.100-6
- pmemobj errors and warnings reported via DAOS logging system

* Thu Aug 15 2024 Michael MacDonald <mjmac@google.com> 2.7.100-5
- Add libdaos_self_test.so to client RPM

Expand Down

0 comments on commit 149320c

Please sign in to comment.