-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAOS-16749 vos: OI iterator for phase2 pool #15465
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -343,8 +343,7 @@ vos_agg_filter(daos_handle_t ih, vos_iter_desc_t *desc, void *cb_arg, unsigned i | |
struct vos_agg_param *agg_param = cb_arg; | ||
int rc = 0; | ||
|
||
rc = need_aggregate(ih, agg_param, desc); | ||
if (rc == 0) { | ||
if (!need_aggregate(ih, agg_param, desc)) { | ||
if (desc->id_type == VOS_ITER_OBJ) { | ||
D_DEBUG(DB_EPC, "Skip untouched oid:"DF_UOID"\n", | ||
DP_UOID(desc->id_oid)); | ||
|
@@ -359,9 +358,6 @@ vos_agg_filter(daos_handle_t ih, vos_iter_desc_t *desc, void *cb_arg, unsigned i | |
D_GOTO(out, rc = 0); | ||
} | ||
|
||
if (rc < 0) /** Ignore the filter error, let iterator handle it on actual probe */ | ||
D_GOTO(out, rc = 0); | ||
|
||
if (desc->id_type == VOS_ITER_OBJ) | ||
rc = oi_iter_check_punch(ih); | ||
else | ||
|
@@ -373,8 +369,14 @@ vos_agg_filter(daos_handle_t ih, vos_iter_desc_t *desc, void *cb_arg, unsigned i | |
inc_agg_counter(agg_param, desc->id_type, AGG_OP_DEL); | ||
D_GOTO(out, rc = 0); | ||
} | ||
out: | ||
|
||
/* This MUST be the last check */ | ||
if (desc->id_type == VOS_ITER_OBJ && vos_bkt_iter_skip(ih, desc)) { | ||
credits_consume(&agg_param->ap_credits, AGG_OP_SCAN); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are a lot of objects to be skipped, will it exhaust the credits before arriving at the object(s) that needs aggregation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's a very common case today. |
||
*acts |= VOS_ITER_CB_SKIP; | ||
D_GOTO(out, rc = 0); | ||
} | ||
out: | ||
if (credits_exhausted(&agg_param->ap_credits) || | ||
(DAOS_FAIL_CHECK(DAOS_VOS_AGG_RANDOM_YIELD) && (rand() % 2))) { | ||
D_DEBUG(DB_EPC, "Credits exhausted, type:%u, acts:%u\n", desc->id_type, *acts); | ||
|
@@ -2707,9 +2709,8 @@ vos_aggregate(daos_handle_t coh, daos_epoch_range_t *epr, | |
|
||
ad->ad_iter_param.ip_flags |= VOS_IT_FOR_PURGE | VOS_IT_FOR_AGG; | ||
retry: | ||
rc = vos_iterate(&ad->ad_iter_param, VOS_ITER_OBJ, true, &ad->ad_anchors, | ||
vos_aggregate_pre_cb, vos_aggregate_post_cb, | ||
&ad->ad_agg_param, NULL); | ||
rc = vos_iterate_obj(&ad->ad_iter_param, true, &ad->ad_anchors, vos_aggregate_pre_cb, | ||
vos_aggregate_post_cb, &ad->ad_agg_param, NULL); | ||
if (rc == -DER_BUSY) { | ||
/** Hit a conflict with obj_discard. Rather than exiting, let's | ||
* yield and try again. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1045,6 +1045,81 @@ vos_iterate_key(struct vos_object *obj, daos_handle_t toh, vos_iter_type_t type, | |
return rc; | ||
} | ||
|
||
static inline void | ||
bkt_iter_free(struct vos_bkt_iter *bkt_iter) | ||
{ | ||
D_FREE(bkt_iter); | ||
} | ||
|
||
static struct vos_bkt_iter * | ||
bkt_iter_alloc(struct vos_pool *pool) | ||
{ | ||
struct umem_store *store = vos_pool2store(pool); | ||
struct umem_cache *cache = store->cache; | ||
struct vos_bkt_iter *bkt_iter; | ||
unsigned int bitmap_sz; | ||
|
||
D_ASSERT(cache != NULL && cache->ca_md_pages > 0); | ||
bitmap_sz = (cache->ca_md_pages + NBBY - 1) / NBBY; | ||
D_ALLOC(bkt_iter, sizeof(*bkt_iter) + bitmap_sz); | ||
if (bkt_iter == NULL) | ||
return NULL; | ||
|
||
bkt_iter->bi_bkt_tot = cache->ca_md_pages; | ||
bkt_iter->bi_bkt_cur = UMEM_DEFAULT_MBKT_ID; | ||
|
||
return bkt_iter; | ||
} | ||
|
||
int | ||
vos_iterate_obj(vos_iter_param_t *param, bool recursive, struct vos_iter_anchors *anchors, | ||
vos_iter_cb_t pre_cb, vos_iter_cb_t post_cb, void *arg, struct dtx_handle *dth) | ||
{ | ||
struct vos_container *cont; | ||
struct vos_bkt_iter *bkt_iter; | ||
uint32_t i, iter_cnt = 0; | ||
int rc = 0; | ||
|
||
/* Not supposed being called by external enumeration which updating read timestamp */ | ||
D_ASSERT(!dtx_is_valid_handle(dth)); | ||
|
||
cont = vos_hdl2cont(param->ip_hdl); | ||
if (!vos_pool_is_evictable(cont->vc_pool)) | ||
return vos_iterate_internal(param, VOS_ITER_OBJ, recursive, false, anchors, | ||
pre_cb, post_cb, arg, dth); | ||
|
||
/* The caller must provide a filter callback and call the oi_bkt_iter_skip() properly */ | ||
D_ASSERT(param->ip_filter_cb != NULL && param->ip_bkt_iter == NULL); | ||
|
||
bkt_iter = bkt_iter_alloc(cont->vc_pool); | ||
if (bkt_iter == NULL) | ||
return -DER_NOMEM; | ||
|
||
param->ip_bkt_iter = bkt_iter; | ||
for (i = UMEM_DEFAULT_MBKT_ID; i < bkt_iter->bi_bkt_tot; i++) { | ||
if (i > UMEM_DEFAULT_MBKT_ID) { | ||
/* The bucket wasn't skipped in prior rounds of iterating */ | ||
if (!isset(&bkt_iter->bi_skipped[0], i)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's not set, which means the bucket wasn't skipped by checking bucket ID, then we can skip iterating on this bucket ID, so it's "!isset()". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, confused. If it is not marked as skipped, then we should call the subsequent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's not marked as skipped (skipped due to unmatched bkt ID), then we don't need to call following vos_iterate_internal() for this bucket, otherwise (there were some objects was skipped due to unmatched bkt ID), we have to call vos_iterate_internal() for this bucket. Does it make sense? |
||
continue; | ||
bkt_iter->bi_bkt_cur = i; | ||
} | ||
|
||
iter_cnt++; | ||
rc = vos_iterate_internal(param, VOS_ITER_OBJ, recursive, false, anchors, | ||
pre_cb, post_cb, arg, dth); | ||
if (rc) { | ||
DL_ERROR(rc, "Iterate bucket:%u failed.", i); | ||
break; | ||
} | ||
} | ||
D_DEBUG(DB_TRACE, "Iterate %u/%u buckets.\n", iter_cnt, bkt_iter->bi_bkt_tot); | ||
|
||
bkt_iter_free(bkt_iter); | ||
param->ip_bkt_iter = NULL; | ||
|
||
return rc; | ||
} | ||
|
||
/** | ||
* Iterate VOS entries (i.e., containers, objects, dkeys, etc.) and call \a | ||
* cb(\a arg) for each entry. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it must be the last check, then do not need "goto done".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I was just thinking that some other operations (not related to skip check) could be added in the future. I can remove it if the patch needs be refreshed.