fix for issue #1023
Better error for core size mismatch during activation/load adding pyocf test for new error code Signed-off-by: Piotr Debski <piotr.debski@intel.com>
This commit is contained in:
parent
f4daf05237
commit
9b980d3f22
@ -140,6 +140,9 @@ typedef enum {
|
||||
/** Invalid operation for cache in standby state. */
|
||||
OCF_ERR_CACHE_STANDBY,
|
||||
|
||||
/** Size of core volume doesn't match the size stored in cache metadata */
|
||||
OCF_ERR_CORE_SIZE_MISMATCH,
|
||||
|
||||
/** Operation invalid with cache drive atatched in failover standby */
|
||||
OCF_ERR_STANDBY_ATTACHED,
|
||||
|
||||
|
@ -382,6 +382,7 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline,
|
||||
int ret = -1;
|
||||
uint64_t hd_lines = 0;
|
||||
uint64_t length;
|
||||
ocf_error_t error = -OCF_ERR_START_CACHE_FAIL;
|
||||
|
||||
OCF_ASSERT_PLUGGED(cache);
|
||||
|
||||
@ -464,9 +465,10 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline,
|
||||
|
||||
length = ocf_volume_get_length(&core->volume);
|
||||
if (length != core->conf_meta->length) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
ocf_core_log(core, log_err,
|
||||
"Size of core volume doesn't match with"
|
||||
" the size stored in cache metadata!");
|
||||
error = -OCF_ERR_CORE_SIZE_MISMATCH;
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -484,7 +486,7 @@ static void _ocf_mngt_load_add_cores(ocf_pipeline_t pipeline,
|
||||
err:
|
||||
_ocf_mngt_close_all_uninitialized_cores(context);
|
||||
|
||||
OCF_PL_FINISH_RET(pipeline, -OCF_ERR_START_CACHE_FAIL);
|
||||
OCF_PL_FINISH_RET(pipeline, error);
|
||||
}
|
||||
|
||||
static void _recovery_reset_cline_metadata(struct ocf_cache *cache,
|
||||
|
@ -305,7 +305,7 @@ static void ocf_mngt_cache_try_add_core_insert(ocf_pipeline_t pipeline,
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Size of core volume doesn't match with"
|
||||
" the size stored in cache metadata!\n");
|
||||
result = -OCF_ERR_CORE_NOT_AVAIL;
|
||||
result = -OCF_ERR_CORE_SIZE_MISMATCH;
|
||||
goto error_after_open;
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ class OcfErrorCode(IntEnum):
|
||||
OCF_ERR_METADATA_LAYOUT_MISMATCH = auto()
|
||||
OCF_ERR_CACHE_LINE_SIZE_MISMATCH = auto()
|
||||
OCF_ERR_CACHE_STANDBY = auto()
|
||||
OCF_ERR_CORE_SIZE_MISMATCH = auto()
|
||||
OCF_ERR_STANDBY_ATTACHED = auto()
|
||||
|
||||
|
||||
|
@ -256,6 +256,12 @@ class Volume(Structure):
|
||||
def get_length(self):
|
||||
return self.size
|
||||
|
||||
def resize(self, size):
|
||||
self.size = size
|
||||
self.data = create_string_buffer(int(self.size))
|
||||
memset(self.data, self.VOLUME_POISON, self.size)
|
||||
self._storage = cast(self.data, c_void_p)
|
||||
|
||||
def get_max_io_size(self):
|
||||
return S.from_KiB(128)
|
||||
|
||||
|
@ -313,3 +313,69 @@ def _io_to_core(exported_obj: Core, data: Data):
|
||||
completion.wait()
|
||||
|
||||
assert completion.results["err"] == 0, "IO to exported object completion"
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
@pytest.mark.parametrize("cache_mode", CacheMode)
|
||||
@pytest.mark.parametrize("cls", CacheLineSize)
|
||||
def test_try_add_with_changed_core_size(pyocf_ctx, cache_mode, cls):
|
||||
"""
|
||||
Test changing volume size before load
|
||||
:param pyocf_ctx: basic pyocf context fixture
|
||||
:param cm: cache mode we start with
|
||||
:param cls: cache line size we start with
|
||||
"""
|
||||
# Start cache device
|
||||
cache_device = Volume(S.from_MiB(50))
|
||||
cache = Cache.start_on_device(
|
||||
cache_device, cache_mode=cache_mode, cache_line_size=cls
|
||||
)
|
||||
|
||||
# Add core to cache
|
||||
core_device = Volume(S.from_MiB(10))
|
||||
core = Core.using_device(core_device)
|
||||
cache.add_core(core)
|
||||
|
||||
# Stop cache
|
||||
cache.stop()
|
||||
|
||||
# Change core device size
|
||||
core_device.resize(S.from_MiB(12))
|
||||
|
||||
# Load cache with changed core size
|
||||
cache = Cache.load_from_device(cache_device, open_cores=False)
|
||||
core = Core(device=core_device, try_add=True)
|
||||
|
||||
with pytest.raises(OcfError, match="OCF_ERR_CORE_SIZE_MISMATCH"):
|
||||
cache.add_core(core)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cache_mode", CacheMode)
|
||||
@pytest.mark.parametrize("cls", CacheLineSize)
|
||||
def test_load_with_changed_core_size(pyocf_ctx, cache_mode, cls):
|
||||
"""
|
||||
Test changing volume size before load
|
||||
:param pyocf_ctx: basic pyocf context fixture
|
||||
:param cm: cache mode we start with
|
||||
:param cls: cache line size we start with
|
||||
"""
|
||||
# Start cache device
|
||||
cache_device = Volume(S.from_MiB(50))
|
||||
cache = Cache.start_on_device(
|
||||
cache_device, cache_mode=cache_mode, cache_line_size=cls
|
||||
)
|
||||
|
||||
# Add core to cache
|
||||
core_device = Volume(S.from_MiB(10))
|
||||
core = Core.using_device(core_device)
|
||||
cache.add_core(core)
|
||||
|
||||
# Stop cache
|
||||
cache.stop()
|
||||
|
||||
# Change core device size
|
||||
core_device.resize(S.from_MiB(12))
|
||||
|
||||
# Load cache with changed core size
|
||||
with pytest.raises(OcfError, match="OCF_ERR_CORE_SIZE_MISMATCH"):
|
||||
cache = Cache.load_from_device(cache_device)
|
||||
|
Loading…
Reference in New Issue
Block a user