Merge pull request #326 from Ostrokrzew/upstream

Change error code
This commit is contained in:
Robert Baldyga 2020-01-10 13:38:18 +01:00 committed by GitHub
commit ce28c71475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View File

@ -117,8 +117,11 @@ typedef enum {
/** Invalid cache line size */ /** Invalid cache line size */
OCF_ERR_INVALID_CACHE_LINE_SIZE, OCF_ERR_INVALID_CACHE_LINE_SIZE,
/** Invalid cache name loaded*/ /** Invalid cache name loaded */
OCF_ERR_CACHE_NAME_MISMATCH, OCF_ERR_CACHE_NAME_MISMATCH,
/** Device does not meet requirements */
OCF_ERR_INVAL_CACHE_DEV,
} ocf_error_t; } ocf_error_t;
#endif /* __OCF_ERR_H__ */ #endif /* __OCF_ERR_H__ */

View File

@ -635,7 +635,7 @@ static void _ocf_mngt_attach_cache_device(ocf_pipeline_t pipeline,
if (context->volume_size < OCF_CACHE_SIZE_MIN) { if (context->volume_size < OCF_CACHE_SIZE_MIN) {
ocf_cache_log(cache, log_err, "ERROR: Cache cache size must " ocf_cache_log(cache, log_err, "ERROR: Cache cache size must "
"be at least %llu [MiB]\n", OCF_CACHE_SIZE_MIN / MiB); "be at least %llu [MiB]\n", OCF_CACHE_SIZE_MIN / MiB);
OCF_PL_FINISH_RET(context->pipeline, -OCF_ERR_START_CACHE_FAIL); OCF_PL_FINISH_RET(context->pipeline, -OCF_ERR_INVAL_CACHE_DEV);
} }
ocf_pipeline_next(pipeline); ocf_pipeline_next(pipeline);
@ -1213,7 +1213,7 @@ static int _ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
result = ocf_metadata_init(tmp_cache, params.metadata.line_size); result = ocf_metadata_init(tmp_cache, params.metadata.line_size);
if (result) { if (result) {
env_rmutex_unlock(&ctx->lock); env_rmutex_unlock(&ctx->lock);
result = -OCF_ERR_START_CACHE_FAIL; result = -OCF_ERR_NO_MEM;
goto _cache_mngt_init_instance_ERROR; goto _cache_mngt_init_instance_ERROR;
} }
params.flags.metadata_inited = true; params.flags.metadata_inited = true;

View File

@ -47,6 +47,7 @@ class OcfErrorCode(IntEnum):
OCF_ERR_INVALID_CACHE_MODE = auto() OCF_ERR_INVALID_CACHE_MODE = auto()
OCF_ERR_INVALID_CACHE_LINE_SIZE = auto() OCF_ERR_INVALID_CACHE_LINE_SIZE = auto()
OCF_ERR_CACHE_NAME_MISMATCH = auto() OCF_ERR_CACHE_NAME_MISMATCH = auto()
OCF_ERR_INVAL_CACHE_DEV = auto()
class OcfCompletion: class OcfCompletion:

View File

@ -359,7 +359,7 @@ def test_start_too_small_device(pyocf_ctx, mode, cls):
cache_device = Volume(Size.from_B(20 * 1024 * 1024 - 1)) cache_device = Volume(Size.from_B(20 * 1024 * 1024 - 1))
with pytest.raises(OcfError, match="OCF_ERR_START_CACHE_FAIL"): with pytest.raises(OcfError, match="OCF_ERR_INVAL_CACHE_DEV"):
Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls) Cache.start_on_device(cache_device, cache_mode=mode, cache_line_size=cls)