Skip to content

Commit

Permalink
common: addjust logging levels
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 31, 2024
1 parent 99898a1 commit 62846c6
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 70 deletions.
26 changes: 13 additions & 13 deletions src/common/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ util_file_map_whole(const char *path)

ssize_t size = util_fd_get_size(fd);
if (size < 0) {
CORE_LOG_WARNING("cannot determine file length \"%s\"", path);
CORE_LOG_ERROR("cannot determine file length \"%s\"", path);
goto out;
}

addr = util_map(fd, 0, (size_t)size, MAP_SHARED, 0, 0, NULL);
if (addr == NULL) {
CORE_LOG_WARNING("failed to map entire file \"%s\"", path);
CORE_LOG_ERROR("failed to map entire file \"%s\"", path);
goto out;
}

Expand Down Expand Up @@ -247,13 +247,13 @@ util_file_zero(const char *path, os_off_t off, size_t len)

ssize_t size = util_fd_get_size(fd);
if (size < 0) {
CORE_LOG_WARNING("cannot determine file length \"%s\"", path);
CORE_LOG_ERROR("cannot determine file length \"%s\"", path);
ret = -1;
goto out;
}

if (off > size) {
CORE_LOG_WARNING("offset beyond file length, %ju > %ju", off,
CORE_LOG_ERROR("offset beyond file length, %ju > %ju", off,
size);
ret = -1;
goto out;
Expand All @@ -269,7 +269,7 @@ util_file_zero(const char *path, os_off_t off, size_t len)

void *addr = util_map(fd, 0, (size_t)size, MAP_SHARED, 0, 0, NULL);
if (addr == NULL) {
CORE_LOG_WARNING("failed to map entire file \"%s\"", path);
CORE_LOG_ERROR("failed to map entire file \"%s\"", path);
ret = -1;
goto out;
}
Expand Down Expand Up @@ -304,7 +304,7 @@ util_file_pwrite(const char *path, const void *buffer, size_t size,
if (type == TYPE_NORMAL) {
int fd = util_file_open(path, NULL, 0, O_RDWR);
if (fd < 0) {
CORE_LOG_WARNING("failed to open file \"%s\"", path);
CORE_LOG_ERROR("failed to open file \"%s\"", path);
return -1;
}

Expand All @@ -317,7 +317,7 @@ util_file_pwrite(const char *path, const void *buffer, size_t size,

ssize_t file_size = util_file_get_size(path);
if (file_size < 0) {
CORE_LOG_WARNING("cannot determine file length \"%s\"", path);
CORE_LOG_ERROR("cannot determine file length \"%s\"", path);
return -1;
}

Expand All @@ -332,7 +332,7 @@ util_file_pwrite(const char *path, const void *buffer, size_t size,

void *addr = util_file_map_whole(path);
if (addr == NULL) {
CORE_LOG_WARNING("failed to map entire file \"%s\"", path);
CORE_LOG_ERROR("failed to map entire file \"%s\"", path);
return -1;
}

Expand All @@ -358,7 +358,7 @@ util_file_pread(const char *path, void *buffer, size_t size,
if (type == TYPE_NORMAL) {
int fd = util_file_open(path, NULL, 0, O_RDONLY);
if (fd < 0) {
CORE_LOG_WARNING("failed to open file \"%s\"", path);
CORE_LOG_ERROR("failed to open file \"%s\"", path);
return -1;
}

Expand All @@ -371,13 +371,13 @@ util_file_pread(const char *path, void *buffer, size_t size,

ssize_t file_size = util_file_get_size(path);
if (file_size < 0) {
CORE_LOG_WARNING("cannot determine file length \"%s\"", path);
CORE_LOG_ERROR("cannot determine file length \"%s\"", path);
return -1;
}

size_t max_size = (size_t)(file_size - offset);
if (size > max_size) {
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"requested size of read goes beyond the file length, %zu > %zu",
size, max_size);
LOG(4, "adjusting size to %zu", max_size);
Expand All @@ -386,7 +386,7 @@ util_file_pread(const char *path, void *buffer, size_t size,

void *addr = util_file_map_whole(path);
if (addr == NULL) {
CORE_LOG_WARNING("failed to map entire file \"%s\"", path);
CORE_LOG_ERROR("failed to map entire file \"%s\"", path);
return -1;
}

Expand Down Expand Up @@ -544,7 +544,7 @@ util_unlink_flock(const char *path)

int fd = util_file_open(path, NULL, 0, O_RDONLY);
if (fd < 0) {
CORE_LOG_WARNING("failed to open file \"%s\"", path);
CORE_LOG_ERROR("failed to open file \"%s\"", path);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/os_deep_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ os_deep_type(const struct map_tracker *mt, void *addr, size_t len)
"deep_flush not supported");
} else {
errno = pmem2_err_to_errno(ret);
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"cannot write to deep_flush in region %u",
mt->region_id);
}
Expand Down
46 changes: 23 additions & 23 deletions src/common/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ util_poolset_open(struct pool_set *set)
{
for (unsigned r = 0; r < set->nreplicas; ++r) {
if (util_replica_open(set, r, MAP_SHARED)) {
CORE_LOG_WARNING("replica open failed: replica %u", r);
CORE_LOG_ERROR("replica open failed: replica %u", r);
errno = EINVAL;
return -1;
}
Expand Down Expand Up @@ -1050,7 +1050,7 @@ util_poolset_directory_load(struct pool_replica **repp, const char *directory)

ssize_t size = util_file_get_size(entry->path);
if (size < 0) {
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"cannot read size of file (%s) in a poolset directory",
entry->path);
goto err;
Expand Down Expand Up @@ -1481,7 +1481,7 @@ util_part_open(struct pool_set_part *part, size_t minsize, int create_part)
part->fd = util_file_create(part->path, part->filesize,
minsize);
if (part->fd == -1) {
CORE_LOG_WARNING("failed to create file: %s",
CORE_LOG_ERROR("failed to create file: %s",
part->path);
return -1;
}
Expand All @@ -1491,7 +1491,7 @@ util_part_open(struct pool_set_part *part, size_t minsize, int create_part)
int flags = O_RDWR;
part->fd = util_file_open(part->path, &size, minsize, flags);
if (part->fd == -1) {
CORE_LOG_WARNING("failed to open file: %s", part->path);
CORE_LOG_ERROR("failed to open file: %s", part->path);
return -1;
}

Expand Down Expand Up @@ -1969,7 +1969,7 @@ util_replica_map_local(struct pool_set *set, unsigned repidx, int flags)
/* map the first part and reserve space for remaining parts */
if (util_map_part(&rep->part[0], addr, rep->resvsize, 0,
flags, 0) != 0) {
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"pool mapping failed - replica #%u part #0",
repidx);
return -1;
Expand Down Expand Up @@ -2013,7 +2013,7 @@ util_replica_map_local(struct pool_set *set, unsigned repidx, int flags)
munmap(addr, rep->resvsize - mapsize);
break;
}
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"usable space mapping failed - part #%d",
p);
goto err;
Expand Down Expand Up @@ -2082,15 +2082,15 @@ util_replica_init_headers_local(struct pool_set *set, unsigned repidx,
/* map all headers - don't care about the address */
for (unsigned p = 0; p < rep->nhdrs; p++) {
if (util_map_hdr(&rep->part[p], flags, 0) != 0) {
CORE_LOG_WARNING("header mapping failed - part #%d", p);
CORE_LOG_ERROR("header mapping failed - part #%d", p);
goto err;
}
}

/* create headers, set UUID's */
for (unsigned p = 0; p < rep->nhdrs; p++) {
if (util_header_create(set, repidx, p, attr, 0) != 0) {
CORE_LOG_WARNING("header creation failed - part #%d",
CORE_LOG_ERROR("header creation failed - part #%d",
p);
goto err;
}
Expand Down Expand Up @@ -2127,7 +2127,7 @@ util_replica_create_local(struct pool_set *set, unsigned repidx, int flags,
*/
if (PART(REP(set, repidx), 0)->addr == NULL) {
if (util_replica_map_local(set, repidx, flags) != 0) {
CORE_LOG_WARNING("replica #%u map failed", repidx);
CORE_LOG_ERROR("replica #%u map failed", repidx);
return -1;
}
}
Expand All @@ -2136,7 +2136,7 @@ util_replica_create_local(struct pool_set *set, unsigned repidx, int flags,
return 0;

if (util_replica_init_headers_local(set, repidx, flags, attr) != 0) {
CORE_LOG_WARNING("replica #%u headers initialization failed",
CORE_LOG_ERROR("replica #%u headers initialization failed",
repidx);
return -1;
}
Expand Down Expand Up @@ -2395,7 +2395,7 @@ util_pool_create_uuids(struct pool_set **setp, const char *path,
int ret = util_poolset_create_set(setp, path, poolsize, minsize,
IGNORE_SDS(attr));
if (ret < 0) {
CORE_LOG_WARNING("cannot create pool set -- '%s'", path);
CORE_LOG_ERROR("cannot create pool set -- '%s'", path);
return -1;
}

Expand Down Expand Up @@ -2482,7 +2482,7 @@ util_pool_create_uuids(struct pool_set **setp, const char *path,
/* generate pool set UUID */
ret = util_uuid_generate(set->uuid);
if (ret < 0) {
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"cannot generate pool set UUID");
goto err_poolset;
}
Expand All @@ -2494,8 +2494,8 @@ util_pool_create_uuids(struct pool_set **setp, const char *path,
for (unsigned i = 0; i < rep->nhdrs; i++) {
ret = util_uuid_generate(rep->part[i].uuid);
if (ret < 0) {
CORE_LOG_WARNING(
"cannot generate pool set part UUID");
CORE_LOG_ERROR(
"cannot generate pool set part UUID");
goto err_poolset;
}
}
Expand All @@ -2521,7 +2521,7 @@ util_pool_create_uuids(struct pool_set **setp, const char *path,
for (unsigned r = 0; r < set->nreplicas; r++) {
if (util_replica_create_local(set, r, flags, attr) !=
0) {
CORE_LOG_WARNING("replica #%u creation failed", r);
CORE_LOG_ERROR("replica #%u creation failed", r);
goto err_create;
}
}
Expand Down Expand Up @@ -2598,7 +2598,7 @@ util_replica_open_local(struct pool_set *set, unsigned repidx, int flags)
/* map the first part and reserve space for remaining parts */
if (util_map_part(&rep->part[0], addr, rep->resvsize, 0,
flags, 0) != 0) {
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"pool mapping failed - replica #%u part #0",
repidx);
return -1;
Expand All @@ -2612,7 +2612,7 @@ util_replica_open_local(struct pool_set *set, unsigned repidx, int flags)
/* map all headers - don't care about the address */
for (unsigned p = 0; p < rep->nhdrs; p++) {
if (util_map_hdr(&rep->part[p], flags, 0) != 0) {
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"header mapping failed - part #%d", p);
goto err;
}
Expand Down Expand Up @@ -2659,7 +2659,7 @@ util_replica_open_local(struct pool_set *set, unsigned repidx, int flags)
rep->resvsize);
break;
}
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"usable space mapping failed - part #%d",
p);
goto err;
Expand Down Expand Up @@ -2790,7 +2790,7 @@ util_replica_check(struct pool_set *set, const struct pool_attr *attr)
struct pool_replica *rep = set->replica[r];
for (unsigned p = 0; p < rep->nhdrs; p++) {
if (util_header_check(set, r, p, attr) != 0) {
CORE_LOG_WARNING(
CORE_LOG_ERROR(
"header check failed - part #%d", p);
return -1;
}
Expand Down Expand Up @@ -2820,7 +2820,7 @@ util_replica_check(struct pool_set *set, const struct pool_attr *attr)
ASSERTne(rep->nparts, 0);
if (shutdown_state_check(&sds, &HDR(rep, 0)->sds,
rep)) {
CORE_LOG_WARNING("ADR failure detected");
CORE_LOG_ERROR("ADR failure detected");
errno = EINVAL;
return -1;
}
Expand Down Expand Up @@ -2913,7 +2913,7 @@ util_pool_open_nocheck(struct pool_set *set, unsigned flags)

for (unsigned r = 0; r < set->nreplicas; r++) {
if (util_replica_open(set, r, mmap_flags) != 0) {
CORE_LOG_WARNING("replica #%u open failed", r);
CORE_LOG_ERROR("replica #%u open failed", r);
goto err_replica;
}
}
Expand Down Expand Up @@ -3004,7 +3004,7 @@ util_pool_open(struct pool_set **setp, const char *path, size_t minpartsize,
int ret = util_poolset_create_set(setp, path, 0, 0,
flags & POOL_OPEN_IGNORE_SDS);
if (ret < 0) {
CORE_LOG_WARNING("cannot open pool set -- '%s'", path);
CORE_LOG_ERROR("cannot open pool set -- '%s'", path);
return -1;
}

Expand Down Expand Up @@ -3076,7 +3076,7 @@ util_pool_open(struct pool_set **setp, const char *path, size_t minpartsize,

for (unsigned r = 0; r < set->nreplicas; r++) {
if (util_replica_open(set, r, mmap_flags) != 0) {
CORE_LOG_WARNING("replica #%u open failed", r);
CORE_LOG_ERROR("replica #%u open failed", r);
goto err_replica;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/shutdown_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ shutdown_state_add_part(struct shutdown_state *sds, int fd,
ERR_WO_ERRNO(
"Cannot read unsafe shutdown count. For more information please check https://github.com/pmem/pmdk/issues/4207");
}
CORE_LOG_WARNING("cannot read unsafe shutdown count for %d",
CORE_LOG_ERROR("cannot read unsafe shutdown count for %d",
fd);
goto err;
}
Expand Down
12 changes: 6 additions & 6 deletions src/common/uuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ util_uuid_to_string(const uuid_t u, char *buf)
int len; /* size that is returned from sprintf call */

if (buf == NULL) {
CORE_LOG_WARNING("invalid buffer for uuid string");
CORE_LOG_ERROR("invalid buffer for uuid string");
return -1;
}

if (u == NULL) {
CORE_LOG_WARNING("invalid uuid structure");
CORE_LOG_ERROR("invalid uuid structure");
return -1;
}

Expand All @@ -38,7 +38,7 @@ util_uuid_to_string(const uuid_t u, char *buf)
uuid->node[5]);

if (len != POOL_HDR_UUID_STR_LEN - 1) {
CORE_LOG_WARNING("snprintf(uuid): %d", len);
CORE_LOG_ERROR("snprintf(uuid): %d", len);
return -1;
}

Expand All @@ -56,13 +56,13 @@ int
util_uuid_from_string(const char uuid[POOL_HDR_UUID_STR_LEN], struct uuid *ud)
{
if (strlen(uuid) != 36) {
CORE_LOG_WARNING("invalid uuid string");
CORE_LOG_ERROR("invalid uuid string");
return -1;
}

if (uuid[8] != '-' || uuid[13] != '-' || uuid[18] != '-' ||
uuid[23] != '-') {
CORE_LOG_WARNING("invalid uuid string");
CORE_LOG_ERROR("invalid uuid string");
return -1;
}

Expand All @@ -75,7 +75,7 @@ util_uuid_from_string(const char uuid[POOL_HDR_UUID_STR_LEN], struct uuid *ud)
&ud->node[5]);

if (n != 11) {
CORE_LOG_WARNING("sscanf(uuid)");
CORE_LOG_ERROR("sscanf(uuid)");
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/uuid_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ util_uuid_generate(uuid_t uuid)
int fd = os_open(POOL_HDR_UUID_GEN_FILE, O_RDONLY);
if (fd < 0) {
/* Fatal error */
CORE_LOG_WARNING_W_ERRNO("open(uuid)");
CORE_LOG_ERROR_WITH_ERRNO("open(uuid)");
return -1;
}
ssize_t num = read(fd, uu, POOL_HDR_UUID_STR_LEN);
if (num < POOL_HDR_UUID_STR_LEN) {
/* Fatal error */
CORE_LOG_WARNING_W_ERRNO("read(uuid)");
CORE_LOG_ERROR_W_ERRNO("read(uuid)");
os_close(fd);
return -1;
}
Expand Down
Loading

0 comments on commit 62846c6

Please sign in to comment.