Skip to content

Commit

Permalink
common: convert LOG(1,...) into CORE_LOG_ERROR()
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
  • Loading branch information
grom72 committed Jan 29, 2024
1 parent 3ae2638 commit 28f81da
Show file tree
Hide file tree
Showing 28 changed files with 206 additions and 161 deletions.
13 changes: 7 additions & 6 deletions src/common/bad_blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
};
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/file_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
17 changes: 9 additions & 8 deletions src/common/os_deep_linux.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
}
Expand Down
38 changes: 22 additions & 16 deletions src/common/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -3023,22 +3029,22 @@ 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;
}

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 {
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions src/common/set_badblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/util_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libpmem/pmem_posix.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/libpmem2/auto_flush_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/libpmem2/badblocks_ndctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pmem2_badblock_context_new(struct pmem2_badblock_context **bbctx,

ret = pmem2_region_namespace(ctx, src, &region, &ndns);
if (ret) {
LOG(1, "getting region and namespace failed");
CORE_LOG_ERROR("getting region and namespace failed");
goto exit_ndctl_unref;
}

Expand Down Expand Up @@ -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;
}

Expand 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;
}
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion src/libpmem2/deep_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit 28f81da

Please sign in to comment.