Skip to content

Commit 0f34795

Browse files
kanard38knard38
authored andcommitted
DAOS-18292 ddb: Debug level of the DDB GO code can not be defined
Properly configure C DAOS debug facilities from Golang DDB code. Features: recovery Signed-off-by: Cedric Koch-Hofer <cedric.koch-hofer@hpe.com>
1 parent 9ea5f5e commit 0f34795

11 files changed

Lines changed: 68 additions & 25 deletions

File tree

src/control/cmd/ddb/main.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,36 @@ the command‑specific help for details.
262262
return errors.New("Cannot use both command file and a command string")
263263
}
264264

265+
if os.Getenv("DD_MASK") == "" {
266+
os.Setenv("DD_MASK", "mgmt,epc,csum,md,df,io,trace")
267+
}
265268
if opts.Debug {
266-
log.WithLogLevel(logging.LogLevelDebug)
267-
log.Debug("debug output enabled")
269+
log.WithLogLevel(logging.LogLevelTrace)
270+
if os.Getenv("D_LOG_MASK") == "" {
271+
os.Setenv("D_LOG_MASK", "INFO,DDB=DEBUG")
272+
}
273+
// Show debug output and above on stderr to not pollute stdout
274+
// NOTE: DD_STDERR can only be used with INFO and above.
275+
if os.Getenv("DD_STDERR") == "" {
276+
os.Setenv("DD_STDERR", "EMIT")
277+
}
278+
if os.Getenv("D_LOG_FILE") == "" {
279+
os.Setenv("D_LOG_FILE", "/dev/stderr")
280+
}
281+
} else {
282+
log.WithLogLevel(logging.LogLevelError)
283+
if os.Getenv("D_LOG_MASK") == "" {
284+
os.Setenv("D_LOG_MASK", "ERR,DDB=WARN")
285+
}
286+
// Only show warnings and above on stderr to not pollute stdout
287+
if os.Getenv("DD_STDERR") == "" {
288+
os.Setenv("DD_STDERR", "WARN")
289+
}
290+
if os.Getenv("D_LOG_FILE") == "" {
291+
os.Setenv("D_LOG_FILE", "/dev/null")
292+
}
268293
}
294+
log.Debug("debug output enabled")
269295

270296
ctx, cleanup, err := InitDdb(log)
271297
if err != nil {

src/include/daos/debug.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* (C) Copyright 2015-2024 Intel Corporation.
3-
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
3+
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
@@ -55,7 +55,8 @@
5555
ACTION(il, il, arg) \
5656
ACTION(csum, csum, arg) \
5757
ACTION(pipeline, pipeline, arg) \
58-
ACTION(stack, stack, arg)
58+
ACTION(stack, stack, arg) \
59+
ACTION(ddb, ddb, arg)
5960

6061
#define DAOS_FOREACH_DB(ACTION, arg) \
6162
/** metadata operation */ \

src/utils/ddb/ddb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
*
66
* SPDX-License-Identifier: BSD-2-Clause-Patent
77
*/
8+
#define D_LOGFAC DD_FAC(ddb)
9+
810
#include <stdlib.h>
911
#include <string.h>
1012
#include <limits.h>
13+
1114
#include <daos_errno.h>
1215
#include <daos_srv/vos.h>
1316

src/utils/ddb/ddb_commands.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
*
66
* SPDX-License-Identifier: BSD-2-Clause-Patent
77
*/
8+
#define D_LOGFAC DD_FAC(ddb)
89

9-
#include <daos/common.h>
10-
#include <daos_srv/vos.h>
1110
#include <sys/types.h>
1211
#include <time.h>
1312

14-
#include "daos_errno.h"
15-
#include "daos_srv/vos_types.h"
16-
#include "daos_types.h"
13+
#include <daos.h>
14+
#include <daos_errno.h>
15+
#include <daos_types.h>
16+
#include <daos/common.h>
17+
#include <daos_srv/vos.h>
18+
#include <daos_srv/vos_types.h>
19+
1720
#include "ddb_common.h"
1821
#include "ddb_parse.h"
1922
#include "ddb.h"
2023
#include "ddb_vos.h"
2124
#include "ddb_printer.h"
22-
#include "daos.h"
2325
#include "ddb_tree_path.h"
24-
#include "gurt/common.h"
25-
#include "gurt/debug.h"
2626

2727
#define ilog_path_required_error_message "Path to object, dkey, or akey required\n"
2828
#define error_msg_write_mode_only "Can only modify the VOS tree in 'write mode'\n"

src/utils/ddb/ddb_main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
*
66
* SPDX-License-Identifier: BSD-2-Clause-Patent
77
*/
8+
#define D_LOGFAC DD_FAC(ddb)
9+
10+
#include <stdarg.h>
11+
#include <sys/stat.h>
812

913
#include <daos/common.h>
1014
#include <daos/object.h>
15+
16+
#include "ddb.h"
1117
#include "ddb_common.h"
1218
#include "ddb_parse.h"
1319
#include "ddb_vos.h"
14-
#include "ddb.h"
15-
#include <stdarg.h>
16-
#include <sys/stat.h>
1720

1821
int
1922
ddb_init()

src/utils/ddb/ddb_mgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

89
#include <ftw.h>
910
#include <unistd.h>
@@ -13,7 +14,6 @@
1314
#include <sys/sysinfo.h>
1415
#include <linux/magic.h>
1516

16-
#include <gurt/debug.h>
1717
#include <daos_srv/control.h>
1818
#include <daos_srv/smd.h>
1919
#include <daos_srv/mgmt_tgt_common.h>

src/utils/ddb/ddb_parse.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

89
#include <wordexp.h>
910
#include <getopt.h>
10-
#include <gurt/common.h>
11+
12+
#include <daos_errno.h>
1113
#include <daos_srv/bio.h>
12-
#include "daos_errno.h"
14+
1315
#include "ddb_common.h"
1416
#include "ddb_parse.h"
1517

src/utils/ddb/ddb_printer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/**
22
* (C) Copyright 2022-2024 Intel Corporation.
3-
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
3+
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

89
#include "ddb_printer.h"
910

src/utils/ddb/ddb_spdk.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
/**
22
* (C) Copyright 2022 Intel Corporation.
3-
* (C) Copyright 2025 Hewlett Packard Enterprise Development LP
3+
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
44
*
55
* SPDX-License-Identifier: BSD-2-Clause-Patent
66
*/
7+
#define D_LOGFAC DD_FAC(ddb)
78

8-
#include <bio_internal.h>
9-
#include <bio_wal.h>
9+
#include <uuid/uuid.h>
1010
#include <spdk/stdinc.h>
1111
#include <spdk/bdev.h>
1212
#include <spdk/env.h>
1313
#include <spdk/event.h>
1414
#include <spdk/blob_bdev.h>
1515
#include <spdk/blob.h>
1616
#include <spdk/string.h>
17-
#include <uuid/uuid.h>
17+
18+
#include <bio_internal.h>
19+
#include <bio_wal.h>
1820

1921
#include "ddb_common.h"
2022
#include "ddb_spdk.h"

src/utils/ddb/ddb_tree_path.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/**
22
* (C) Copyright 2023-2024 Intel Corporation.
3+
* (C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
34
*
45
* SPDX-License-Identifier: BSD-2-Clause-Patent
56
*/
7+
#define D_LOGFAC DD_FAC(ddb)
68

79
#include "ddb_tree_path.h"
810
#include "ddb_printer.h"

0 commit comments

Comments
 (0)