Skip to content

Commit

Permalink
DAOS-16569 vos: avoid find in emtpy daos array
Browse files Browse the repository at this point in the history
DAOS array doesn't support searching in empty array.

Required-githooks: true

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
  • Loading branch information
NiuYawei committed Sep 24, 2024
1 parent 8717180 commit 6488828
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/vos/vos_obj_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ vos_bkt_array_subset(struct vos_bkt_array *super, struct vos_bkt_array *sub)
{
int i, idx;

D_ASSERT(sub->vba_cnt > 0);
if (sub->vba_cnt > super->vba_cnt)
return false;

Expand All @@ -844,9 +845,11 @@ vos_bkt_array_add(struct vos_bkt_array *bkts, uint32_t bkt_id)
D_ASSERT(bkt_id != UMEM_DEFAULT_MBKT_ID);

/* The @bkt_id is already in bucket array */
idx = daos_array_find(bkts->vba_bkts, bkts->vba_cnt, bkt_id, &bkt_sort_ops);
if (idx >= 0)
return 0;
if (bkts->vba_cnt > 0) {
idx = daos_array_find(bkts->vba_bkts, bkts->vba_cnt, bkt_id, &bkt_sort_ops);
if (idx >= 0)
return 0;
}

/* Bucket array needs be expanded */
if (bkts->vba_cnt == bkts->vba_tot) {
Expand Down

0 comments on commit 6488828

Please sign in to comment.