From 7b88aac56ff99e7786775c3002e2e44fffa4ebfe Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Tue, 7 May 2019 14:01:44 +0200 Subject: [PATCH] Remove "interruption" argument from flush() functions As non-interruptible flushes are no longer triggered from OCF internals, we can get rid of "interruption" argument and let adapters handle it themselves. Signed-off-by: Robert Baldyga --- inc/ocf_mngt.h | 6 ++---- src/mngt/ocf_mngt_cache.c | 3 +-- src/mngt/ocf_mngt_flush.c | 26 +++++++------------------- tests/functional/pyocf/types/cache.py | 2 +- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/inc/ocf_mngt.h b/inc/ocf_mngt.h index 95991a8..1a5fbbd 100644 --- a/inc/ocf_mngt.h +++ b/inc/ocf_mngt.h @@ -532,11 +532,10 @@ typedef void (*ocf_mngt_cache_flush_end_t)(ocf_cache_t cache, * @brief Flush data from given cache * * @param[in] cache Cache handle - * @param[in] interruption Allow for interruption * @param[in] cmpl Completion callback * @param[in] priv Completion callback context */ -void ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption, +void ocf_mngt_cache_flush(ocf_cache_t cache, ocf_mngt_cache_flush_end_t cmpl, void *priv); /** @@ -553,11 +552,10 @@ typedef void (*ocf_mngt_core_flush_end_t)(ocf_core_t core, * @brief Flush data to given core * * @param[in] core Core handle - * @param[in] interruption Allow for interruption * @param[in] cmpl Completion callback * @param[in] priv Completion callback context */ -void ocf_mngt_core_flush(ocf_core_t core, bool interruption, +void ocf_mngt_core_flush(ocf_core_t core, ocf_mngt_core_flush_end_t cmpl, void *priv); /** diff --git a/src/mngt/ocf_mngt_cache.c b/src/mngt/ocf_mngt_cache.c index b535415..68e5119 100644 --- a/src/mngt/ocf_mngt_cache.c +++ b/src/mngt/ocf_mngt_cache.c @@ -2291,8 +2291,7 @@ static void ocf_mngt_cache_detach_flush(ocf_pipeline_t pipeline, struct ocf_mngt_cache_detach_context *context = priv; ocf_cache_t cache = context->cache; - ocf_mngt_cache_flush(cache, true, ocf_mngt_cache_detach_flush_cmpl, - context); + ocf_mngt_cache_flush(cache, ocf_mngt_cache_detach_flush_cmpl, context); } static void ocf_mngt_cache_detach_wait_pending(ocf_pipeline_t pipeline, diff --git a/src/mngt/ocf_mngt_flush.c b/src/mngt/ocf_mngt_flush.c index 05fcd15..5163816 100644 --- a/src/mngt/ocf_mngt_flush.c +++ b/src/mngt/ocf_mngt_flush.c @@ -46,8 +46,6 @@ struct ocf_mngt_cache_flush_context ocf_cache_t cache; /* target core */ ocf_core_t core; - /* true if flush interrupt respected */ - bool allow_interruption; /* management operation identifier */ enum { @@ -364,18 +362,11 @@ static void _ocf_mngt_flush_portion_end(void *private_data, int error) env_atomic_cmpxchg(&fsc->error, 0, error); if (cache->flushing_interrupted) { - first_interrupt = !env_atomic_cmpxchg(&fsc->interrupt_seen, 0, 1); + first_interrupt = !env_atomic_cmpxchg( + &fsc->interrupt_seen, 0, 1); if (first_interrupt) { - if (context->allow_interruption) { - ocf_cache_log(cache, log_info, - "Flushing interrupted by " - "user\n"); - } else { - ocf_cache_log(cache, log_err, - "Cannot interrupt flushing\n"); - } - } - if (context->allow_interruption) { + ocf_cache_log(cache, log_info, + "Flushing interrupted by user\n"); env_atomic_cmpxchg(&fsc->error, 0, -OCF_ERR_FLUSHING_INTERRUPTED); } @@ -598,6 +589,7 @@ static void _ocf_mngt_cache_flush(ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg) { struct ocf_mngt_cache_flush_context *context = priv; + context->cache->flushing_interrupted = 0; _ocf_mngt_flush_all_cores(context, _ocf_mngt_flush_all_cores_complete); } @@ -657,7 +649,7 @@ static struct ocf_pipeline_properties _ocf_mngt_cache_flush_pipeline_properties }, }; -void ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption, +void ocf_mngt_cache_flush(ocf_cache_t cache, ocf_mngt_cache_flush_end_t cmpl, void *priv) { ocf_pipeline_t pipeline; @@ -695,7 +687,6 @@ void ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption, context->cmpl.flush_cache = cmpl; context->priv = priv; context->cache = cache; - context->allow_interruption = interruption; context->op = flush_cache; ocf_pipeline_next(context->pipeline); @@ -744,7 +735,7 @@ struct ocf_pipeline_properties _ocf_mngt_core_flush_pipeline_properties = { }, }; -void ocf_mngt_core_flush(ocf_core_t core, bool interruption, +void ocf_mngt_core_flush(ocf_core_t core, ocf_mngt_core_flush_end_t cmpl, void *priv) { ocf_pipeline_t pipeline; @@ -785,7 +776,6 @@ void ocf_mngt_core_flush(ocf_core_t core, bool interruption, context->cmpl.flush_core = cmpl; context->priv = priv; context->cache = cache; - context->allow_interruption = interruption; context->op = flush_core; context->core = core; @@ -845,7 +835,6 @@ void ocf_mngt_cache_purge(ocf_cache_t cache, context->cmpl.purge_cache = cmpl; context->priv = priv; context->cache = cache; - context->allow_interruption = true; context->op = purge_cache; context->purge.core_id = OCF_CORE_ID_INVALID; context->purge.end_byte = ~0ULL; @@ -899,7 +888,6 @@ void ocf_mngt_core_purge(ocf_core_t core, context->cmpl.purge_core = cmpl; context->priv = priv; context->cache = cache; - context->allow_interruption = true; context->op = purge_core; context->purge.core_id = core_id; context->purge.end_byte = core_size ?: ~0ULL; diff --git a/tests/functional/pyocf/types/cache.py b/tests/functional/pyocf/types/cache.py index c452124..0853ee6 100644 --- a/tests/functional/pyocf/types/cache.py +++ b/tests/functional/pyocf/types/cache.py @@ -505,7 +505,7 @@ class Cache: c = OcfCompletion( [("cache", c_void_p), ("priv", c_void_p), ("error", c_int)] ) - self.owner.lib.ocf_mngt_cache_flush(self.cache_handle, False, c, None) + self.owner.lib.ocf_mngt_cache_flush(self.cache_handle, c, None) c.wait() if c.results["error"]: self.put_and_write_unlock()