From 64a79086a8529da6e85d96c0b02c502de2aa701b Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Fri, 10 May 2019 09:28:28 -0400 Subject: [PATCH 1/2] Removed core pool initializing from adapter. As core pool is initialized by OCF, it is no longer required to do it in adapter Signed-off-by: Michal Mielewczyk --- modules/cas_cache/context.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/cas_cache/context.c b/modules/cas_cache/context.c index 025ed1b..acf3e8c 100644 --- a/modules/cas_cache/context.c +++ b/modules/cas_cache/context.c @@ -426,8 +426,6 @@ int cas_initialize_context(void) goto err_block_dev; } - ocf_mngt_core_pool_init(cas_ctx); - return 0; err_block_dev: @@ -444,7 +442,6 @@ err_ctx: int cas_cleanup_context(void) { - ocf_mngt_core_pool_deinit(cas_ctx); block_dev_deinit(); atomic_dev_deinit(); cas_garbage_collector_deinit(); From 095ccc51fef741a40c3c6a473cf057b676d8cee8 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Mon, 29 Apr 2019 09:51:51 -0400 Subject: [PATCH 2/2] Added possibility to disable cleaner thread. In case of cleaner thread retrived 'OCF_CLEANER_DISABLE' no cleaning is performed until kick is called. Signed-off-by: Michal Mielewczyk --- modules/cas_cache/context.c | 6 ++++++ modules/cas_cache/threads.c | 27 +++++++++++++++++++++++++-- modules/cas_cache/threads.h | 1 + ocf | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/modules/cas_cache/context.c b/modules/cas_cache/context.c index acf3e8c..aaf9f6d 100644 --- a/modules/cas_cache/context.c +++ b/modules/cas_cache/context.c @@ -271,6 +271,11 @@ static int _cas_ctx_cleaner_init(ocf_cleaner_t c) return cas_create_cleaner_thread(c); } +static void _cas_ctx_cleaner_kick(ocf_cleaner_t c) +{ + return cas_kick_cleaner_thread(c); +} + static void _cas_ctx_cleaner_stop(ocf_cleaner_t c) { return cas_stop_cleaner_thread(c); @@ -364,6 +369,7 @@ static const struct ocf_ctx_config ctx_cfg = { .cleaner = { .init = _cas_ctx_cleaner_init, + .kick = _cas_ctx_cleaner_kick, .stop = _cas_ctx_cleaner_stop, }, diff --git a/modules/cas_cache/threads.c b/modules/cas_cache/threads.c index 83af4c2..76fc245 100644 --- a/modules/cas_cache/threads.c +++ b/modules/cas_cache/threads.c @@ -89,11 +89,27 @@ static int _cas_cleaner_thread(void *data) ocf_cleaner_set_cmpl(c, _cas_cleaner_complete); do { + if (atomic_read(&info->stop)) + break; + + atomic_set(&info->kicked, 0); init_completion(&info->sync_compl); ocf_cleaner_run(c, cache_priv->io_queues[smp_processor_id()]); wait_for_completion(&info->sync_compl); - } while (0 == wait_event_interruptible_timeout(info->wq, - atomic_read(&info->stop), msecs_to_jiffies(ms))); + + /* + * In case of nop cleaning policy we don't want to perform cleaning + * until cleaner_kick() is called. + */ + if (ms == OCF_CLEANER_DISABLE) { + wait_event_interruptible(info->wq, atomic_read(&info->kicked) || + atomic_read(&info->stop)); + } else { + wait_event_interruptible_timeout(info->wq, + atomic_read(&info->kicked) || atomic_read(&info->stop), + msecs_to_jiffies(ms)); + } + } while (true); complete_and_exit(&info->compl, 0); @@ -241,6 +257,13 @@ int cas_create_cleaner_thread(ocf_cleaner_t c) return result; } +void cas_kick_cleaner_thread(ocf_cleaner_t c) +{ + struct cas_thread_info *info = ocf_cleaner_get_priv(c); + atomic_set(&info->kicked, 1); + wake_up(&info->wq); +} + void cas_stop_cleaner_thread(ocf_cleaner_t c) { struct cas_thread_info *info = ocf_cleaner_get_priv(c); diff --git a/modules/cas_cache/threads.h b/modules/cas_cache/threads.h index fc8bde8..c687807 100644 --- a/modules/cas_cache/threads.h +++ b/modules/cas_cache/threads.h @@ -17,6 +17,7 @@ void cas_kick_queue_thread(ocf_queue_t q); void cas_stop_queue_thread(ocf_queue_t q); int cas_create_cleaner_thread(ocf_cleaner_t c); +void cas_kick_cleaner_thread(ocf_cleaner_t c); void cas_stop_cleaner_thread(ocf_cleaner_t c); int cas_create_metadata_updater_thread(ocf_metadata_updater_t mu); diff --git a/ocf b/ocf index 8d09d7a..7165bc1 160000 --- a/ocf +++ b/ocf @@ -1 +1 @@ -Subproject commit 8d09d7ae47b7ef5377d70cd22de488905c1e2877 +Subproject commit 7165bc16c3f9c3c6efbd41138fbdf4cf8aaf6262