A utility to continue pipeline on zero refcnt
Signed-off-by: Roel Apfelbaum <roel.apfelbaum@huawei.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
7685b70810
commit
b02481cf74
@ -2145,22 +2145,14 @@ struct ocf_mngt_cache_unplug_context {
|
||||
int cache_write_error;
|
||||
};
|
||||
|
||||
static void ocf_mngt_cache_stop_wait_metadata_io_finish(void *priv)
|
||||
{
|
||||
struct ocf_mngt_cache_unplug_context *context = priv;
|
||||
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
}
|
||||
|
||||
static void ocf_mngt_cache_stop_wait_metadata_io(ocf_pipeline_t pipeline,
|
||||
void *priv, ocf_pipeline_arg_t arg)
|
||||
{
|
||||
struct ocf_mngt_cache_unplug_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
struct env_refcnt *refcnt = &context->cache->refcnt.metadata;
|
||||
|
||||
env_refcnt_freeze(&cache->refcnt.metadata);
|
||||
env_refcnt_register_zero_cb(&cache->refcnt.metadata,
|
||||
ocf_mngt_cache_stop_wait_metadata_io_finish, context);
|
||||
env_refcnt_freeze(refcnt);
|
||||
ocf_mngt_continue_pipeline_on_zero_refcnt(refcnt, context->pipeline);
|
||||
}
|
||||
|
||||
static void ocf_mngt_cache_stop_check_dirty(ocf_pipeline_t pipeline,
|
||||
@ -2566,22 +2558,14 @@ struct ocf_cache_standby_detach_context {
|
||||
void *priv;
|
||||
};
|
||||
|
||||
static void _ocf_mngt_standby_detach_wait_metadata_io_finish(void *priv)
|
||||
{
|
||||
struct ocf_cache_standby_detach_context *context = priv;
|
||||
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_standby_detach_wait_metadata_io(ocf_pipeline_t pipeline,
|
||||
void *priv, ocf_pipeline_arg_t arg)
|
||||
{
|
||||
struct ocf_cache_standby_detach_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
struct env_refcnt *refcnt = &context->cache->refcnt.metadata;
|
||||
|
||||
env_refcnt_freeze(&cache->refcnt.metadata);
|
||||
env_refcnt_register_zero_cb(&cache->refcnt.metadata,
|
||||
_ocf_mngt_standby_detach_wait_metadata_io_finish, context);
|
||||
env_refcnt_freeze(refcnt);
|
||||
ocf_mngt_continue_pipeline_on_zero_refcnt(refcnt, context->pipeline);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_activate_set_cache_device(ocf_pipeline_t pipeline,
|
||||
@ -3812,21 +3796,14 @@ static void ocf_mngt_cache_detach_flush(ocf_pipeline_t pipeline,
|
||||
ocf_mngt_cache_flush(cache, ocf_mngt_cache_detach_flush_cmpl, context);
|
||||
}
|
||||
|
||||
static void ocf_mngt_cache_detach_stop_cache_io_finish(void *priv)
|
||||
{
|
||||
struct ocf_mngt_cache_unplug_context *context = priv;
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
}
|
||||
|
||||
static void ocf_mngt_cache_detach_stop_cache_io(ocf_pipeline_t pipeline,
|
||||
void *priv, ocf_pipeline_arg_t arg)
|
||||
{
|
||||
struct ocf_mngt_cache_unplug_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
struct env_refcnt *refcnt = &context->cache->refcnt.metadata;
|
||||
|
||||
env_refcnt_freeze(&cache->refcnt.metadata);
|
||||
env_refcnt_register_zero_cb(&cache->refcnt.metadata,
|
||||
ocf_mngt_cache_detach_stop_cache_io_finish, context);
|
||||
env_refcnt_freeze(refcnt);
|
||||
ocf_mngt_continue_pipeline_on_zero_refcnt(refcnt, context->pipeline);
|
||||
}
|
||||
|
||||
static void ocf_mngt_cache_detach_stop_cleaner_io_finish(void *priv)
|
||||
|
@ -515,3 +515,16 @@ int ocf_mngt_cache_visit_reverse(ocf_ctx_t ocf_ctx,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void _ocf_mngt_continue_pipeline_on_zero_refcnt_cb(void *priv)
|
||||
{
|
||||
ocf_pipeline_next((ocf_pipeline_t)priv);
|
||||
}
|
||||
|
||||
void ocf_mngt_continue_pipeline_on_zero_refcnt(struct env_refcnt *refcnt,
|
||||
ocf_pipeline_t pipeline)
|
||||
{
|
||||
env_refcnt_register_zero_cb(refcnt,
|
||||
_ocf_mngt_continue_pipeline_on_zero_refcnt_cb,
|
||||
pipeline);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2021 Intel Corporation
|
||||
* Copyright(c) 2025 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@ -7,6 +8,9 @@
|
||||
#ifndef __OCF_MNGT_COMMON_H__
|
||||
#define __OCF_MNGT_COMMON_H__
|
||||
|
||||
#include "ocf_env_refcnt.h"
|
||||
#include "../utils/utils_pipeline.h"
|
||||
|
||||
void cache_mngt_core_deinit(ocf_core_t core);
|
||||
|
||||
void cache_mngt_core_remove_from_meta(ocf_core_t core);
|
||||
@ -33,4 +37,7 @@ bool ocf_mngt_cache_is_locked(ocf_cache_t cache);
|
||||
void __set_cleaning_policy(ocf_cache_t cache,
|
||||
ocf_cleaning_t new_cleaning_policy);
|
||||
|
||||
void ocf_mngt_continue_pipeline_on_zero_refcnt(struct env_refcnt *refcnt,
|
||||
ocf_pipeline_t pipeline);
|
||||
|
||||
#endif /* __OCF_MNGT_COMMON_H__ */
|
||||
|
@ -82,12 +82,6 @@ struct ocf_mngt_cache_flush_context
|
||||
struct flush_containers_context fcs;
|
||||
};
|
||||
|
||||
static void _ocf_mngt_begin_flush_complete(void *priv)
|
||||
{
|
||||
struct ocf_mngt_cache_flush_context *context = priv;
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_begin_flush(ocf_pipeline_t pipeline, void *priv,
|
||||
ocf_pipeline_arg_t arg)
|
||||
{
|
||||
@ -105,8 +99,8 @@ static void _ocf_mngt_begin_flush(ocf_pipeline_t pipeline, void *priv,
|
||||
env_refcnt_freeze(&cache->refcnt.dirty);
|
||||
context->flags.freeze = true;
|
||||
|
||||
env_refcnt_register_zero_cb(&cache->refcnt.dirty,
|
||||
_ocf_mngt_begin_flush_complete, context);
|
||||
ocf_mngt_continue_pipeline_on_zero_refcnt(&cache->refcnt.dirty,
|
||||
context->pipeline);
|
||||
}
|
||||
|
||||
bool ocf_mngt_core_is_dirty(ocf_core_t core)
|
||||
|
Loading…
Reference in New Issue
Block a user