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 <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2019-04-29 09:51:51 -04:00
parent 64a79086a8
commit 095ccc51fe
4 changed files with 33 additions and 3 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,
},

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