Merge pull request #16 from mmichal10/cleaner-kick

Added possibility to disable cleaner thread.
This commit is contained in:
Michal Rakowski 2019-05-10 15:58:33 +02:00 committed by GitHub
commit 80f8e617e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 6 deletions

View File

@ -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,
},
@ -426,8 +432,6 @@ int cas_initialize_context(void)
goto err_block_dev;
}
ocf_mngt_core_pool_init(cas_ctx);
return 0;
err_block_dev:
@ -444,7 +448,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();

View File

@ -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);

View File

@ -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);

2
ocf

@ -1 +1 @@
Subproject commit 8d09d7ae47b7ef5377d70cd22de488905c1e2877
Subproject commit 7165bc16c3f9c3c6efbd41138fbdf4cf8aaf6262