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