Skip to content

Commit

Permalink
DAOS-16465 vos: fix misused ip_hdl (#15034) (#15043)
Browse files Browse the repository at this point in the history
vos_iter_param_t.ip_hdl is for passing dkey or akey tree open handle
in vos_iterate_key() case, don't always regard it as 'vos_pool' or
'vos_container'.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
  • Loading branch information
NiuYawei authored Sep 2, 2024
1 parent f4ae244 commit 1ccdef3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/include/daos_srv/vos_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ typedef int (*vos_iter_filter_cb_t)(daos_handle_t ih, vos_iter_desc_t *desc,
* Parameters for initializing VOS iterator
*/
typedef struct {
/** pool connection handle or container open handle */
/** pool connection handle or container open handle,
* for vos_iterate_key(), it's used for passing dkey or akey tree open handle.
*/
daos_handle_t ip_hdl;
/** standalone prepare: DAOS_HDL_INVAL
* nested prepare: parent iterator handle
Expand Down
5 changes: 5 additions & 0 deletions src/vos/vos_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ is_sysdb_pool(vos_iter_type_t type, vos_iter_param_t *param)
struct vos_pool *vos_pool;
struct vos_container *vos_cont;

/* vos_iterate_key() will never be called upon sysdb */
if (param->ip_flags == VOS_IT_KEY_TREE)
return false;

D_ASSERT(!(param->ip_flags & VOS_IT_KEY_TREE));
if (type == VOS_ITER_COUUID) {
vos_pool = vos_hdl2pool(param->ip_hdl);
D_ASSERT(vos_pool != NULL);
Expand Down
13 changes: 10 additions & 3 deletions src/vos/vos_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1689,16 +1689,23 @@ vos_obj_iter_prep(vos_iter_type_t type, vos_iter_param_t *param,
struct vos_ts_set *ts_set)
{
struct vos_obj_iter *oiter;
struct vos_container *cont = vos_hdl2cont(param->ip_hdl);
bool is_sysdb = cont->vc_pool->vp_sysdb;
struct dtx_handle *dth = vos_dth_get(is_sysdb);
struct vos_container *cont = NULL;
bool is_sysdb = false;
struct dtx_handle *dth = NULL;
daos_epoch_t bound;
int rc;

D_ALLOC_PTR(oiter);
if (oiter == NULL)
return -DER_NOMEM;

/* ip_hdl is dkey or akey tree open handle for vos_iterate_key() */
if (!(param->ip_flags & VOS_IT_KEY_TREE)) {
cont = vos_hdl2cont(param->ip_hdl);
is_sysdb = cont->vc_pool->vp_sysdb;
dth = vos_dth_get(is_sysdb);
}

bound = dtx_is_valid_handle(dth) ? dth->dth_epoch_bound :
param->ip_epr.epr_hi;
oiter->it_iter.it_bound = MAX(bound, param->ip_epr.epr_hi);
Expand Down

0 comments on commit 1ccdef3

Please sign in to comment.