From 28f81da634fa8f3217578818dc40f13a4ff545e9 Mon Sep 17 00:00:00 2001 From: Tomasz Gromadzki Date: Mon, 29 Jan 2024 11:07:05 +0100 Subject: [PATCH] common: convert LOG(1,...) into CORE_LOG_ERROR() Signed-off-by: Tomasz Gromadzki --- src/common/bad_blocks.c | 13 ++-- src/common/ctl.c | 2 +- src/common/file_posix.c | 2 +- src/common/mmap.c | 2 +- src/common/os_deep_linux.c | 17 +++-- src/common/set.c | 38 ++++++---- src/common/set_badblocks.c | 5 +- src/core/util_posix.c | 4 +- src/libpmem/pmem_posix.c | 4 +- src/libpmem2/auto_flush_linux.c | 3 +- src/libpmem2/badblocks_ndctl.c | 8 +- src/libpmem2/deep_flush.c | 3 +- src/libpmem2/deep_flush_linux.c | 17 +++-- src/libpmem2/deep_flush_other.c | 3 +- src/libpmem2/map.c | 5 +- src/libpmem2/map_posix.c | 4 +- src/libpmem2/numa_ndctl.c | 2 +- src/libpmem2/persist.c | 6 +- src/libpmem2/pmem2_utils_ndctl.c | 4 +- src/libpmem2/region_namespace_ndctl.c | 2 +- src/libpmemobj/pmalloc.c | 14 ++-- src/libpmemobj/tx.c | 4 +- src/libpmemobj/ulog.c | 7 +- src/libpmempool/pool.c | 3 +- src/libpmempool/replica.c | 104 ++++++++++++++------------ src/libpmempool/sync.c | 21 +++--- src/libpmempool/transform.c | 66 +++++++++------- src/test/traces/traces.c | 4 +- 28 files changed, 206 insertions(+), 161 deletions(-) diff --git a/src/common/bad_blocks.c b/src/common/bad_blocks.c index 8657060bfdc..f44ec4848e3 100644 --- a/src/common/bad_blocks.c +++ b/src/common/bad_blocks.c @@ -148,7 +148,7 @@ badblocks_clear(const char *file, struct badblocks *bbs) ret = pmem2_badblock_context_new(&bbctx, src); if (ret) { - LOG(1, "pmem2_badblock_context_new failed -- %s", file); + CORE_LOG_ERROR("pmem2_badblock_context_new failed -- %s", file); goto exit_delete_source; } @@ -157,7 +157,7 @@ badblocks_clear(const char *file, struct badblocks *bbs) bb.length = bbs->bbv[b].length; ret = pmem2_badblock_clear(bbctx, &bb); if (ret) { - LOG(1, "pmem2_badblock_clear -- %s", file); + CORE_LOG_ERROR("pmem2_badblock_clear -- %s", file); goto exit_delete_ctx; } } @@ -206,14 +206,14 @@ badblocks_clear_all(const char *file) ret = pmem2_badblock_context_new(&bbctx, src); if (ret) { - LOG(1, "pmem2_badblock_context_new failed -- %s", file); + CORE_LOG_ERROR("pmem2_badblock_context_new failed -- %s", file); goto exit_delete_source; } while ((pmem2_badblock_next(bbctx, &bb)) == 0) { ret = pmem2_badblock_clear(bbctx, &bb); if (ret) { - LOG(1, "pmem2_badblock_clear -- %s", file); + CORE_LOG_ERROR("pmem2_badblock_clear -- %s", file); goto exit_delete_ctx; } }; @@ -251,12 +251,13 @@ badblocks_check_file(const char *file) long bbsc = badblocks_count(file); if (bbsc < 0) { - LOG(1, "counting bad blocks failed -- '%s'", file); + CORE_LOG_ERROR("counting bad blocks failed -- '%s'", file); return -1; } if (bbsc > 0) { - LOG(1, "pool file '%s' contains %li bad block(s)", file, bbsc); + CORE_LOG_ERROR("pool file '%s' contains %li bad block(s)", file, + bbsc); return 1; } diff --git a/src/common/ctl.c b/src/common/ctl.c index 99d2ece7dc0..fa721dbeda3 100644 --- a/src/common/ctl.c +++ b/src/common/ctl.c @@ -234,7 +234,7 @@ ctl_exec_query_write(void *ctx, const struct ctl_node *n, void *real_arg = ctl_query_get_real_args(n, arg, source); if (real_arg == NULL) { - LOG(1, "Invalid arguments"); + CORE_LOG_ERROR("Invalid arguments"); return -1; } diff --git a/src/common/file_posix.c b/src/common/file_posix.c index 2a1dc19870d..938722130e9 100644 --- a/src/common/file_posix.c +++ b/src/common/file_posix.c @@ -112,7 +112,7 @@ device_dax_alignment(const char *path) int fd = os_open(path, O_RDONLY); if (fd == -1) { - LOG(1, "Cannot open file %s", path); + CORE_LOG_ERROR("Cannot open file %s", path); return size; } diff --git a/src/common/mmap.c b/src/common/mmap.c index 546f11a08e7..aaf4b3deddb 100644 --- a/src/common/mmap.c +++ b/src/common/mmap.c @@ -91,7 +91,7 @@ util_map(int fd, os_off_t off, size_t len, int flags, int rdonly, void *base; void *addr = util_map_hint(len, req_align); if (addr == MAP_FAILED) { - LOG(1, "cannot find a contiguous region of given size"); + CORE_LOG_ERROR("cannot find a contiguous region of given size"); return NULL; } diff --git a/src/common/os_deep_linux.c b/src/common/os_deep_linux.c index eec0a3a5ce1..f74cf64a8d0 100644 --- a/src/common/os_deep_linux.c +++ b/src/common/os_deep_linux.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -/* Copyright 2017-2023, Intel Corporation */ +/* Copyright 2017-2024, Intel Corporation */ /* * os_deep_linux.c -- Linux abstraction layer @@ -35,7 +35,7 @@ os_deep_type(const struct map_tracker *mt, void *addr, size_t len) if (ret < 0) { if (ret == PMEM2_E_NOSUPP) { errno = ENOTSUP; - LOG(1, "!deep_flush not supported"); + CORE_LOG_ERROR("!deep_flush not supported"); } else { errno = pmem2_err_to_errno(ret); LOG(2, "cannot write to deep_flush" @@ -122,7 +122,7 @@ os_part_deep_common(struct pool_replica *rep, unsigned partidx, void *addr, return 0; if (pmem_msync(addr, len)) { - LOG(1, "pmem_msync(%p, %lu)", addr, len); + CORE_LOG_ERROR("pmem_msync(%p, %lu)", addr, len); return -1; } return 0; @@ -151,16 +151,17 @@ os_part_deep_common(struct pool_replica *rep, unsigned partidx, void *addr, if (ret < 0) { if (errno == ENOENT) { errno = ENOTSUP; - LOG(1, "!deep_flush not supported"); + CORE_LOG_ERROR_WITH_ERRNO( + "deep_flush not supported"); } else { - LOG(1, "invalid dax_region id %u", region_id); + CORE_LOG_ERROR("invalid dax_region id %u", + region_id); } return -1; } if (pmem2_deep_flush_write(region_id)) { - LOG(1, "pmem2_deep_flush_write(%u)", - region_id); + CORE_LOG_ERROR("pmem2_deep_flush_write(%u)", region_id); return -1; } } else { @@ -169,7 +170,7 @@ os_part_deep_common(struct pool_replica *rep, unsigned partidx, void *addr, * call msync on one page. */ if (pmem_msync(addr, MIN(Pagesize, len))) { - LOG(1, "pmem_msync(%p, %lu)", addr, len); + CORE_LOG_ERROR("pmem_msync(%p, %lu)", addr, len); return -1; } } diff --git a/src/common/set.c b/src/common/set.c index 487e755c65d..fe33cdb61b9 100644 --- a/src/common/set.c +++ b/src/common/set.c @@ -180,7 +180,8 @@ util_map_hdr(struct pool_set_part *part, int flags, int rdonly) /* this is required only for Device DAX & memcheck */ addr = util_map_hint(hdrsize, hdrsize); if (addr == MAP_FAILED) { - LOG(1, "cannot find a contiguous region of given size"); + CORE_LOG_ERROR( + "cannot find a contiguous region of given size"); /* there's nothing we can do */ return -1; } @@ -424,8 +425,8 @@ util_poolset_chmod(struct pool_set *set, mode_t mode) } if (stbuf.st_mode & ~(unsigned)S_IFMT) { - LOG(1, "file permissions changed during pool " - "initialization, file: %s (%o)", + CORE_LOG_ERROR( + "file permissions changed during pool initialization, file: %s (%o)", part->path, stbuf.st_mode & ~(unsigned)S_IFMT); } @@ -1959,7 +1960,8 @@ util_replica_map_local(struct pool_set *set, unsigned repidx, int flags) /* determine a hint address for mmap() */ addr = util_map_hint(rep->resvsize, 0); if (addr == MAP_FAILED) { - LOG(1, "cannot find a contiguous region of given size"); + CORE_LOG_ERROR( + "cannot find a contiguous region of given size"); return -1; } @@ -2433,7 +2435,7 @@ util_pool_create_uuids(struct pool_set **setp, const char *path, (attr->features.compat & POOL_FEAT_CHECK_BAD_BLOCKS)) { int bbs = badblocks_check_poolset(set, 1 /* create */); if (bbs < 0) { - LOG(1, + CORE_LOG_ERROR( "failed to check pool set for bad blocks -- '%s'", path); goto err_poolset_free; @@ -2578,7 +2580,8 @@ util_replica_open_local(struct pool_set *set, unsigned repidx, int flags) if (addr == NULL) addr = util_map_hint(rep->resvsize, 0); if (addr == MAP_FAILED) { - LOG(1, "cannot find a contiguous region of given size"); + CORE_LOG_ERROR( + "cannot find a contiguous region of given size"); return -1; } @@ -2864,20 +2867,21 @@ util_pool_open_nocheck(struct pool_set *set, unsigned flags) return -1; } if (bfe < 0) { - LOG(1, + CORE_LOG_ERROR( "an error occurred when checking whether recovery file exists."); return -1; } int bbs = badblocks_check_poolset(set, 0 /* not create */); if (bbs < 0) { - LOG(1, "failed to check pool set for bad blocks"); + CORE_LOG_ERROR( + "failed to check pool set for bad blocks"); return -1; } if (bbs > 0) { if (flags & POOL_OPEN_IGNORE_BAD_BLOCKS) { - LOG(1, + CORE_LOG_ERROR( "WARNING: pool set contains bad blocks, ignoring"); } else { ERR_WO_ERRNO( @@ -2935,14 +2939,16 @@ util_read_compat_features(struct pool_set *set, uint32_t *compat_features) struct pool_set_part *part = &rep->part[p]; if (util_part_open(part, 0, 0 /* create */)) { - LOG(1, "!cannot open the part -- \"%s\"", + CORE_LOG_ERROR( + "!cannot open the part -- \"%s\"", part->path); /* try to open the next part */ continue; } if (util_map_hdr(part, MAP_SHARED, 0) != 0) { - LOG(1, "header mapping failed -- \"%s\"", + CORE_LOG_ERROR( + "header mapping failed -- \"%s\"", part->path); util_part_fdclose(part); return -1; @@ -3008,7 +3014,7 @@ util_pool_open(struct pool_set **setp, const char *path, size_t minpartsize, uint32_t compat_features; if (util_read_compat_features(set, &compat_features)) { - LOG(1, "reading compat features failed"); + CORE_LOG_ERROR("reading compat features failed"); goto err_poolset_free; } @@ -3023,14 +3029,14 @@ util_pool_open(struct pool_set **setp, const char *path, size_t minpartsize, } if (bfe < 0) { - LOG(1, + CORE_LOG_ERROR( "an error occurred when checking whether recovery file exists."); goto err_poolset_free; } int bbs = badblocks_check_poolset(set, 0 /* not create */); if (bbs < 0) { - LOG(1, + CORE_LOG_ERROR( "failed to check pool set for bad blocks -- '%s'", path); goto err_poolset_free; @@ -3038,7 +3044,7 @@ util_pool_open(struct pool_set **setp, const char *path, size_t minpartsize, if (bbs > 0) { if (flags & POOL_OPEN_IGNORE_BAD_BLOCKS) { - LOG(1, + CORE_LOG_ERROR( "WARNING: pool set contains bad blocks, ignoring -- '%s'", path); } else { @@ -3292,7 +3298,7 @@ util_replica_deep_common(const void *addr, size_t len, struct pool_set *set, replica_id, part, (void *)range_start, range_len); if (os_part_deep_common(rep, p, (void *)range_start, range_len, flush)) { - LOG(1, "os_part_deep_common(%p, %p, %lu)", + CORE_LOG_ERROR("os_part_deep_common(%p, %p, %lu)", part, (void *)range_start, range_len); return -1; } diff --git a/src/common/set_badblocks.c b/src/common/set_badblocks.c index e12d73bf323..f39ac85966f 100644 --- a/src/common/set_badblocks.c +++ b/src/common/set_badblocks.c @@ -83,7 +83,8 @@ badblocks_check_poolset(struct pool_set *set, int create) } if (cfcb.n_files_bbs) { - LOG(1, "%i pool file(s) contain bad blocks", cfcb.n_files_bbs); + CORE_LOG_ERROR("%i pool file(s) contain bad blocks", + cfcb.n_files_bbs); set->has_bad_blocks = 1; } @@ -209,7 +210,7 @@ badblocks_recovery_file_exists(struct pool_set *set) char *rec_file = badblocks_recovery_file_alloc(set->path, r, p); if (rec_file == NULL) { - LOG(1, + CORE_LOG_ERROR( "allocating name of bad block recovery file failed"); return -1; } diff --git a/src/core/util_posix.c b/src/core/util_posix.c index 2d7558e48c8..d55e0c89f52 100644 --- a/src/core/util_posix.c +++ b/src/core/util_posix.c @@ -48,7 +48,7 @@ util_compare_file_inodes(const char *path1, const char *path2) ERR_W_ERRNO("stat failed for %s", path1); return -1; } - LOG(1, "stat failed for %s", path1); + CORE_LOG_ERROR("stat failed for %s", path1); errno = 0; return strcmp(path1, path2) != 0; } @@ -58,7 +58,7 @@ util_compare_file_inodes(const char *path1, const char *path2) ERR_W_ERRNO("stat failed for %s", path2); return -1; } - LOG(1, "stat failed for %s", path2); + CORE_LOG_ERROR("stat failed for %s", path2); errno = 0; return strcmp(path1, path2) != 0; } diff --git a/src/libpmem/pmem_posix.c b/src/libpmem/pmem_posix.c index d295b13c732..c06308ffcdd 100644 --- a/src/libpmem/pmem_posix.c +++ b/src/libpmem/pmem_posix.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -/* Copyright 2014-2019, Intel Corporation */ +/* Copyright 2014-2024, Intel Corporation */ /* * pmem_posix.c -- pmem utilities with Posix implementation @@ -58,7 +58,7 @@ pmem_map_register(int fd, size_t len, const char *path, int is_dev_dax) if (type != MAX_PMEM_TYPE) { if (util_range_register(addr, len, path, type)) { - LOG(1, "can't track mapped region"); + CORE_LOG_ERROR("can't track mapped region"); goto err_unmap; } } diff --git a/src/libpmem2/auto_flush_linux.c b/src/libpmem2/auto_flush_linux.c index 951dc791833..ebe0fe84323 100644 --- a/src/libpmem2/auto_flush_linux.c +++ b/src/libpmem2/auto_flush_linux.c @@ -34,7 +34,8 @@ check_cpu_cache(const char *domain_path) int cpu_cache = 0; if ((domain_fd = os_open(domain_path, O_RDONLY)) < 0) { - LOG(1, "!open(\"%s\", O_RDONLY)", domain_path); + CORE_LOG_ERROR_WITH_ERRNO("open(\"%s\", O_RDONLY)", + domain_path); goto end; } ssize_t len = read(domain_fd, domain_value, diff --git a/src/libpmem2/badblocks_ndctl.c b/src/libpmem2/badblocks_ndctl.c index c2205d8c61d..35a914e9566 100644 --- a/src/libpmem2/badblocks_ndctl.c +++ b/src/libpmem2/badblocks_ndctl.c @@ -284,7 +284,7 @@ pmem2_badblock_context_new(struct pmem2_badblock_context **bbctx, ret = pmem2_region_namespace(ctx, src, ®ion, &ndns); if (ret) { - LOG(1, "getting region and namespace failed"); + CORE_LOG_ERROR("getting region and namespace failed"); goto exit_ndctl_unref; } @@ -314,7 +314,7 @@ pmem2_badblock_context_new(struct pmem2_badblock_context **bbctx, region, ndns, &ns_beg, &ns_size); if (ret) { - LOG(1, "cannot read namespace's bounds"); + CORE_LOG_ERROR("cannot read namespace's bounds"); goto error_free_all; } @@ -339,7 +339,7 @@ pmem2_badblock_context_new(struct pmem2_badblock_context **bbctx, /* only regular files have extents */ ret = pmem2_extents_create_get(src->value.fd, &tbbctx->exts); if (ret) { - LOG(1, "getting extents of fd %i failed", + CORE_LOG_ERROR("getting extents of fd %i failed", src->value.fd); goto error_free_all; } @@ -744,7 +744,7 @@ pmem2_badblock_clear_devdax(const struct pmem2_badblock_context *bbctx, bb->offset + bbctx->rgn.ns_res, bb->length); if (ret) { - LOG(1, + CORE_LOG_ERROR( "failed to clear a bad block: offset %zu length %zu (in 512B sectors)", B2SEC(bb->offset), B2SEC(bb->length)); diff --git a/src/libpmem2/deep_flush.c b/src/libpmem2/deep_flush.c index 1882ab7fca9..a44239a176f 100644 --- a/src/libpmem2/deep_flush.c +++ b/src/libpmem2/deep_flush.c @@ -34,7 +34,8 @@ pmem2_deep_flush(struct pmem2_map *map, void *ptr, size_t size) int ret = map->deep_flush_fn(map, ptr, size); if (ret) { - LOG(1, "cannot perform deep flush operation for map %p", map); + CORE_LOG_ERROR( + "cannot perform deep flush operation for map %p", map); return ret; } diff --git a/src/libpmem2/deep_flush_linux.c b/src/libpmem2/deep_flush_linux.c index ff4d547bcb9..a8f70d13a71 100644 --- a/src/libpmem2/deep_flush_linux.c +++ b/src/libpmem2/deep_flush_linux.c @@ -39,12 +39,13 @@ pmem2_deep_flush_write(unsigned region_id) } if ((deep_flush_fd = os_open(deep_flush_path, O_RDONLY)) < 0) { - LOG(1, "!os_open(\"%s\", O_RDONLY)", deep_flush_path); + CORE_LOG_ERROR_WITH_ERRNO("os_open(\"%s\", O_RDONLY)", + deep_flush_path); return 0; } if (read(deep_flush_fd, rbuf, sizeof(rbuf)) != 2) { - LOG(1, "!read(%d)", deep_flush_fd); + CORE_LOG_ERROR_WITH_ERRNO("read(%d)", deep_flush_fd); goto end; } @@ -56,13 +57,14 @@ pmem2_deep_flush_write(unsigned region_id) os_close(deep_flush_fd); if ((deep_flush_fd = os_open(deep_flush_path, O_WRONLY)) < 0) { - LOG(1, "Cannot open deep_flush file %s to write", + CORE_LOG_ERROR("Cannot open deep_flush file %s to write", deep_flush_path); return 0; } if (write(deep_flush_fd, "1", 1) != 1) { - LOG(1, "Cannot write to deep_flush file %d", deep_flush_fd); + CORE_LOG_ERROR("Cannot write to deep_flush file %d", + deep_flush_fd); goto end; } @@ -98,7 +100,7 @@ pmem2_deep_flush_dax(struct pmem2_map *map, void *ptr, size_t size) ret = pmem2_flush_file_buffers_os(map, ptr, size, 0); if (ret) { - LOG(1, "cannot flush buffers addr %p len %zu", + CORE_LOG_ERROR("cannot flush buffers addr %p len %zu", ptr, size); return ret; } @@ -106,13 +108,14 @@ pmem2_deep_flush_dax(struct pmem2_map *map, void *ptr, size_t size) unsigned region_id; int ret = pmem2_get_region_id(&map->source, ®ion_id); if (ret < 0) { - LOG(1, "cannot find region id for dev %lu", + CORE_LOG_ERROR("cannot find region id for dev %lu", map->source.value.st_rdev); return ret; } ret = pmem2_deep_flush_write(region_id); if (ret) { - LOG(1, "cannot write to deep_flush file for region %d", + CORE_LOG_ERROR( + "cannot write to deep_flush file for region %d", region_id); return ret; } diff --git a/src/libpmem2/deep_flush_other.c b/src/libpmem2/deep_flush_other.c index 4b4b8ebb394..b1aaa5a2ee5 100644 --- a/src/libpmem2/deep_flush_other.c +++ b/src/libpmem2/deep_flush_other.c @@ -23,7 +23,8 @@ pmem2_deep_flush_dax(struct pmem2_map *map, void *ptr, size_t size) { int ret = pmem2_flush_file_buffers_os(map, ptr, size, 0); if (ret) { - LOG(1, "cannot flush buffers addr %p len %zu", ptr, size); + CORE_LOG_ERROR("cannot flush buffers addr %p len %zu", ptr, + size); return ret; } diff --git a/src/libpmem2/map.c b/src/libpmem2/map.c index ea78bec1309..de729b58a9c 100644 --- a/src/libpmem2/map.c +++ b/src/libpmem2/map.c @@ -70,7 +70,8 @@ parse_force_granularity() char str[11]; /* strlen("CACHE_LINE") + 1 */ if (util_safe_strcpy(str, ptr, sizeof(str))) { - LOG(1, "Invalid value of PMEM2_FORCE_GRANULARITY"); + CORE_LOG_ERROR( + "Invalid value of PMEM2_FORCE_GRANULARITY"); return PMEM2_GRANULARITY_INVALID; } @@ -90,7 +91,7 @@ parse_force_granularity() return PMEM2_GRANULARITY_PAGE; } - LOG(1, "Invalid value of PMEM2_FORCE_GRANULARITY"); + CORE_LOG_ERROR("Invalid value of PMEM2_FORCE_GRANULARITY"); } return PMEM2_GRANULARITY_INVALID; } diff --git a/src/libpmem2/map_posix.c b/src/libpmem2/map_posix.c index 9fe3ec616e6..8e0eeac1cf6 100644 --- a/src/libpmem2/map_posix.c +++ b/src/libpmem2/map_posix.c @@ -429,10 +429,10 @@ pmem2_map_new(struct pmem2_map **map_ptr, const struct pmem2_config *cfg, &reserved_length, cfg); if (ret != 0) { if (ret == PMEM2_E_MAPPING_EXISTS) - LOG(1, + CORE_LOG_ERROR( "given mapping region is already occupied"); else - LOG(1, + CORE_LOG_ERROR( "cannot find a contiguous region of given size"); return ret; } diff --git a/src/libpmem2/numa_ndctl.c b/src/libpmem2/numa_ndctl.c index 15e1e700e3c..9359a531342 100644 --- a/src/libpmem2/numa_ndctl.c +++ b/src/libpmem2/numa_ndctl.c @@ -39,7 +39,7 @@ pmem2_source_numa_node(const struct pmem2_source *src, int *numa_node) int ret = pmem2_region_namespace(ctx, src, ®ion, NULL); if (ret < 0) { - LOG(1, "getting region failed"); + CORE_LOG_ERROR("getting region failed"); goto end; } diff --git a/src/libpmem2/persist.c b/src/libpmem2/persist.c index defe99d8a4f..b9281089958 100644 --- a/src/libpmem2/persist.c +++ b/src/libpmem2/persist.c @@ -322,7 +322,8 @@ pmem2_deep_flush_cache(struct pmem2_map *map, void *ptr, size_t size) int ret = pmem2_deep_flush_dax(map, ptr, size); if (ret < 0) { - LOG(1, "cannot perform deep flush cache for map %p", map); + CORE_LOG_ERROR( + "cannot perform deep flush cache for map %p", map); return ret; } @@ -356,7 +357,8 @@ pmem2_deep_flush_byte(struct pmem2_map *map, void *ptr, size_t size) int ret = pmem2_deep_flush_dax(map, ptr, size); if (ret < 0) { - LOG(1, "cannot perform deep flush byte for map %p", map); + CORE_LOG_ERROR("cannot perform deep flush byte for map %p", + map); return ret; } diff --git a/src/libpmem2/pmem2_utils_ndctl.c b/src/libpmem2/pmem2_utils_ndctl.c index 0de3c774129..a9e1c0ca5a7 100644 --- a/src/libpmem2/pmem2_utils_ndctl.c +++ b/src/libpmem2/pmem2_utils_ndctl.c @@ -30,7 +30,7 @@ pmem2_device_dax_alignment(const struct pmem2_source *src, size_t *alignment) ret = pmem2_region_namespace(ctx, src, NULL, &ndns); if (ret) { - LOG(1, "getting region and namespace failed"); + CORE_LOG_ERROR("getting region and namespace failed"); goto end; } @@ -69,7 +69,7 @@ pmem2_device_dax_size(const struct pmem2_source *src, size_t *size) ret = pmem2_region_namespace(ctx, src, NULL, &ndns); if (ret) { - LOG(1, "getting region and namespace failed"); + CORE_LOG_ERROR("getting region and namespace failed"); goto end; } diff --git a/src/libpmem2/region_namespace_ndctl.c b/src/libpmem2/region_namespace_ndctl.c index f9893d4c897..03aa85a214b 100644 --- a/src/libpmem2/region_namespace_ndctl.c +++ b/src/libpmem2/region_namespace_ndctl.c @@ -245,7 +245,7 @@ pmem2_get_region_id(const struct pmem2_source *src, unsigned *region_id) int rv = pmem2_region_namespace(ctx, src, ®ion, &ndns); if (rv) { - LOG(1, "getting region and namespace failed"); + CORE_LOG_ERROR("getting region and namespace failed"); goto end; } diff --git a/src/libpmemobj/pmalloc.c b/src/libpmemobj/pmalloc.c index 41e9a58979d..7f81c3a4c89 100644 --- a/src/libpmemobj/pmalloc.c +++ b/src/libpmemobj/pmalloc.c @@ -567,7 +567,7 @@ CTL_WRITE_HANDLER(max)(void *ctx, int ret = heap_set_narenas_max(&pop->heap, size); if (ret) { - LOG(1, "cannot change max arena number"); + CORE_LOG_ERROR("cannot change max arena number"); return -1; } @@ -633,7 +633,7 @@ CTL_WRITE_HANDLER(arena_id)(void *ctx, * or if it is not equal zero */ if (arena_id < 1 || arena_id > narenas) { - LOG(1, "arena id outside of the allowed range: <1,%u>", + CORE_LOG_ERROR("arena id outside of the allowed range: <1,%u>", narenas); errno = ERANGE; return -1; @@ -671,14 +671,14 @@ CTL_WRITE_HANDLER(automatic)(void *ctx, enum ctl_query_source source, * or if it is not equal zero */ if (arena_id < 1 || arena_id > narenas) { - LOG(1, "arena id outside of the allowed range: <1,%u>", + CORE_LOG_ERROR("arena id outside of the allowed range: <1,%u>", narenas); errno = ERANGE; return -1; } if (arg_in != 0 && arg_in != 1) { - LOG(1, "incorrect arena state, must be 0 or 1"); + CORE_LOG_ERROR("incorrect arena state, must be 0 or 1"); return -1; } @@ -710,7 +710,7 @@ CTL_READ_HANDLER(automatic)(void *ctx, * or if it is not equal zero */ if (arena_id < 1 || arena_id > narenas) { - LOG(1, "arena id outside of the allowed range: <1,%u>", + CORE_LOG_ERROR("arena id outside of the allowed range: <1,%u>", narenas); errno = ERANGE; return -1; @@ -758,7 +758,7 @@ CTL_READ_HANDLER(size)(void *ctx, * or if it is not equal zero */ if (arena_id < 1 || arena_id > narenas) { - LOG(1, "arena id outside of the allowed range: <1,%u>", + CORE_LOG_ERROR("arena id outside of the allowed range: <1,%u>", narenas); errno = ERANGE; return -1; @@ -957,7 +957,7 @@ CTL_WRITE_HANDLER(arenas_default_max)(void *ctx, unsigned size = *(unsigned *)arg; if (size == 0) { - LOG(1, "number of default arenas can't be 0"); + CORE_LOG_ERROR("number of default arenas can't be 0"); return -1; } diff --git a/src/libpmemobj/tx.c b/src/libpmemobj/tx.c index 63eac100c33..acfcc51f29e 100644 --- a/src/libpmemobj/tx.c +++ b/src/libpmemobj/tx.c @@ -2225,7 +2225,7 @@ CTL_READ_HANDLER(threshold)(void *ctx, /* suppress unused-parameter errors */ SUPPRESS_UNUSED(ctx, source, arg, indexes); - LOG(1, "tx.cache.threshold parameter is deprecated"); + CORE_LOG_ERROR("tx.cache.threshold parameter is deprecated"); return 0; } @@ -2240,7 +2240,7 @@ CTL_WRITE_HANDLER(threshold)(void *ctx, /* suppress unused-parameter errors */ SUPPRESS_UNUSED(ctx, source, arg, indexes); - LOG(1, "tx.cache.threshold parameter is deprecated"); + CORE_LOG_ERROR("tx.cache.threshold parameter is deprecated"); return 0; } diff --git a/src/libpmemobj/ulog.c b/src/libpmemobj/ulog.c index 80569373d85..35eefd475e7 100644 --- a/src/libpmemobj/ulog.c +++ b/src/libpmemobj/ulog.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -/* Copyright 2015-2021, Intel Corporation */ +/* Copyright 2015-2024, Intel Corporation */ /* * ulog.c -- unified log implementation @@ -240,7 +240,7 @@ ulog_reserve(struct ulog *ulog, const struct pmem_ops *p_ops) { if (!auto_reserve) { - LOG(1, "cannot auto reserve next ulog"); + CORE_LOG_ERROR("cannot auto reserve next ulog"); return -1; } @@ -669,7 +669,8 @@ ulog_free_next(struct ulog *u, const struct pmem_ops *p_ops, if (VEC_PUSH_BACK(&ulogs_internal_except_first, &u->next) != 0) { /* this is fine, it will just use more pmem */ - LOG(1, "unable to free transaction logs memory"); + CORE_LOG_ERROR( + "unable to free transaction logs memory"); goto out; } u = ulog_by_offset(u->next, p_ops); diff --git a/src/libpmempool/pool.c b/src/libpmempool/pool.c index 63fb938b5f5..f6d6866e487 100644 --- a/src/libpmempool/pool.c +++ b/src/libpmempool/pool.c @@ -597,7 +597,8 @@ pool_set_part_copy(struct pool_set_part *dpart, struct pool_set_part *spart, #ifdef DEBUG /* provide extra logging in case of wrong dmapped/smapped value */ if (dmapped < smapped) { - LOG(1, "dmapped < smapped: dmapped = %lu, smapped = %lu", + CORE_LOG_ERROR( + "dmapped < smapped: dmapped = %lu, smapped = %lu", dmapped, smapped); ASSERT(0); } diff --git a/src/libpmempool/replica.c b/src/libpmempool/replica.c index a0e9eea7320..b58ae9a253d 100644 --- a/src/libpmempool/replica.c +++ b/src/libpmempool/replica.c @@ -546,7 +546,8 @@ check_and_open_poolset_part_files(struct pool_set *set, enum file_type type = util_file_get_type(path); if (type < 0 || os_access(path, R_OK|W_OK) != 0) { - LOG(1, "part file %s is not accessible", path); + CORE_LOG_ERROR("part file %s is not accessible", + path); errno = 0; rep_hs->part[p].flags |= IS_BROKEN; if (is_dry_run(flags)) @@ -555,12 +556,12 @@ check_and_open_poolset_part_files(struct pool_set *set, if (util_part_open(&rep->part[p], 0, 0)) { if (type == TYPE_DEVDAX) { - LOG(1, + CORE_LOG_ERROR( "opening part on Device DAX %s failed", path); return -1; } - LOG(1, "opening part %s failed", path); + CORE_LOG_ERROR("opening part %s failed", path); errno = 0; rep_hs->part[p].flags |= IS_BROKEN; } @@ -590,7 +591,8 @@ map_all_unbroken_headers(struct pool_set *set, LOG(4, "mapping header for part %u, replica %u", p, r); if (util_map_hdr(&rep->part[p], MAP_SHARED, 0) != 0) { - LOG(1, "header mapping failed - part #%d", p); + CORE_LOG_ERROR( + "header mapping failed - part #%d", p); rep_hs->part[p].flags |= IS_BROKEN; } } @@ -767,7 +769,7 @@ replica_part_badblocks_recovery_file_read(struct part_health_status *part_hs) do { if (fscanf(recovery_file, "%zu %zu\n", &bb.offset, &bb.length) < 2) { - LOG(1, + CORE_LOG_ERROR( "incomplete bad block recovery file -- '%s'", path); ret = 1; @@ -804,7 +806,7 @@ replica_part_badblocks_recovery_file_read(struct part_health_status *part_hs) os_fclose(recovery_file); - LOG(1, "bad blocks read from the recovery file -- '%s'", path); + CORE_LOG_ERROR("bad blocks read from the recovery file -- '%s'", path); return 0; @@ -856,7 +858,7 @@ replica_badblocks_recovery_files_check(struct pool_set *set, badblocks_recovery_file_alloc(set->path, r, p); if (part_hs->recovery_file_name == NULL) { - LOG(1, + CORE_LOG_ERROR( "allocating name of bad block recovery file failed"); return RECOVERY_FILES_ERROR; } @@ -926,21 +928,21 @@ replica_badblocks_recovery_files_read(struct pool_set *set, continue; } - LOG(1, + CORE_LOG_ERROR( "reading bad blocks from the recovery file -- '%s'", part_hs->recovery_file_name); ret = replica_part_badblocks_recovery_file_read( part_hs); if (ret < 0) { - LOG(1, + CORE_LOG_ERROR( "reading bad blocks from the recovery file failed -- '%s'", part_hs->recovery_file_name); return -1; } if (ret > 0) { - LOG(1, + CORE_LOG_ERROR( "incomplete bad block recovery file detected -- '%s'", part_hs->recovery_file_name); return 1; @@ -1042,7 +1044,7 @@ replica_badblocks_recovery_files_save(struct pool_set *set, int ret = replica_badblocks_recovery_file_save(part_hs); if (ret < 0) { - LOG(1, + CORE_LOG_ERROR( "opening bad block recovery file failed -- '%s'", part_hs->recovery_file_name); return -1; @@ -1160,7 +1162,7 @@ replica_badblocks_clear(struct pool_set *set, ret = badblocks_clear(path, &part_hs->bbs); if (ret < 0) { - LOG(1, + CORE_LOG_ERROR( "clearing bad blocks in replica failed -- '%s'", path); return -1; @@ -1201,7 +1203,7 @@ replica_badblocks_check_or_clear(struct pool_set *set, /* phase #1 - error handling */ switch (status) { case RECOVERY_FILES_ERROR: - LOG(1, "checking bad block recovery files failed"); + CORE_LOG_ERROR("checking bad block recovery files failed"); return -1; case RECOVERY_FILES_EXIST_ALL: @@ -1244,14 +1246,15 @@ replica_badblocks_check_or_clear(struct pool_set *set, /* read all bad block recovery files */ ret = replica_badblocks_recovery_files_read(set, set_hs); if (ret < 0) { - LOG(1, "checking bad block recovery files failed"); + CORE_LOG_ERROR( + "checking bad block recovery files failed"); return -1; } if (ret > 0) { /* incomplete bad block recovery file was detected */ - LOG(1, + CORE_LOG_ERROR( "warning: incomplete bad block recovery file detected\n" " - all recovery files will be removed"); @@ -1261,7 +1264,7 @@ replica_badblocks_check_or_clear(struct pool_set *set, break; case RECOVERY_FILES_NOT_ALL_EXIST: - LOG(1, + CORE_LOG_ERROR( "warning: one of bad block recovery files does not exist\n" " - all recovery files will be removed"); break; @@ -1278,15 +1281,17 @@ replica_badblocks_check_or_clear(struct pool_set *set, */ if (!dry_run) { - LOG(1, "removing all bad block recovery files..."); + CORE_LOG_ERROR( + "removing all bad block recovery files..."); ret = replica_remove_all_recovery_files(set_hs); if (ret < 0) { - LOG(1, + CORE_LOG_ERROR( "removing bad block recovery files failed"); return -1; } } else { - LOG(1, "all bad block recovery files would be removed"); + CORE_LOG_ERROR( + "all bad block recovery files would be removed"); } /* changing status to RECOVERY_FILES_DO_NOT_EXIST */ @@ -1302,11 +1307,11 @@ replica_badblocks_check_or_clear(struct pool_set *set, int bad_blocks_found = replica_badblocks_get(set, set_hs); if (bad_blocks_found < 0) { if (errno == ENOTSUP) { - LOG(1, BB_NOT_SUPP); + CORE_LOG_ERROR(BB_NOT_SUPP); return -1; } - LOG(1, "checking bad blocks failed"); + CORE_LOG_ERROR("checking bad blocks failed"); return -1; } @@ -1332,7 +1337,7 @@ replica_badblocks_check_or_clear(struct pool_set *set, if (dry_run) { /* dry-run - do nothing */ - LOG(1, "warning: bad blocks were found"); + CORE_LOG_ERROR("warning: bad blocks were found"); return 0; } @@ -1340,7 +1345,7 @@ replica_badblocks_check_or_clear(struct pool_set *set, ret = replica_badblocks_recovery_files_create_empty(set, set_hs); if (ret < 0) { - LOG(1, + CORE_LOG_ERROR( "creating empty bad block recovery files failed"); return -1; } @@ -1348,14 +1353,15 @@ replica_badblocks_check_or_clear(struct pool_set *set, /* save bad blocks in recovery files */ ret = replica_badblocks_recovery_files_save(set, set_hs); if (ret < 0) { - LOG(1, "saving bad block recovery files failed"); + CORE_LOG_ERROR( + "saving bad block recovery files failed"); return -1; } } if (dry_run) { /* dry-run - do nothing */ - LOG(1, "bad blocks would be cleared"); + CORE_LOG_ERROR("bad blocks would be cleared"); return 0; } @@ -1545,7 +1551,7 @@ check_replica_options(struct pool_set *set, unsigned repn, struct pool_hdr *hdr = HDR(rep, p); if (((hdr->features.incompat & POOL_FEAT_SINGLEHDR) == 0) != ((set->options & OPTION_SINGLEHDR) == 0)) { - LOG(1, + CORE_LOG_ERROR( "improper options are set in part %u's header in replica %u", p, repn); rep_hs->part[p].flags |= IS_BROKEN; @@ -1803,7 +1809,9 @@ check_replica_sizes(struct pool_set *set, struct poolset_health_status *set_hs) replica_pool_size = replica_get_pool_size(set, r); if (replica_pool_size < 0) { - LOG(1, "getting pool size from replica %u failed", r); + CORE_LOG_ERROR( + "getting pool size from replica %u failed", + r); set_hs->replica[r]->flags |= IS_BROKEN; continue; } @@ -1811,7 +1819,7 @@ check_replica_sizes(struct pool_set *set, struct poolset_health_status *set_hs) /* check if the pool is bigger than minimum size */ enum pool_type type = pool_hdr_get_type(HDR(REP(set, r), 0)); if ((size_t)replica_pool_size < pool_get_min_size(type)) { - LOG(1, + CORE_LOG_ERROR( "pool size from replica %u is smaller than the minimum size allowed for the pool", r); set_hs->replica[r]->flags |= IS_BROKEN; @@ -1862,7 +1870,7 @@ replica_read_features(struct pool_set *set, continue; if (util_map_hdr(part, MAP_SHARED, 0) != 0) { - LOG(1, "header mapping failed"); + CORE_LOG_ERROR("header mapping failed"); return -1; } @@ -1892,7 +1900,7 @@ replica_check_poolset_health(struct pool_set *set, set, set_hsp, called_from_sync, flags); if (replica_create_poolset_health_status(set, set_hsp)) { - LOG(1, "creating poolset health status failed"); + CORE_LOG_ERROR("creating poolset health status failed"); return -1; } @@ -1900,7 +1908,7 @@ replica_check_poolset_health(struct pool_set *set, /* check if part files exist and are accessible */ if (check_and_open_poolset_part_files(set, set_hs, flags)) { - LOG(1, "poolset part files check failed"); + CORE_LOG_ERROR("poolset part files check failed"); goto err; } @@ -1922,7 +1930,7 @@ replica_check_poolset_health(struct pool_set *set, * We will not fix bad blocks, so we have to read features here. */ if (replica_read_features(set, set_hs, &features)) { - LOG(1, "reading features failed"); + CORE_LOG_ERROR("reading features failed"); goto err; } check_bad_blks = features.compat & POOL_FEAT_CHECK_BAD_BLOCKS; @@ -1931,13 +1939,13 @@ replica_check_poolset_health(struct pool_set *set, /* check for bad blocks when in dry run or clear them otherwise */ if (replica_badblocks_check_or_clear(set, set_hs, is_dry_run(flags), called_from_sync, check_bad_blks, fix_bad_blks)) { - LOG(1, "replica bad_blocks check failed"); + CORE_LOG_ERROR("replica bad_blocks check failed"); goto err; } /* read features after fixing bad blocks */ if (fix_bad_blks && replica_read_features(set, set_hs, &features)) { - LOG(1, "reading features failed"); + CORE_LOG_ERROR("reading features failed"); goto err; } @@ -1955,47 +1963,47 @@ replica_check_poolset_health(struct pool_set *set, /* check if option flags are consistent */ if (check_options(set, set_hs)) { - LOG(1, "flags check failed"); + CORE_LOG_ERROR("flags check failed"); goto err; } if (!set->ignore_sds && check_shutdown_state(set, set_hs)) { - LOG(1, "replica shutdown_state check failed"); + CORE_LOG_ERROR("replica shutdown_state check failed"); goto err; } /* check if uuids in parts across each replica are consistent */ if (check_replicas_consistency(set, set_hs)) { - LOG(1, "replica consistency check failed"); + CORE_LOG_ERROR("replica consistency check failed"); goto err; } /* check poolset_uuid values between replicas */ if (check_poolset_uuids(set, set_hs)) { - LOG(1, "poolset uuids check failed"); + CORE_LOG_ERROR("poolset uuids check failed"); goto err; } /* check if uuids for adjacent replicas are consistent */ if (check_uuids_between_replicas(set, set_hs)) { - LOG(1, "replica uuids check failed"); + CORE_LOG_ERROR("replica uuids check failed"); goto err; } /* check if healthy replicas make up another poolset */ if (check_replica_cycles(set, set_hs)) { - LOG(1, "replica cycles check failed"); + CORE_LOG_ERROR("replica cycles check failed"); goto err; } /* check if replicas are large enough */ if (check_replica_sizes(set, set_hs)) { - LOG(1, "replica sizes check failed"); + CORE_LOG_ERROR("replica sizes check failed"); goto err; } if (check_store_all_sizes(set, set_hs)) { - LOG(1, "reading pool sizes failed"); + CORE_LOG_ERROR("reading pool sizes failed"); goto err; } @@ -2129,8 +2137,9 @@ replica_open_replica_part_files(struct pool_set *set, unsigned repn) continue; if (util_part_open(&rep->part[p], 0, 0)) { - LOG(1, "part files open failed for replica %u, part %u", - repn, p); + CORE_LOG_ERROR( + "part files open failed for replica %u, part %u", + repn, p); errno = EINVAL; goto err; } @@ -2151,7 +2160,8 @@ replica_open_poolset_part_files(struct pool_set *set) LOG(3, "set %p", set); for (unsigned r = 0; r < set->nreplicas; ++r) { if (replica_open_replica_part_files(set, r)) { - LOG(1, "opening replica %u, part files failed", r); + CORE_LOG_ERROR("opening replica %u, part files failed", + r); goto err; } } @@ -2208,7 +2218,7 @@ pmempool_syncU(const char *poolset, unsigned flags) /* sync all replicas */ if (replica_sync(set, NULL, flags)) { - LOG(1, "synchronization failed"); + CORE_LOG_ERROR("synchronization failed"); goto err_close_all; } @@ -2318,7 +2328,7 @@ pmempool_transformU(const char *poolset_src, /* transform poolset */ if (replica_transform(set_in, set_out, flags)) { - LOG(1, "transformation failed"); + CORE_LOG_ERROR("transformation failed"); goto err_free_poolout; } diff --git a/src/libpmempool/sync.c b/src/libpmempool/sync.c index bc22068f244..ef8bc70762d 100644 --- a/src/libpmempool/sync.c +++ b/src/libpmempool/sync.c @@ -98,7 +98,8 @@ sync_recreate_header(struct pool_set *set, unsigned r, unsigned p, util_pool_hdr2attr(&attr, src_hdr); if (util_header_create(set, r, p, &attr, 1) != 0) { - LOG(1, "part headers create failed for replica %u part %u", + CORE_LOG_ERROR( + "part headers create failed for replica %u part %u", r, p); errno = EINVAL; return -1; @@ -711,7 +712,7 @@ sync_check_bad_blocks_overlap(struct pool_set *set, if (pbb_all->nhealthy == NO_HEALTHY_REPLICA) { ret = 1; /* this bad block cannot be fixed */ - LOG(1, + CORE_LOG_ERROR( "uncorrectable bad block found: offset 0x%zx, length 0x%zx", pbb_all->offset, pbb_all->length); @@ -816,10 +817,10 @@ sync_badblocks_data(struct pool_set *set, struct poolset_health_status *set_hs) sync_mark_replica_no_badblocks(r, set_hs); } - LOG(1, "all bad blocks have been fixed"); + CORE_LOG_ERROR("all bad blocks have been fixed"); if (replica_remove_all_recovery_files(set_hs)) { - LOG(1, "removing bad block recovery files failed"); + CORE_LOG_ERROR("removing bad block recovery files failed"); return -1; } @@ -1317,13 +1318,13 @@ replica_sync(struct pool_set *set, struct poolset_health_status *s_hs, if (replica_check_poolset_health(set, &set_hs, 1 /* called from sync */, flags)) { - LOG(1, "poolset health check failed"); + CORE_LOG_ERROR("poolset health check failed"); return -1; } /* check if poolset is broken; if not, nothing to do */ if (replica_is_poolset_healthy(set_hs)) { - LOG(1, "poolset is healthy"); + CORE_LOG_ERROR("poolset is healthy"); goto out; } } else { @@ -1345,7 +1346,7 @@ replica_sync(struct pool_set *set, struct poolset_health_status *s_hs, /* in dry-run mode we can stop here */ if (is_dry_run(flags)) { - LOG(1, "Sync in dry-run mode finished successfully"); + CORE_LOG_ERROR("Sync in dry-run mode finished successfully"); goto out; } @@ -1376,7 +1377,7 @@ replica_sync(struct pool_set *set, struct poolset_health_status *s_hs, /* recalculate offset and length of bad blocks */ if (sync_recalc_badblocks(set, set_hs)) { - LOG(1, "syncing bad blocks data failed"); + CORE_LOG_ERROR("syncing bad blocks data failed"); ret = -1; goto out; } @@ -1387,7 +1388,7 @@ replica_sync(struct pool_set *set, struct poolset_health_status *s_hs, */ int status = sync_check_bad_blocks_overlap(set, set_hs); if (status == -1) { - LOG(1, "checking bad blocks failed"); + CORE_LOG_ERROR("checking bad blocks failed"); ret = -1; goto out; } @@ -1404,7 +1405,7 @@ replica_sync(struct pool_set *set, struct poolset_health_status *s_hs, /* sync data in bad blocks */ if (sync_badblocks_data(set, set_hs)) { - LOG(1, "syncing bad blocks data failed"); + CORE_LOG_ERROR("syncing bad blocks data failed"); ret = -1; goto out; } diff --git a/src/libpmempool/transform.c b/src/libpmempool/transform.c index 151a064e436..f130e14764d 100644 --- a/src/libpmempool/transform.c +++ b/src/libpmempool/transform.c @@ -55,8 +55,9 @@ check_if_part_used_once(struct pool_set *set, unsigned repn, unsigned partn) struct pool_replica *rep = REP(set, repn); char *path = util_part_realpath(PART(rep, partn)->path); if (path == NULL) { - LOG(1, "cannot get absolute path for %s, replica %u, part %u", - PART(rep, partn)->path, repn, partn); + CORE_LOG_ERROR( + "cannot get absolute path for %s, replica %u, part %u", + PART(rep, partn)->path, repn, partn); errno = 0; path = strdup(PART(rep, partn)->path); if (path == NULL) { @@ -80,7 +81,7 @@ check_if_part_used_once(struct pool_set *set, unsigned repn, unsigned partn) ret = -1; goto out; } - LOG(1, + CORE_LOG_ERROR( "cannot get absolute path for %s, replica %u, part %u", PART(rep, partn)->path, repn, partn); pathp = strdup(PART(repr, p)->path); @@ -258,7 +259,8 @@ check_compare_poolsets_status(struct pool_set *set_in, struct pool_replica *rep_in = REP(set_in, ri); for (unsigned ro = 0; ro < set_out->nreplicas; ++ro) { struct pool_replica *rep_out = REP(set_out, ro); - LOG(1, "comparing rep_in %u with rep_out %u", ri, ro); + CORE_LOG_ERROR("comparing rep_in %u with rep_out %u", + ri, ro); /* skip different replicas */ if (compare_replicas(rep_in, rep_out)) continue; @@ -461,8 +463,8 @@ do_added_parts_exist(struct pool_set *set, return -1; if (exists && !rep->part[p].is_dev_dax) { - LOG(1, "part file %s exists", - rep->part[p].path); + CORE_LOG_ERROR("part file %s exists", + rep->part[p].path); return 1; } errno = oerrno; @@ -502,7 +504,8 @@ copy_replica_data_fw(struct pool_set *set_dst, struct pool_set *set_src, LOG(3, "set_in %p, set_out %p, repn %u", set_src, set_dst, repn); ssize_t pool_size = replica_get_pool_size(set_src, repn); if (pool_size < 0) { - LOG(1, "getting pool size from replica %u failed", repn); + CORE_LOG_ERROR("getting pool size from replica %u failed", + repn); pool_size = (ssize_t)set_src->poolsize; } @@ -529,7 +532,8 @@ copy_replica_data_bw(struct pool_set *set_dst, struct pool_set *set_src, LOG(3, "set_in %p, set_out %p, repn %u", set_src, set_dst, repn); ssize_t pool_size = replica_get_pool_size(set_src, repn); if (pool_size < 0) { - LOG(1, "getting pool size from replica %u failed", repn); + CORE_LOG_ERROR("getting pool size from replica %u failed", + repn); pool_size = (ssize_t)set_src->poolsize; } @@ -559,8 +563,9 @@ create_missing_headers(struct pool_set *set, unsigned repn) util_pool_hdr2attr(&attr, src_hdr); attr.features.incompat &= (uint32_t)(~POOL_FEAT_SINGLEHDR); if (util_header_create(set, repn, p, &attr, 1) != 0) { - LOG(1, "part headers create failed for" - " replica %u part %u", repn, p); + CORE_LOG_ERROR( + "part headers create failed for replica %u part %u", + repn, p); errno = EINVAL; return -1; } @@ -674,7 +679,7 @@ remove_hdrs_replica(struct pool_set *set_in, struct pool_set *set_out, /* open all part files of the input replica */ if (replica_open_replica_part_files(set_in, repn)) { - LOG(1, "opening replica %u, part files failed", repn); + CORE_LOG_ERROR("opening replica %u, part files failed", repn); ret = -1; goto out; } @@ -684,14 +689,16 @@ remove_hdrs_replica(struct pool_set *set_in, struct pool_set *set_out, /* map the whole input replica */ if (util_replica_open(set_in, repn, MAP_SHARED)) { - LOG(1, "opening input replica failed: replica %u", repn); + CORE_LOG_ERROR("opening input replica failed: replica %u", + repn); ret = -1; goto out_close; } /* map the whole output replica */ if (util_replica_open(set_out, repn, MAP_SHARED)) { - LOG(1, "opening output replica failed: replica %u", repn); + CORE_LOG_ERROR("opening output replica failed: replica %u", + repn); ret = -1; goto out_unmap_in; } @@ -726,7 +733,8 @@ add_hdrs_replica(struct pool_set *set_in, struct pool_set *set_out, /* open all part files of the input replica */ if (replica_open_replica_part_files(set_in, repn)) { - LOG(1, "opening replica %u, part files failed", repn); + CORE_LOG_ERROR("opening replica %u, part files failed", + repn); ret = -1; goto out; } @@ -736,22 +744,25 @@ add_hdrs_replica(struct pool_set *set_in, struct pool_set *set_out, /* map the whole input replica */ if (util_replica_open(set_in, repn, MAP_SHARED)) { - LOG(1, "opening input replica failed: replica %u", repn); + CORE_LOG_ERROR("opening input replica failed: replica %u", + repn); ret = -1; goto out_close; } /* map the whole output replica */ if (util_replica_open(set_out, repn, MAP_SHARED)) { - LOG(1, "opening output replica failed: replica %u", repn); + CORE_LOG_ERROR("opening output replica failed: replica %u", + repn); ret = -1; goto out_unmap_in; } /* generate new uuids for lacking headers */ if (fill_replica_struct_uuids(set_out, repn)) { - LOG(1, "generating lacking uuids for parts failed: replica %u", - repn); + CORE_LOG_ERROR( + "generating lacking uuids for parts failed: replica %u", + repn); ret = -1; goto out_unmap_out; } @@ -762,7 +773,8 @@ add_hdrs_replica(struct pool_set *set_in, struct pool_set *set_out, /* create the missing headers */ if (create_missing_headers(set_out, repn)) { - LOG(1, "creating lacking headers failed: replica %u", repn); + CORE_LOG_ERROR("creating lacking headers failed: replica %u", + repn); /* * copy the data back, so we could fall back to the original * state @@ -802,7 +814,8 @@ remove_hdrs(struct pool_set *set_in, struct pool_set *set_out, set_in, set_out, set_in_hs, flags); for (unsigned r = 0; r < set_in->nreplicas; ++r) { if (remove_hdrs_replica(set_in, set_out, r)) { - LOG(1, "removing headers from replica %u failed", r); + CORE_LOG_ERROR( + "removing headers from replica %u failed", r); /* mark all previous replicas as damaged */ while (--r < set_in->nreplicas) REP_HEALTH(set_in_hs, r)->flags |= IS_BROKEN; @@ -826,7 +839,8 @@ add_hdrs(struct pool_set *set_in, struct pool_set *set_out, set_in, set_out, set_in_hs, flags); for (unsigned r = 0; r < set_in->nreplicas; ++r) { if (add_hdrs_replica(set_in, set_out, r)) { - LOG(1, "adding headers to replica %u failed", r); + CORE_LOG_ERROR("adding headers to replica %u failed", + r); /* mark all previous replicas as damaged */ while (--r < set_in->nreplicas) REP_HEALTH(set_in_hs, r)->flags |= IS_BROKEN; @@ -888,7 +902,7 @@ replica_transform(struct pool_set *set_in, struct pool_set *set_out, set_out_cs, set_in_hs, set_out_hs); if (operation == NOT_TRANSFORMABLE) { - LOG(1, "poolsets are not transformable"); + CORE_LOG_ERROR("poolsets are not transformable"); ret = -1; errno = EINVAL; goto free_cs; @@ -902,10 +916,10 @@ replica_transform(struct pool_set *set_in, struct pool_set *set_out, "removing headers failed; falling back to the input poolset"); if (replica_sync(set_in, set_in_hs, flags | IS_TRANSFORMED)) { - LOG(1, + CORE_LOG_ERROR( "falling back to the input poolset failed"); } else { - LOG(1, + CORE_LOG_ERROR( "falling back to the input poolset succeeded"); } ret = -1; @@ -920,10 +934,10 @@ replica_transform(struct pool_set *set_in, struct pool_set *set_out, "adding headers failed; falling back to the input poolset"); if (replica_sync(set_in, set_in_hs, flags | IS_TRANSFORMED)) { - LOG(1, + CORE_LOG_ERROR( "falling back to the input poolset failed"); } else { - LOG(1, + CORE_LOG_ERROR( "falling back to the input poolset succeeded"); } ret = -1; diff --git a/src/test/traces/traces.c b/src/test/traces/traces.c index 317ceb53f9a..f465729d640 100644 --- a/src/test/traces/traces.c +++ b/src/test/traces/traces.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -/* Copyright 2014-2017, Intel Corporation */ +/* Copyright 2014-2024, Intel Corporation */ /* * traces.c -- unit test for traces @@ -25,7 +25,7 @@ main(int argc, char *argv[]) common_init(LOG_PREFIX, LOG_LEVEL_VAR, LOG_FILE_VAR, MAJOR_VERSION, MINOR_VERSION); LOG(0, "Log level NONE"); - LOG(1, "Log level ERROR"); + CORE_LOG_ERROR("Log level ERROR"); LOG(2, "Log level WARNING"); LOG(3, "Log level INFO"); LOG(4, "Log level DEBUG");