Merge pull request #732 from pdebski21/pipeline_conditional_step
Validate metadata segments in cleaning section - Pipeline conditional step
This commit is contained in:
commit
6d1270cdd4
@ -976,7 +976,6 @@ struct ocf_pipeline_arg ocf_metadata_flush_all_args[] = {
|
|||||||
OCF_PL_ARG_INT(metadata_segment_sb_runtime),
|
OCF_PL_ARG_INT(metadata_segment_sb_runtime),
|
||||||
OCF_PL_ARG_INT(metadata_segment_part_runtime),
|
OCF_PL_ARG_INT(metadata_segment_part_runtime),
|
||||||
OCF_PL_ARG_INT(metadata_segment_core_runtime),
|
OCF_PL_ARG_INT(metadata_segment_core_runtime),
|
||||||
OCF_PL_ARG_INT(metadata_segment_cleaning),
|
|
||||||
OCF_PL_ARG_INT(metadata_segment_lru),
|
OCF_PL_ARG_INT(metadata_segment_lru),
|
||||||
OCF_PL_ARG_INT(metadata_segment_collision),
|
OCF_PL_ARG_INT(metadata_segment_collision),
|
||||||
OCF_PL_ARG_INT(metadata_segment_list_info),
|
OCF_PL_ARG_INT(metadata_segment_list_info),
|
||||||
@ -984,12 +983,31 @@ struct ocf_pipeline_arg ocf_metadata_flush_all_args[] = {
|
|||||||
OCF_PL_ARG_TERMINATOR(),
|
OCF_PL_ARG_TERMINATOR(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Predicate function checking whether disable cleaner option is set
|
||||||
|
*/
|
||||||
|
static bool ocf_check_if_cleaner_enabled(ocf_pipeline_t pipeline,
|
||||||
|
void* priv, ocf_pipeline_arg_t arg)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_context *context = priv;
|
||||||
|
|
||||||
|
return !context->cache->conf_meta->cleaner_disabled;
|
||||||
|
}
|
||||||
|
|
||||||
struct ocf_pipeline_properties ocf_metadata_flush_all_pipeline_props = {
|
struct ocf_pipeline_properties ocf_metadata_flush_all_pipeline_props = {
|
||||||
.priv_size = sizeof(struct ocf_metadata_context),
|
.priv_size = sizeof(struct ocf_metadata_context),
|
||||||
.finish = ocf_metadata_flush_all_finish,
|
.finish = ocf_metadata_flush_all_finish,
|
||||||
.steps = {
|
.steps = {
|
||||||
|
|
||||||
|
OCF_PL_STEP_COND_ARG_INT(ocf_check_if_cleaner_enabled,
|
||||||
|
ocf_metadata_flush_segment,
|
||||||
|
metadata_segment_cleaning),
|
||||||
OCF_PL_STEP_FOREACH(ocf_metadata_flush_segment,
|
OCF_PL_STEP_FOREACH(ocf_metadata_flush_segment,
|
||||||
ocf_metadata_flush_all_args),
|
ocf_metadata_flush_all_args),
|
||||||
|
|
||||||
|
OCF_PL_STEP_COND_ARG_INT(ocf_check_if_cleaner_enabled,
|
||||||
|
ocf_metadata_calculate_crc,
|
||||||
|
metadata_segment_cleaning),
|
||||||
OCF_PL_STEP_FOREACH(ocf_metadata_calculate_crc,
|
OCF_PL_STEP_FOREACH(ocf_metadata_calculate_crc,
|
||||||
ocf_metadata_flush_all_args),
|
ocf_metadata_flush_all_args),
|
||||||
OCF_PL_STEP_ARG_INT(ocf_metadata_flush_all_set_status,
|
OCF_PL_STEP_ARG_INT(ocf_metadata_flush_all_set_status,
|
||||||
@ -1118,7 +1136,6 @@ out:
|
|||||||
|
|
||||||
struct ocf_pipeline_arg ocf_metadata_load_all_args[] = {
|
struct ocf_pipeline_arg ocf_metadata_load_all_args[] = {
|
||||||
OCF_PL_ARG_INT(metadata_segment_core_runtime),
|
OCF_PL_ARG_INT(metadata_segment_core_runtime),
|
||||||
OCF_PL_ARG_INT(metadata_segment_cleaning),
|
|
||||||
OCF_PL_ARG_INT(metadata_segment_lru),
|
OCF_PL_ARG_INT(metadata_segment_lru),
|
||||||
OCF_PL_ARG_INT(metadata_segment_collision),
|
OCF_PL_ARG_INT(metadata_segment_collision),
|
||||||
OCF_PL_ARG_INT(metadata_segment_list_info),
|
OCF_PL_ARG_INT(metadata_segment_list_info),
|
||||||
@ -1130,8 +1147,15 @@ struct ocf_pipeline_properties ocf_metadata_load_all_pipeline_props = {
|
|||||||
.priv_size = sizeof(struct ocf_metadata_context),
|
.priv_size = sizeof(struct ocf_metadata_context),
|
||||||
.finish = ocf_metadata_load_all_finish,
|
.finish = ocf_metadata_load_all_finish,
|
||||||
.steps = {
|
.steps = {
|
||||||
|
OCF_PL_STEP_COND_ARG_INT(ocf_check_if_cleaner_enabled,
|
||||||
|
ocf_metadata_load_segment,
|
||||||
|
metadata_segment_cleaning),
|
||||||
OCF_PL_STEP_FOREACH(ocf_metadata_load_segment,
|
OCF_PL_STEP_FOREACH(ocf_metadata_load_segment,
|
||||||
ocf_metadata_load_all_args),
|
ocf_metadata_load_all_args),
|
||||||
|
|
||||||
|
OCF_PL_STEP_COND_ARG_INT(ocf_check_if_cleaner_enabled,
|
||||||
|
ocf_metadata_check_crc,
|
||||||
|
metadata_segment_cleaning),
|
||||||
OCF_PL_STEP_FOREACH(ocf_metadata_check_crc,
|
OCF_PL_STEP_FOREACH(ocf_metadata_check_crc,
|
||||||
ocf_metadata_load_all_args),
|
ocf_metadata_load_all_args),
|
||||||
OCF_PL_STEP_TERMINATOR(),
|
OCF_PL_STEP_TERMINATOR(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright(c) 2019-2021 Intel Corporation
|
* Copyright(c) 2019-2022 Intel Corporation
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -39,6 +39,13 @@ static int _ocf_pipeline_run_step(struct ocf_request *req)
|
|||||||
pipeline->next_step++;
|
pipeline->next_step++;
|
||||||
step->hndl(pipeline, pipeline->priv, &step->arg);
|
step->hndl(pipeline, pipeline->priv, &step->arg);
|
||||||
return 0;
|
return 0;
|
||||||
|
case ocf_pipeline_step_conditional:
|
||||||
|
pipeline->next_step++;
|
||||||
|
if (step->pred(pipeline, pipeline->priv, &step->arg)) {
|
||||||
|
step->hndl(pipeline, pipeline->priv, &step->arg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
case ocf_pipeline_step_foreach:
|
case ocf_pipeline_step_foreach:
|
||||||
arg = &step->args[pipeline->next_arg++];
|
arg = &step->args[pipeline->next_arg++];
|
||||||
if (arg->type == ocf_pipeline_arg_terminator) {
|
if (arg->type == ocf_pipeline_arg_terminator) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright(c) 2019-2021 Intel Corporation
|
* Copyright(c) 2019-2022 Intel Corporation
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,6 +11,7 @@
|
|||||||
enum ocf_pipeline_step_type {
|
enum ocf_pipeline_step_type {
|
||||||
ocf_pipeline_step_single,
|
ocf_pipeline_step_single,
|
||||||
ocf_pipeline_step_foreach,
|
ocf_pipeline_step_foreach,
|
||||||
|
ocf_pipeline_step_conditional,
|
||||||
ocf_pipeline_step_terminator,
|
ocf_pipeline_step_terminator,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,9 +66,13 @@ typedef void (*ocf_pipeline_step_hndl_t)(ocf_pipeline_t pipeline,
|
|||||||
typedef void (*ocf_pipeline_finish_t)(ocf_pipeline_t pipeline,
|
typedef void (*ocf_pipeline_finish_t)(ocf_pipeline_t pipeline,
|
||||||
void *priv, int error);
|
void *priv, int error);
|
||||||
|
|
||||||
|
typedef bool (*ocf_pipeline_cond_step_predicate_t)(ocf_pipeline_t pipeline,
|
||||||
|
void *priv, ocf_pipeline_arg_t arg);
|
||||||
|
|
||||||
struct ocf_pipeline_step {
|
struct ocf_pipeline_step {
|
||||||
enum ocf_pipeline_step_type type;
|
enum ocf_pipeline_step_type type;
|
||||||
ocf_pipeline_step_hndl_t hndl;
|
ocf_pipeline_step_hndl_t hndl;
|
||||||
|
ocf_pipeline_cond_step_predicate_t pred;
|
||||||
union {
|
union {
|
||||||
struct ocf_pipeline_arg arg;
|
struct ocf_pipeline_arg arg;
|
||||||
struct ocf_pipeline_arg *args;
|
struct ocf_pipeline_arg *args;
|
||||||
@ -112,6 +117,35 @@ struct ocf_pipeline_step {
|
|||||||
.type = ocf_pipeline_step_terminator, \
|
.type = ocf_pipeline_step_terminator, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OCF_PL_STEP_COND(_pred, _hndl) \
|
||||||
|
{ \
|
||||||
|
.pred = _pred, \
|
||||||
|
.type = ocf_pipeline_step_conditional, \
|
||||||
|
.hndl = _hndl, \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OCF_PL_STEP_COND_ARG_INT(_pred, _hndl, _int) \
|
||||||
|
{ \
|
||||||
|
.pred = _pred, \
|
||||||
|
.type = ocf_pipeline_step_conditional, \
|
||||||
|
.hndl = _hndl, \
|
||||||
|
.arg = { \
|
||||||
|
.type = ocf_pipeline_arg_int, \
|
||||||
|
.val.i = _int, \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OCF_PL_STEP_COND_ARG_PTR(_pred, _hndl, _ptr) \
|
||||||
|
{ \
|
||||||
|
.pred = _pred, \
|
||||||
|
.type = ocf_pipeline_step_conditional, \
|
||||||
|
.hndl = _hndl, \
|
||||||
|
.arg = { \
|
||||||
|
.type = ocf_pipeline_arg_ptr, \
|
||||||
|
.val.p = _ptr, \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
struct ocf_pipeline_properties {
|
struct ocf_pipeline_properties {
|
||||||
uint32_t priv_size;
|
uint32_t priv_size;
|
||||||
ocf_pipeline_finish_t finish;
|
ocf_pipeline_finish_t finish;
|
||||||
|
Loading…
Reference in New Issue
Block a user