Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/pool_map.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2024 Intel Corporation.

Check failure on line 2 in src/common/pool_map.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -1999,6 +1999,7 @@
struct pool_domain *tmp;
int i;

D_ASSERT(map != NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please explain the reason for adding all those asserts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current code can't handle 'map == NULL' case, it indicates a bug if the assert happens. Adding these asserts would be helpful on catching regressions. (if some new code calls these functions with NULL map).

if (pool_map_empty(map)) {
D_ERROR("Uninitialized pool map\n");
return 0;
Expand Down Expand Up @@ -2051,6 +2052,7 @@
pool_map_find_ranks(struct pool_map *map, uint32_t id,
struct pool_domain **domain_pp)
{
D_ASSERT(map != NULL);
return pool_map_find_domain(map, PO_COMP_TP_RANK, id,
domain_pp);
}
Expand Down Expand Up @@ -2109,6 +2111,7 @@
int doms_cnt;
int i;

D_ASSERT(map != NULL);
doms_cnt = pool_map_find_ranks(map, PO_COMP_ID_ALL, &doms);
if (doms_cnt <= 0)
return NULL;
Expand Down Expand Up @@ -2191,6 +2194,7 @@
{
struct pool_domain *dom;

D_ASSERT(map != NULL);
dom = pool_map_find_dom_by_rank(map, rank);
if (dom == NULL)
return 0;
Expand Down
9 changes: 8 additions & 1 deletion src/pool/srv_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,13 @@ check_pool_targets(uuid_t pool_id, int *tgt_ids, int tgt_cnt, bool reint,

nr_downout = nr_down = nr_upin = nr_up = 0;
ABT_rwlock_rdlock(pool->sp_lock);

if (pool->sp_map == NULL) {
D_ERROR(DF_UUID ": Pool map not populated\n", DP_UUID(pool_id));
rc = -DER_UNINIT;
goto done;
}

for (i = 0; i < tgt_cnt; i++) {
nr = pool_map_find_target_by_rank_idx(pool->sp_map, rank,
tgt_ids[i], &target);
Expand Down Expand Up @@ -1560,7 +1567,7 @@ check_pool_targets(uuid_t pool_id, int *tgt_ids, int tgt_cnt, bool reint,
break;
}
}

done:
if (pool->sp_iv_ns != NULL) {
*pl_rank = pool->sp_iv_ns->iv_master_rank;
} else {
Expand Down
Loading