Introduce OCF_CMPL_RET() macro
This simplifies cases when we want to call completion callback and immediately return from void-returning function, by allowing to explicitly express programmers intent. That way we can avoid cases when return statement is missing by mistake (this patch fixes at least one bug related to this). Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
bcb2e670f3
commit
1373471af7
@ -251,44 +251,37 @@ static void ocf_metadata_load_properties_cmpl(
|
||||
|
||||
if (superblock->magic_number != CACHE_MAGIC_NUMBER) {
|
||||
ocf_log(ctx, log_info, "Cannot detect pre-existing metadata\n");
|
||||
cmpl(priv, -ENODATA, NULL);
|
||||
return;
|
||||
OCF_CMPL_RET(priv, -ENODATA, NULL);
|
||||
}
|
||||
|
||||
if (METADATA_VERSION() != superblock->metadata_version) {
|
||||
ocf_log(ctx, log_err, "Metadata version mismatch!\n");
|
||||
cmpl(priv, -EBADF, NULL);
|
||||
return;
|
||||
OCF_CMPL_RET(priv, -EBADF, NULL);
|
||||
}
|
||||
|
||||
if (!ocf_cache_line_size_is_valid(superblock->line_size)) {
|
||||
ocf_log(ctx, log_err, "ERROR: Invalid cache line size!\n");
|
||||
cmpl(priv, -EINVAL, NULL);
|
||||
return;
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
}
|
||||
|
||||
if ((unsigned)superblock->metadata_layout >= ocf_metadata_layout_max) {
|
||||
ocf_log(ctx, log_err, "ERROR: Invalid metadata layout!\n");
|
||||
cmpl(priv, -EINVAL, NULL);
|
||||
return;
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
}
|
||||
|
||||
if (superblock->cache_mode >= ocf_cache_mode_max) {
|
||||
ocf_log(ctx, log_err, "ERROR: Invalid cache mode!\n");
|
||||
cmpl(priv, -EINVAL, NULL);
|
||||
return;
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
}
|
||||
|
||||
if (superblock->clean_shutdown > ocf_metadata_clean_shutdown) {
|
||||
ocf_log(ctx, log_err, "ERROR: Invalid shutdown status!\n");
|
||||
cmpl(priv, -EINVAL, NULL);
|
||||
return;
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
}
|
||||
|
||||
if (superblock->dirty_flushed > DIRTY_FLUSHED) {
|
||||
ocf_log(ctx, log_err, "ERROR: Invalid flush status!\n");
|
||||
cmpl(priv, -EINVAL, NULL);
|
||||
return;
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
}
|
||||
|
||||
properties.line_size = superblock->line_size;
|
||||
@ -297,7 +290,7 @@ static void ocf_metadata_load_properties_cmpl(
|
||||
properties.shutdown_status = superblock->clean_shutdown;
|
||||
properties.dirty_flushed = superblock->dirty_flushed;
|
||||
|
||||
cmpl(priv, 0, &properties);
|
||||
OCF_CMPL_RET(priv, 0, &properties);
|
||||
}
|
||||
|
||||
void ocf_metadata_load_properties(ocf_volume_t volume,
|
||||
@ -310,7 +303,7 @@ void ocf_metadata_load_properties(ocf_volume_t volume,
|
||||
result = ocf_metadata_read_sb(volume->cache->owner, volume,
|
||||
ocf_metadata_load_properties_cmpl, cmpl, priv);
|
||||
if (result)
|
||||
cmpl(priv, result, NULL);
|
||||
OCF_CMPL_RET(priv, result, NULL);
|
||||
}
|
||||
|
||||
static void ocf_metadata_probe_cmpl(struct ocf_metadata_read_sb_ctx *context)
|
||||
@ -320,31 +313,23 @@ static void ocf_metadata_probe_cmpl(struct ocf_metadata_read_sb_ctx *context)
|
||||
ocf_metadata_probe_end_t cmpl = context->priv1;
|
||||
void *priv = context->priv2;
|
||||
|
||||
if (superblock->magic_number != CACHE_MAGIC_NUMBER) {
|
||||
cmpl(priv, -ENODATA, NULL);
|
||||
return;
|
||||
}
|
||||
if (superblock->magic_number != CACHE_MAGIC_NUMBER)
|
||||
OCF_CMPL_RET(priv, -ENODATA, NULL);
|
||||
|
||||
if (METADATA_VERSION() != superblock->metadata_version) {
|
||||
cmpl(priv, -EBADF, NULL);
|
||||
return;
|
||||
}
|
||||
if (METADATA_VERSION() != superblock->metadata_version)
|
||||
OCF_CMPL_RET(priv, -EBADF, NULL);
|
||||
|
||||
if (superblock->clean_shutdown > ocf_metadata_clean_shutdown) {
|
||||
cmpl(priv, -EINVAL, NULL);
|
||||
return;
|
||||
}
|
||||
if (superblock->clean_shutdown > ocf_metadata_clean_shutdown)
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
|
||||
if (superblock->dirty_flushed > DIRTY_FLUSHED) {
|
||||
cmpl(priv, -EINVAL, NULL);
|
||||
return;
|
||||
}
|
||||
if (superblock->dirty_flushed > DIRTY_FLUSHED)
|
||||
OCF_CMPL_RET(priv, -EINVAL, NULL);
|
||||
|
||||
status.clean_shutdown = (superblock->clean_shutdown !=
|
||||
ocf_metadata_dirty_shutdown);
|
||||
status.cache_dirty = (superblock->dirty_flushed == DIRTY_NOT_FLUSHED);
|
||||
|
||||
cmpl(priv, 0, &status);
|
||||
OCF_CMPL_RET(priv, 0, &status);
|
||||
}
|
||||
|
||||
void ocf_metadata_probe(ocf_ctx_t ctx, ocf_volume_t volume,
|
||||
@ -358,7 +343,7 @@ void ocf_metadata_probe(ocf_ctx_t ctx, ocf_volume_t volume,
|
||||
result = ocf_metadata_read_sb(ctx, volume, ocf_metadata_probe_cmpl,
|
||||
cmpl, priv);
|
||||
if (result)
|
||||
cmpl(priv, result, NULL);
|
||||
OCF_CMPL_RET(priv, result, NULL);
|
||||
}
|
||||
|
||||
/* completion context for query_cores */
|
||||
@ -385,10 +370,8 @@ void ocf_metadata_probe_cores(ocf_ctx_t ctx, ocf_volume_t volume,
|
||||
const struct ocf_metadata_iface *iface;
|
||||
|
||||
context = env_vzalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM, 0);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM, 0);
|
||||
|
||||
context->cmpl = cmpl;
|
||||
context->priv = priv;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "../utils/utils_cache_line.h"
|
||||
#include "../utils/utils_pipeline.h"
|
||||
#include "../ocf_def_priv.h"
|
||||
#include "../ocf_priv.h"
|
||||
|
||||
#define OCF_METADATA_HASH_DEBUG 0
|
||||
|
||||
@ -794,17 +795,14 @@ void ocf_metadata_hash_query_cores(ocf_ctx_t owner, ocf_volume_t volume,
|
||||
struct query_cores_context *context;
|
||||
int err;
|
||||
|
||||
if (count > OCF_CORE_MAX) {
|
||||
cmpl(priv, -EINVAL, 0);
|
||||
return;
|
||||
}
|
||||
if (count > OCF_CORE_MAX)
|
||||
OCF_CMPL_RET(priv, -EINVAL, 0);
|
||||
|
||||
/* intialize query context */
|
||||
context = env_secure_alloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -ENOMEM, 0);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -ENOMEM, 0);
|
||||
|
||||
ENV_BUG_ON(env_memset(context, sizeof(*context), 0));
|
||||
context->ctx = owner;
|
||||
context->params.cmpl = cmpl;
|
||||
@ -1392,10 +1390,8 @@ static void ocf_metadata_hash_load_superblock(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_metadata_hash_load_sb_pipeline_props);
|
||||
if (result) {
|
||||
cmpl(priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -1527,10 +1523,8 @@ static void ocf_metadata_hash_flush_superblock(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_metadata_hash_flush_sb_pipeline_props);
|
||||
if (result) {
|
||||
cmpl(priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -1683,10 +1677,8 @@ static void ocf_metadata_hash_flush_all(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_metadata_hash_flush_all_pipeline_props);
|
||||
if (result) {
|
||||
cmpl(priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -1807,10 +1799,8 @@ static void ocf_metadata_hash_load_all(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_metadata_hash_load_all_pipeline_props);
|
||||
if (result) {
|
||||
cmpl(priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -1968,10 +1958,8 @@ static void _ocf_metadata_hash_load_recovery_legacy(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_metadata_hash_load_recovery_legacy_pl_props);
|
||||
if (result) {
|
||||
cmpl(priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -2117,10 +2105,8 @@ static void _ocf_metadata_hash_load_recovery_atomic(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_metadata_hash_load_recovery_atomic_pl_props);
|
||||
if (result) {
|
||||
cmpl(priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "metadata_io.h"
|
||||
#include "metadata_raw_atomic.h"
|
||||
#include "../ocf_def_priv.h"
|
||||
#include "../ocf_priv.h"
|
||||
|
||||
#define OCF_METADATA_RAW_DEBUG 0
|
||||
|
||||
@ -250,10 +251,8 @@ static void _raw_ram_load_all(ocf_cache_t cache, struct ocf_metadata_raw *raw,
|
||||
OCF_DEBUG_TRACE(cache);
|
||||
|
||||
context = env_vmalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context->raw = raw;
|
||||
context->cmpl = cmpl;
|
||||
@ -319,10 +318,8 @@ static void _raw_ram_flush_all(ocf_cache_t cache, struct ocf_metadata_raw *raw,
|
||||
OCF_DEBUG_TRACE(cache);
|
||||
|
||||
context = env_vmalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context->raw = raw;
|
||||
context->cmpl = cmpl;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "../utils/utils_io.h"
|
||||
#include "../utils/utils_req.h"
|
||||
#include "../ocf_def_priv.h"
|
||||
#include "../ocf_priv.h"
|
||||
|
||||
#define OCF_METADATA_RAW_DEBUG 0
|
||||
|
||||
@ -434,10 +435,8 @@ void raw_dynamic_load_all(ocf_cache_t cache, struct ocf_metadata_raw *raw,
|
||||
OCF_DEBUG_TRACE(cache);
|
||||
|
||||
context = env_vzalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context->raw = raw;
|
||||
context->cache = cache;
|
||||
@ -475,7 +474,7 @@ err_zpage:
|
||||
ctx_data_free(cache->owner, context->data);
|
||||
err_data:
|
||||
env_vfree(context);
|
||||
cmpl(priv, result);
|
||||
OCF_CMPL_RET(priv, result);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -534,10 +533,8 @@ void raw_dynamic_flush_all(ocf_cache_t cache, struct ocf_metadata_raw *raw,
|
||||
OCF_DEBUG_TRACE(cache);
|
||||
|
||||
context = env_vmalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context->raw = raw;
|
||||
context->cmpl = cmpl;
|
||||
@ -548,7 +545,7 @@ void raw_dynamic_flush_all(ocf_cache_t cache, struct ocf_metadata_raw *raw,
|
||||
raw_dynamic_flush_all_fill,
|
||||
raw_dynamic_flush_all_complete);
|
||||
if (result)
|
||||
cmpl(priv, result);
|
||||
OCF_CMPL_RET(priv, result);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1631,10 +1631,8 @@ static void _ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&_ocf_mngt_cache_attach_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(cache, priv1, priv2, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv1, priv2, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -1675,7 +1673,7 @@ err_uuid:
|
||||
env_vfree(data);
|
||||
err_pipeline:
|
||||
ocf_pipeline_destroy(pipeline);
|
||||
cmpl(cache, priv1, priv2, result);
|
||||
OCF_CMPL_RET(cache, priv1, priv2, result);
|
||||
}
|
||||
|
||||
static int _ocf_mngt_cache_validate_cfg(struct ocf_mngt_cache_config *cfg)
|
||||
@ -1794,7 +1792,7 @@ static void _ocf_mngt_cache_attach_complete(ocf_cache_t cache, void *priv1,
|
||||
"failed\n");
|
||||
}
|
||||
|
||||
cmpl(cache, priv2, error);
|
||||
OCF_CMPL_RET(cache, priv2, error);
|
||||
}
|
||||
|
||||
void ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
@ -1807,10 +1805,8 @@ void ocf_mngt_cache_attach(ocf_cache_t cache,
|
||||
OCF_CHECK_NULL(cfg);
|
||||
|
||||
result = _ocf_mngt_cache_validate_device_cfg(cfg);
|
||||
if (result) {
|
||||
cmpl(cache, priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv, result);
|
||||
|
||||
_ocf_mngt_cache_attach(cache, cfg, false,
|
||||
_ocf_mngt_cache_attach_complete, cmpl, priv);
|
||||
@ -1927,15 +1923,13 @@ static void _ocf_mngt_cache_load_complete(ocf_cache_t cache, void *priv1,
|
||||
{
|
||||
ocf_mngt_cache_load_end_t cmpl = priv1;
|
||||
|
||||
if (error) {
|
||||
cmpl(cache, priv2, error);
|
||||
return;
|
||||
}
|
||||
if (error)
|
||||
OCF_CMPL_RET(cache, priv2, error);
|
||||
|
||||
_ocf_mng_cache_set_valid(cache);
|
||||
_ocf_mngt_cache_load_log(cache);
|
||||
|
||||
cmpl(cache, priv2, 0);
|
||||
OCF_CMPL_RET(cache, priv2, 0);
|
||||
}
|
||||
|
||||
void ocf_mngt_cache_load(ocf_cache_t cache,
|
||||
@ -1949,13 +1943,11 @@ void ocf_mngt_cache_load(ocf_cache_t cache,
|
||||
|
||||
/* Load is not allowed in volatile metadata mode */
|
||||
if (cache->metadata.is_volatile)
|
||||
cmpl(cache, priv, -EINVAL);
|
||||
OCF_CMPL_RET(cache, priv, -EINVAL);
|
||||
|
||||
result = _ocf_mngt_cache_validate_device_cfg(cfg);
|
||||
if (result) {
|
||||
cmpl(cache, priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv, result);
|
||||
|
||||
_ocf_mngt_cache_attach(cache, cfg, true,
|
||||
_ocf_mngt_cache_load_complete, cmpl, priv);
|
||||
@ -2119,10 +2111,8 @@ void ocf_mngt_cache_stop(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_mngt_cache_stop_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(cache, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -2136,8 +2126,7 @@ void ocf_mngt_cache_stop(ocf_cache_t cache,
|
||||
ocf_cache_get_name(cache), sizeof(context->cache_name));
|
||||
if (result) {
|
||||
ocf_pipeline_destroy(pipeline);
|
||||
cmpl(cache, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_NO_MEM);
|
||||
}
|
||||
|
||||
ocf_cache_log(cache, log_info, "Stopping cache\n");
|
||||
@ -2200,10 +2189,8 @@ void ocf_mngt_cache_save(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_mngt_cache_save_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(cache, priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -2475,17 +2462,13 @@ void ocf_mngt_cache_detach(ocf_cache_t cache,
|
||||
|
||||
OCF_CHECK_NULL(cache);
|
||||
|
||||
if (!env_atomic_read(&cache->attached)) {
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
}
|
||||
if (!env_atomic_read(&cache->attached))
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_mngt_cache_detach_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(cache, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
|
@ -551,10 +551,8 @@ void ocf_mngt_cache_add_core(ocf_cache_t cache,
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_mngt_cache_add_core_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(cache, NULL, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, NULL, priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -585,7 +583,7 @@ err_uuid:
|
||||
env_vfree(data);
|
||||
err_pipeline:
|
||||
ocf_pipeline_destroy(context->pipeline);
|
||||
cmpl(cache, NULL, priv, result);
|
||||
OCF_CMPL_RET(cache, NULL, priv, result);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -671,17 +669,13 @@ void ocf_mngt_cache_remove_core(ocf_core_t core,
|
||||
core_id = ocf_core_get_id(core);
|
||||
|
||||
/* TODO: Make this asynchronous */
|
||||
if (_ocf_cleaning_wait_for_finish(cache, 60 * 1000)) {
|
||||
cmpl(priv, -OCF_ERR_CACHE_IN_USE);
|
||||
return;
|
||||
}
|
||||
if (_ocf_cleaning_wait_for_finish(cache, 60 * 1000))
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_CACHE_IN_USE);
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&ocf_mngt_cache_remove_core_pipeline_props);
|
||||
if (result) {
|
||||
cmpl(priv, result);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(priv, result);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
@ -738,10 +732,8 @@ void ocf_mngt_cache_detach_core(ocf_core_t core,
|
||||
core_name = ocf_core_get_name(core);
|
||||
|
||||
/* TODO: Make this asynchronous */
|
||||
if (_ocf_cleaning_wait_for_finish(cache, 60 * 1000)) {
|
||||
cmpl(priv, -OCF_ERR_CACHE_IN_USE);
|
||||
return;
|
||||
}
|
||||
if (_ocf_cleaning_wait_for_finish(cache, 60 * 1000))
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_CACHE_IN_USE);
|
||||
|
||||
ocf_core_log(core, log_debug, "Detaching core\n");
|
||||
|
||||
@ -754,7 +746,7 @@ void ocf_mngt_cache_detach_core(ocf_core_t core,
|
||||
core_name);
|
||||
}
|
||||
|
||||
cmpl(priv, result);
|
||||
OCF_CMPL_RET(priv, result);
|
||||
}
|
||||
|
||||
int ocf_mngt_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid)
|
||||
|
@ -671,30 +671,26 @@ void ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption,
|
||||
if (!ocf_cache_is_device_attached(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush cache - "
|
||||
"cache device is detached\n");
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
|
||||
}
|
||||
|
||||
if (ocf_cache_is_incomplete(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush cache - "
|
||||
"cache is in incomplete state\n");
|
||||
cmpl(cache, priv, -OCF_ERR_CACHE_IN_INCOMPLETE_STATE);
|
||||
return;
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_CACHE_IN_INCOMPLETE_STATE);
|
||||
}
|
||||
|
||||
if (!cache->mngt_queue) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Cannot flush cache - no flush queue set\n");
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
|
||||
}
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&_ocf_mngt_cache_flush_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(cache, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
context->pipeline = pipeline;
|
||||
@ -767,30 +763,26 @@ void ocf_mngt_core_flush(ocf_core_t core, bool interruption,
|
||||
if (!ocf_cache_is_device_attached(cache)) {
|
||||
ocf_cache_log(cache, log_err, "Cannot flush core - "
|
||||
"cache device is detached\n");
|
||||
cmpl(core, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
OCF_CMPL_RET(core, priv, -OCF_ERR_INVAL);
|
||||
}
|
||||
|
||||
if (!core->opened) {
|
||||
ocf_core_log(core, log_err, "Cannot flush - core is in "
|
||||
"inactive state\n");
|
||||
cmpl(core, priv, -OCF_ERR_CORE_IN_INACTIVE_STATE);
|
||||
return;
|
||||
OCF_CMPL_RET(core, priv, -OCF_ERR_CORE_IN_INACTIVE_STATE);
|
||||
}
|
||||
|
||||
if (!cache->mngt_queue) {
|
||||
ocf_core_log(core, log_err,
|
||||
"Cannot flush core - no flush queue set\n");
|
||||
cmpl(core, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
OCF_CMPL_RET(core, priv, -OCF_ERR_INVAL);
|
||||
}
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&_ocf_mngt_core_flush_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(core, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(core, priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
context->pipeline = pipeline;
|
||||
@ -846,16 +838,14 @@ void ocf_mngt_cache_purge(ocf_cache_t cache,
|
||||
if (!cache->mngt_queue) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Cannot purge cache - no flush queue set\n");
|
||||
cmpl(cache, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_INVAL);
|
||||
}
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&_ocf_mngt_cache_purge_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(cache, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(cache, priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
context->pipeline = pipeline;
|
||||
@ -900,18 +890,15 @@ void ocf_mngt_core_purge(ocf_core_t core,
|
||||
if (!cache->mngt_queue) {
|
||||
ocf_core_log(core, log_err,
|
||||
"Cannot purge core - no flush queue set\n");
|
||||
cmpl(core, priv, -OCF_ERR_INVAL);
|
||||
return;
|
||||
OCF_CMPL_RET(core, priv, -OCF_ERR_INVAL);
|
||||
}
|
||||
|
||||
core_size = ocf_volume_get_length(&cache->core[core_id].volume);
|
||||
|
||||
result = ocf_pipeline_create(&pipeline, cache,
|
||||
&_ocf_mngt_core_purge_pipeline_properties);
|
||||
if (result) {
|
||||
cmpl(core, priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (result)
|
||||
OCF_CMPL_RET(core, priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context = ocf_pipeline_get_priv(pipeline);
|
||||
|
||||
|
@ -10,4 +10,9 @@
|
||||
|
||||
#define OCF_CHECK_NULL(p) ENV_BUG_ON(!(p))
|
||||
|
||||
#define OCF_CMPL_RET(args...) ({ \
|
||||
cmpl(args); \
|
||||
return; \
|
||||
})
|
||||
|
||||
#endif /* __OCF_PRIV_H__ */
|
||||
|
@ -32,10 +32,8 @@ void ocf_submit_volume_flush(ocf_volume_t volume,
|
||||
struct ocf_io *io;
|
||||
|
||||
io = ocf_volume_new_io(volume);
|
||||
if (!io) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!io)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
ocf_io_configure(io, 0, 0, OCF_WRITE, 0, 0);
|
||||
ocf_io_set_cmpl(io, cmpl, priv, _ocf_volume_flush_end);
|
||||
@ -68,10 +66,8 @@ void ocf_submit_volume_discard(ocf_volume_t volume, uint64_t addr,
|
||||
struct ocf_io *io;
|
||||
|
||||
context = env_vzalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
env_atomic_set(&context->req_remaining, 1);
|
||||
context->cmpl = cmpl;
|
||||
@ -112,10 +108,8 @@ void ocf_submit_write_zeros(ocf_volume_t volume, uint64_t addr,
|
||||
struct ocf_io *io;
|
||||
|
||||
context = env_vzalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
env_atomic_set(&context->req_remaining, 1);
|
||||
context->cmpl = cmpl;
|
||||
@ -179,10 +173,8 @@ void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
||||
int result = 0;
|
||||
|
||||
context = env_vmalloc(sizeof(*context));
|
||||
if (!context) {
|
||||
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||
return;
|
||||
}
|
||||
if (!context)
|
||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||
|
||||
context->cache = cache;
|
||||
context->buffer = buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user