diff --git a/inc/ocf_mngt.h b/inc/ocf_mngt.h index 3c48018..d1285ae 100644 --- a/inc/ocf_mngt.h +++ b/inc/ocf_mngt.h @@ -605,6 +605,15 @@ typedef void (*ocf_mngt_cache_flush_end_t)(ocf_cache_t cache, void ocf_mngt_cache_flush(ocf_cache_t cache, ocf_mngt_cache_flush_end_t cmpl, void *priv); +/** + * @brief Check if core is dirty + * + * @param[in] core Core handle + * + * @retval true if core is dirty, false otherwise + */ +bool ocf_mngt_core_is_dirty(ocf_core_t core); + /** * @brief Check if cache is dirty * diff --git a/src/cleaning/cleaning.c b/src/cleaning/cleaning.c index d99940e..cf72ae4 100644 --- a/src/cleaning/cleaning.c +++ b/src/cleaning/cleaning.c @@ -96,8 +96,7 @@ static int _ocf_cleaner_run_check_dirty_inactive(ocf_cache_t cache) return 0; for_each_core(cache, core, core_id) { - if (core->opened && env_atomic_read( - &core->runtime_meta->dirty_clines)) { + if (core->opened && ocf_mngt_core_is_dirty(core)) { return 0; } } diff --git a/src/mngt/ocf_mngt_flush.c b/src/mngt/ocf_mngt_flush.c index df49e3e..a09f82c 100644 --- a/src/mngt/ocf_mngt_flush.c +++ b/src/mngt/ocf_mngt_flush.c @@ -105,6 +105,11 @@ static void _ocf_mngt_end_flush(ocf_cache_t cache) env_mutex_unlock(&cache->flush_mutex); } +bool ocf_mngt_core_is_dirty(ocf_core_t core) +{ + return !!env_atomic_read(&core->runtime_meta->dirty_clines); +} + bool ocf_mngt_cache_is_dirty(ocf_cache_t cache) { ocf_core_t core; @@ -113,7 +118,7 @@ bool ocf_mngt_cache_is_dirty(ocf_cache_t cache) OCF_CHECK_NULL(cache); for_each_core(cache, core, core_id) { - if (env_atomic_read(&core->runtime_meta->dirty_clines)) + if (ocf_mngt_core_is_dirty(core)) return true; }