Add kick function for cleaner
ocf_kick_cleaner() allows to perfom cleaning immediately. Nop cleaning policy now returns new 'OCF_CLEANER_DISABLE' macro which indicates that cleaing shouldn't be performed. To enable it back, ocf_kick_cleaner() should be called. Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
94ef5a5249
commit
7165bc16c3
@ -145,6 +145,13 @@ struct ocf_cleaner_ops {
|
|||||||
*/
|
*/
|
||||||
int (*init)(ocf_cleaner_t c);
|
int (*init)(ocf_cleaner_t c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Kick cleaner thread.
|
||||||
|
*
|
||||||
|
* @param[in] c Descriptor of cleaner to be kicked.
|
||||||
|
*/
|
||||||
|
void (*kick)(ocf_cleaner_t c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stop cleaner
|
* @brief Stop cleaner
|
||||||
*
|
*
|
||||||
|
@ -320,6 +320,15 @@ typedef enum {
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name OCF cleaner definitions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define OCF_CLEANER_DISABLE ~0U
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
#define MAX_TRIM_RQ_SIZE (1 * MiB)
|
#define MAX_TRIM_RQ_SIZE (1 * MiB)
|
||||||
|
|
||||||
#endif /* __OCF_DEF_H__ */
|
#endif /* __OCF_DEF_H__ */
|
||||||
|
@ -316,6 +316,7 @@ int cleaning_policy_acp_initialize(struct ocf_cache *cache,
|
|||||||
}
|
}
|
||||||
|
|
||||||
_acp_rebuild(cache);
|
_acp_rebuild(cache);
|
||||||
|
ocf_kick_cleaner(cache);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -336,6 +337,7 @@ int cleaning_policy_acp_set_cleaning_param(ocf_cache_t cache,
|
|||||||
config->thread_wakeup_time = param_value;
|
config->thread_wakeup_time = param_value;
|
||||||
ocf_cache_log(cache, log_info, "Write-back flush thread "
|
ocf_cache_log(cache, log_info, "Write-back flush thread "
|
||||||
"wake-up time: %d\n", config->thread_wakeup_time);
|
"wake-up time: %d\n", config->thread_wakeup_time);
|
||||||
|
ocf_kick_cleaner(cache);
|
||||||
break;
|
break;
|
||||||
case ocf_acp_flush_max_buffers:
|
case ocf_acp_flush_max_buffers:
|
||||||
OCF_CLEANING_CHECK_PARAM(cache, param_value,
|
OCF_CLEANING_CHECK_PARAM(cache, param_value,
|
||||||
|
@ -470,6 +470,8 @@ int cleaning_policy_alru_initialize(ocf_cache_t cache, int init_metadata)
|
|||||||
if (init_metadata)
|
if (init_metadata)
|
||||||
_alru_rebuild(cache);
|
_alru_rebuild(cache);
|
||||||
|
|
||||||
|
ocf_kick_cleaner(cache);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,6 +497,7 @@ int cleaning_policy_alru_set_cleaning_param(ocf_cache_t cache,
|
|||||||
config->thread_wakeup_time = param_value;
|
config->thread_wakeup_time = param_value;
|
||||||
ocf_cache_log(cache, log_info, "Write-back flush thread "
|
ocf_cache_log(cache, log_info, "Write-back flush thread "
|
||||||
"wake-up time: %d\n", config->thread_wakeup_time);
|
"wake-up time: %d\n", config->thread_wakeup_time);
|
||||||
|
ocf_kick_cleaner(cache);
|
||||||
break;
|
break;
|
||||||
case ocf_alru_stale_buffer_time:
|
case ocf_alru_stale_buffer_time:
|
||||||
OCF_CLEANING_CHECK_PARAM(cache, param_value,
|
OCF_CLEANING_CHECK_PARAM(cache, param_value,
|
||||||
|
@ -59,6 +59,11 @@ void ocf_stop_cleaner(ocf_cache_t cache)
|
|||||||
ctx_cleaner_stop(cache->owner, &cache->cleaner);
|
ctx_cleaner_stop(cache->owner, &cache->cleaner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ocf_kick_cleaner(ocf_cache_t cache)
|
||||||
|
{
|
||||||
|
ctx_cleaner_kick(cache->owner, &cache->cleaner);
|
||||||
|
}
|
||||||
|
|
||||||
void ocf_cleaner_set_cmpl(ocf_cleaner_t cleaner, ocf_cleaner_end_t fn)
|
void ocf_cleaner_set_cmpl(ocf_cleaner_t cleaner, ocf_cleaner_end_t fn)
|
||||||
{
|
{
|
||||||
cleaner->end = fn;
|
cleaner->end = fn;
|
||||||
|
@ -68,6 +68,8 @@ struct ocf_cleaner {
|
|||||||
|
|
||||||
int ocf_start_cleaner(ocf_cache_t cache);
|
int ocf_start_cleaner(ocf_cache_t cache);
|
||||||
|
|
||||||
|
void ocf_kick_cleaner(ocf_cache_t cache);
|
||||||
|
|
||||||
void ocf_stop_cleaner(ocf_cache_t cache);
|
void ocf_stop_cleaner(ocf_cache_t cache);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,6 +9,5 @@
|
|||||||
|
|
||||||
void cleaning_nop_perform_cleaning(ocf_cache_t cache, ocf_cleaner_end_t cmpl)
|
void cleaning_nop_perform_cleaning(ocf_cache_t cache, ocf_cleaner_end_t cmpl)
|
||||||
{
|
{
|
||||||
uint32_t interval = SLEEP_TIME_MS;
|
cmpl(&cache->cleaner, OCF_CLEANER_DISABLE);
|
||||||
cmpl(&cache->cleaner, interval);
|
|
||||||
}
|
}
|
||||||
|
@ -1347,6 +1347,15 @@ static void _ocf_mngt_attach_init_instance(ocf_pipeline_t pipeline,
|
|||||||
{
|
{
|
||||||
struct ocf_cache_attach_context *context = priv;
|
struct ocf_cache_attach_context *context = priv;
|
||||||
ocf_cache_t cache = context->cache;
|
ocf_cache_t cache = context->cache;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
result = ocf_start_cleaner(cache);
|
||||||
|
if (result) {
|
||||||
|
ocf_cache_log(cache, log_err,
|
||||||
|
"Error while starting cleaner\n");
|
||||||
|
OCF_PL_FINISH_RET(context->pipeline, result);
|
||||||
|
}
|
||||||
|
context->flags.cleaner_started = true;
|
||||||
|
|
||||||
switch (cache->device->init_mode) {
|
switch (cache->device->init_mode) {
|
||||||
case ocf_init_mode_init:
|
case ocf_init_mode_init:
|
||||||
@ -1503,17 +1512,6 @@ static void _ocf_mngt_attach_post_init(ocf_pipeline_t pipeline,
|
|||||||
{
|
{
|
||||||
struct ocf_cache_attach_context *context = priv;
|
struct ocf_cache_attach_context *context = priv;
|
||||||
ocf_cache_t cache = context->cache;
|
ocf_cache_t cache = context->cache;
|
||||||
int result;
|
|
||||||
|
|
||||||
if (!context->flags.cleaner_started) {
|
|
||||||
result = ocf_start_cleaner(cache);
|
|
||||||
if (result) {
|
|
||||||
ocf_cache_log(cache, log_err,
|
|
||||||
"Error while starting cleaner\n");
|
|
||||||
OCF_PL_FINISH_RET(context->pipeline, result);
|
|
||||||
}
|
|
||||||
context->flags.cleaner_started = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ocf_cleaner_refcnt_unfreeze(cache);
|
ocf_cleaner_refcnt_unfreeze(cache);
|
||||||
ocf_refcnt_unfreeze(&cache->refcnt.metadata);
|
ocf_refcnt_unfreeze(&cache->refcnt.metadata);
|
||||||
|
@ -146,6 +146,11 @@ static inline void ctx_cleaner_stop(ocf_ctx_t ctx, ocf_cleaner_t cleaner)
|
|||||||
ctx->ops->cleaner.stop(cleaner);
|
ctx->ops->cleaner.stop(cleaner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void ctx_cleaner_kick(ocf_ctx_t ctx, ocf_cleaner_t cleaner)
|
||||||
|
{
|
||||||
|
ctx->ops->cleaner.kick(cleaner);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int ctx_metadata_updater_init(ocf_ctx_t ctx,
|
static inline int ctx_metadata_updater_init(ocf_ctx_t ctx,
|
||||||
ocf_metadata_updater_t mu)
|
ocf_metadata_updater_t mu)
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,10 @@ from .shared import SharedOcfObject
|
|||||||
|
|
||||||
class CleanerOps(Structure):
|
class CleanerOps(Structure):
|
||||||
INIT = CFUNCTYPE(c_int, c_void_p)
|
INIT = CFUNCTYPE(c_int, c_void_p)
|
||||||
|
KICK = CFUNCTYPE(None, c_void_p)
|
||||||
STOP = CFUNCTYPE(None, c_void_p)
|
STOP = CFUNCTYPE(None, c_void_p)
|
||||||
|
|
||||||
_fields_ = [("init", INIT), ("stop", STOP)]
|
_fields_ = [("init", INIT), ("kick", KICK), ("stop", STOP)]
|
||||||
|
|
||||||
|
|
||||||
class Cleaner(SharedOcfObject):
|
class Cleaner(SharedOcfObject):
|
||||||
@ -24,13 +25,18 @@ class Cleaner(SharedOcfObject):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_ops(cls):
|
def get_ops(cls):
|
||||||
return CleanerOps(init=cls._init, stop=cls._stop)
|
return CleanerOps(init=cls._init, kick=cls._kick, stop=cls._stop)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@CleanerOps.INIT
|
@CleanerOps.INIT
|
||||||
def _init(cleaner):
|
def _init(cleaner):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@CleanerOps.KICK
|
||||||
|
def _kick(cleaner):
|
||||||
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@CleanerOps.STOP
|
@CleanerOps.STOP
|
||||||
def _stop(cleaner):
|
def _stop(cleaner):
|
||||||
|
Loading…
Reference in New Issue
Block a user