Merge pull request #17 from robertbaldyga/handle-non-interruptible-flush
Handle non interruptible flush
This commit is contained in:
commit
be4dcd0bc0
@ -58,6 +58,7 @@ struct cas_classifier;
|
|||||||
|
|
||||||
struct cache_priv {
|
struct cache_priv {
|
||||||
struct cas_classifier *classifier;
|
struct cas_classifier *classifier;
|
||||||
|
atomic_t flush_interrupt_enabled;
|
||||||
ocf_queue_t mngt_queue;
|
ocf_queue_t mngt_queue;
|
||||||
ocf_queue_t io_queues[];
|
ocf_queue_t io_queues[];
|
||||||
};
|
};
|
||||||
|
@ -591,6 +591,7 @@ static int _cas_cls_parse_conditions(struct cas_classifier *cls,
|
|||||||
static struct cas_classifier* cas_get_classifier(ocf_cache_t cache)
|
static struct cas_classifier* cas_get_classifier(ocf_cache_t cache)
|
||||||
{
|
{
|
||||||
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
|
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
|
||||||
|
|
||||||
ENV_BUG_ON(!cache_priv);
|
ENV_BUG_ON(!cache_priv);
|
||||||
return cache_priv->classifier;
|
return cache_priv->classifier;
|
||||||
}
|
}
|
||||||
@ -599,6 +600,7 @@ static void cas_set_classifier(ocf_cache_t cache,
|
|||||||
struct cas_classifier* cls)
|
struct cas_classifier* cls)
|
||||||
{
|
{
|
||||||
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
|
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
|
||||||
|
|
||||||
ENV_BUG_ON(!cache_priv);
|
ENV_BUG_ON(!cache_priv);
|
||||||
cache_priv->classifier = cls;
|
cache_priv->classifier = cls;
|
||||||
}
|
}
|
||||||
@ -826,7 +828,7 @@ void cas_cls_deinit(ocf_cache_t cache)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize classifier context */
|
/* Initialize classifier context */
|
||||||
static struct cas_classifier *_cas_cls_init(ocf_cache_t cache)
|
static struct cas_classifier *_cas_cls_init(void)
|
||||||
{
|
{
|
||||||
struct cas_classifier *cls;
|
struct cas_classifier *cls;
|
||||||
|
|
||||||
@ -860,7 +862,7 @@ int cas_cls_init(ocf_cache_t cache)
|
|||||||
unsigned result = 0;
|
unsigned result = 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
cls = _cas_cls_init(cache);
|
cls = _cas_cls_init();
|
||||||
if (IS_ERR(cls))
|
if (IS_ERR(cls))
|
||||||
return PTR_ERR(cls);
|
return PTR_ERR(cls);
|
||||||
cas_set_classifier(cache, cls);
|
cas_set_classifier(cache, cls);
|
||||||
|
@ -53,15 +53,17 @@ static void _cache_mng_cache_flush_complete(ocf_cache_t cache, void *priv,
|
|||||||
|
|
||||||
static int _cache_mng_cache_flush_sync(ocf_cache_t cache, bool interruption)
|
static int _cache_mng_cache_flush_sync(ocf_cache_t cache, bool interruption)
|
||||||
{
|
{
|
||||||
|
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
|
||||||
struct _cache_mng_sync_context context;
|
struct _cache_mng_sync_context context;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
init_completion(&context.compl);
|
init_completion(&context.compl);
|
||||||
context.result = &result;
|
context.result = &result;
|
||||||
|
|
||||||
ocf_mngt_cache_flush(cache, interruption,
|
atomic_set(&cache_priv->flush_interrupt_enabled, 0);
|
||||||
_cache_mng_cache_flush_complete, &context);
|
ocf_mngt_cache_flush(cache, _cache_mng_cache_flush_complete, &context);
|
||||||
wait_for_completion(&context.compl);
|
wait_for_completion(&context.compl);
|
||||||
|
atomic_set(&cache_priv->flush_interrupt_enabled, 1);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -77,15 +79,18 @@ static void _cache_mng_core_flush_complete(ocf_core_t core, void *priv,
|
|||||||
|
|
||||||
static int _cache_mng_core_flush_sync(ocf_core_t core, bool interruption)
|
static int _cache_mng_core_flush_sync(ocf_core_t core, bool interruption)
|
||||||
{
|
{
|
||||||
|
ocf_cache_t cache = ocf_core_get_cache(core);
|
||||||
|
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
|
||||||
struct _cache_mng_sync_context context;
|
struct _cache_mng_sync_context context;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
init_completion(&context.compl);
|
init_completion(&context.compl);
|
||||||
context.result = &result;
|
context.result = &result;
|
||||||
|
|
||||||
ocf_mngt_core_flush(core, interruption,
|
atomic_set(&cache_priv->flush_interrupt_enabled, 0);
|
||||||
_cache_mng_core_flush_complete, &context);
|
ocf_mngt_core_flush(core, _cache_mng_core_flush_complete, &context);
|
||||||
wait_for_completion(&context.compl);
|
wait_for_completion(&context.compl);
|
||||||
|
atomic_set(&cache_priv->flush_interrupt_enabled, 1);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1061,13 +1066,35 @@ static void _cache_mng_attach_complete(ocf_cache_t cache, void *priv, int error)
|
|||||||
complete(&context->compl);
|
complete(&context->compl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _cache_mng_cache_priv_init(ocf_cache_t cache)
|
||||||
|
{
|
||||||
|
struct cache_priv *cache_priv;
|
||||||
|
uint32_t cpus_no = num_online_cpus();
|
||||||
|
|
||||||
|
cache_priv = vmalloc(sizeof(*cache_priv) +
|
||||||
|
cpus_no * sizeof(*cache_priv->io_queues));
|
||||||
|
if (!cache_priv)
|
||||||
|
return -OCF_ERR_NO_MEM;
|
||||||
|
|
||||||
|
atomic_set(&cache_priv->flush_interrupt_enabled, 1);
|
||||||
|
|
||||||
|
ocf_cache_set_priv(cache, cache_priv);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _cache_mng_cache_priv_deinit(ocf_cache_t cache)
|
||||||
|
{
|
||||||
|
struct cache_priv *cache_priv = ocf_cache_get_priv(cache);
|
||||||
|
|
||||||
|
vfree(cache_priv);
|
||||||
|
}
|
||||||
|
|
||||||
static int _cache_mng_start(struct ocf_mngt_cache_config *cfg,
|
static int _cache_mng_start(struct ocf_mngt_cache_config *cfg,
|
||||||
struct ocf_mngt_cache_device_config *device_cfg,
|
struct ocf_mngt_cache_device_config *device_cfg,
|
||||||
struct kcas_start_cache *cmd, ocf_cache_t *cache)
|
struct kcas_start_cache *cmd, ocf_cache_t *cache)
|
||||||
{
|
{
|
||||||
struct _cache_mng_attach_context context;
|
struct _cache_mng_attach_context context;
|
||||||
struct cache_priv *cache_priv;
|
|
||||||
uint32_t cpus_no = num_online_cpus();
|
|
||||||
ocf_cache_t tmp_cache;
|
ocf_cache_t tmp_cache;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -1075,14 +1102,9 @@ static int _cache_mng_start(struct ocf_mngt_cache_config *cfg,
|
|||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
cache_priv = vmalloc(sizeof(*cache_priv) +
|
result = _cache_mng_cache_priv_init(tmp_cache);
|
||||||
cpus_no * sizeof(*cache_priv->io_queues));
|
if (result)
|
||||||
if (!cache_priv) {
|
|
||||||
result = -OCF_ERR_NO_MEM;
|
|
||||||
goto err_priv;
|
goto err_priv;
|
||||||
}
|
|
||||||
|
|
||||||
ocf_cache_set_priv(tmp_cache, cache_priv);
|
|
||||||
|
|
||||||
result = cas_cls_init(tmp_cache);
|
result = cas_cls_init(tmp_cache);
|
||||||
if (result)
|
if (result)
|
||||||
@ -1116,7 +1138,7 @@ err_attach:
|
|||||||
err_queues:
|
err_queues:
|
||||||
cas_cls_deinit(tmp_cache);
|
cas_cls_deinit(tmp_cache);
|
||||||
err_classifier:
|
err_classifier:
|
||||||
vfree(cache_priv);
|
_cache_mng_cache_priv_deinit(tmp_cache);
|
||||||
err_priv:
|
err_priv:
|
||||||
_cache_mng_cache_stop_sync(tmp_cache);
|
_cache_mng_cache_stop_sync(tmp_cache);
|
||||||
ocf_mngt_cache_unlock(tmp_cache);
|
ocf_mngt_cache_unlock(tmp_cache);
|
||||||
@ -1141,8 +1163,6 @@ static int _cache_mng_load(struct ocf_mngt_cache_config *cfg,
|
|||||||
struct kcas_start_cache *cmd, ocf_cache_t *cache)
|
struct kcas_start_cache *cmd, ocf_cache_t *cache)
|
||||||
{
|
{
|
||||||
struct _cache_mng_load_context context;
|
struct _cache_mng_load_context context;
|
||||||
struct cache_priv *cache_priv;
|
|
||||||
uint32_t cpus_no = num_online_cpus();
|
|
||||||
ocf_cache_t tmp_cache;
|
ocf_cache_t tmp_cache;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -1150,15 +1170,9 @@ static int _cache_mng_load(struct ocf_mngt_cache_config *cfg,
|
|||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
result = _cache_mng_cache_priv_init(tmp_cache);
|
||||||
cache_priv = vmalloc(sizeof(*cache_priv) +
|
if (result)
|
||||||
cpus_no * sizeof(*cache_priv->io_queues));
|
|
||||||
if (!cache_priv) {
|
|
||||||
result = -OCF_ERR_NO_MEM;
|
|
||||||
goto err_priv;
|
goto err_priv;
|
||||||
}
|
|
||||||
|
|
||||||
ocf_cache_set_priv(tmp_cache, cache_priv);
|
|
||||||
|
|
||||||
result = _cache_mng_start_queues(tmp_cache);
|
result = _cache_mng_start_queues(tmp_cache);
|
||||||
if (result)
|
if (result)
|
||||||
@ -1199,7 +1213,7 @@ err_load:
|
|||||||
&cmd->min_free_ram);
|
&cmd->min_free_ram);
|
||||||
}
|
}
|
||||||
err_queues:
|
err_queues:
|
||||||
vfree(cache_priv);
|
_cache_mng_cache_priv_deinit(tmp_cache);
|
||||||
err_priv:
|
err_priv:
|
||||||
_cache_mng_cache_stop_sync(tmp_cache);
|
_cache_mng_cache_stop_sync(tmp_cache);
|
||||||
ocf_mngt_cache_unlock(tmp_cache);
|
ocf_mngt_cache_unlock(tmp_cache);
|
||||||
@ -1610,14 +1624,18 @@ int cache_mng_list_caches(struct kcas_cache_list *list)
|
|||||||
|
|
||||||
int cache_mng_interrupt_flushing(ocf_cache_id_t id)
|
int cache_mng_interrupt_flushing(ocf_cache_id_t id)
|
||||||
{
|
{
|
||||||
int result;
|
|
||||||
ocf_cache_t cache;
|
ocf_cache_t cache;
|
||||||
|
struct cache_priv *cache_priv;
|
||||||
|
int result;
|
||||||
|
|
||||||
result = ocf_mngt_cache_get_by_id(cas_ctx, id, &cache);
|
result = ocf_mngt_cache_get_by_id(cas_ctx, id, &cache);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
ocf_mngt_cache_flush_interrupt(cache);
|
cache_priv = ocf_cache_get_priv(cache);
|
||||||
|
|
||||||
|
if (atomic_read(&cache_priv->flush_interrupt_enabled))
|
||||||
|
ocf_mngt_cache_flush_interrupt(cache);
|
||||||
|
|
||||||
ocf_mngt_cache_put(cache);
|
ocf_mngt_cache_put(cache);
|
||||||
|
|
||||||
|
2
ocf
2
ocf
@ -1 +1 @@
|
|||||||
Subproject commit bb6fe41b9df17c727780391cac7c816b3c484175
|
Subproject commit 8d09d7ae47b7ef5377d70cd22de488905c1e2877
|
Loading…
Reference in New Issue
Block a user