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
1 change: 1 addition & 0 deletions src/include/daos_srv/vos.h
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,7 @@ struct scrub_ctx {
sc_sleep_fn_t sc_sleep_fn;
sc_yield_fn_t sc_yield_fn;
void *sc_sched_arg;
uint32_t sc_filter_credits;

enum scrub_status sc_status;
uint8_t sc_cont_loaded : 1, /* Have all the containers been loaded */
Expand Down
2 changes: 1 addition & 1 deletion src/vos/vos_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ vos_iterate_obj(vos_iter_param_t *param, struct vos_iter_anchors *anchors, vos_i
return vos_iterate_internal(param, VOS_ITER_OBJ, true, false, anchors, pre_cb,
post_cb, arg, dth);

/* The caller must provide a filter callback and call the oi_bkt_iter_skip() properly */
/* The caller must provide a filter callback and call the vos_bkt_iter_skip() properly */
D_ASSERT(param->ip_filter_cb != NULL && param->ip_bkt_iter == NULL);

bkt_iter = bkt_iter_alloc(cont->vc_pool);
Expand Down
30 changes: 30 additions & 0 deletions src/vos/vos_pool_scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,31 @@ obj_iter_scrub_pre_cb(daos_handle_t ih, vos_iter_entry_t *entry,
return 0;
}

/* Yield if scrubber consecutively skips too many objects */
#define SCRUB_FILTER_CREDITS 64

static int
sc_obj_filter_cb(daos_handle_t ih, vos_iter_desc_t *desc, void *cb_arg, unsigned int *acts)
{
struct scrub_ctx *ctx = cb_arg;

if (desc->id_type == VOS_ITER_OBJ) {
if (vos_bkt_iter_skip(ih, desc)) {
*acts |= VOS_ITER_CB_SKIP;

D_ASSERT(ctx->sc_filter_credits > 0);
if (--ctx->sc_filter_credits == 0) {
ctx->sc_filter_credits = SCRUB_FILTER_CREDITS;
sc_sleep(ctx, 0);
}
} else {
ctx->sc_filter_credits = SCRUB_FILTER_CREDITS;
}
}

return 0;
}

static int
sc_scrub_cont(struct scrub_ctx *ctx)
{
Expand All @@ -737,10 +762,15 @@ sc_scrub_cont(struct scrub_ctx *ctx)
if (!daos_csummer_initialized(sc_csummer(ctx)))
return 0;

ctx->sc_filter_credits = SCRUB_FILTER_CREDITS;

param.ip_hdl = sc_cont_hdl(ctx);
param.ip_epr.epr_hi = DAOS_EPOCH_MAX;
param.ip_epr.epr_lo = 0;
param.ip_epc_expr = VOS_IT_EPC_RE;
param.ip_filter_cb = sc_obj_filter_cb;
param.ip_filter_arg = ctx;

/*
* FIXME: Improve iteration by only iterating over visible
* recxs (set param.ip_flags = VOS_IT_RECX_VISIBLE). Will have to be
Expand Down
Loading