Create new volume instead of using non-allocated one

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-09-23 14:01:17 +02:00
parent ed1ae71992
commit dd0a39eea7

View File

@ -1068,7 +1068,7 @@ uint64_t _ocf_mngt_calculate_ram_needed(ocf_cache_t cache,
int ocf_mngt_get_ram_needed(ocf_cache_t cache,
struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed)
{
struct ocf_volume *volume = &cache->device->volume;
ocf_volume_t volume;
ocf_volume_type_t type;
int result;
@ -1080,21 +1080,21 @@ int ocf_mngt_get_ram_needed(ocf_cache_t cache,
if (!type)
return -OCF_ERR_INVAL_VOLUME_TYPE;
result = ocf_volume_init(volume, type,
&cfg->uuid, false);
result = ocf_volume_create(&volume, type,
&cfg->uuid);
if (result)
return result;
result = ocf_volume_open(volume, cfg->volume_params);
if (result) {
ocf_volume_deinit(volume);
ocf_volume_destroy(volume);
return result;
}
*ram_needed = _ocf_mngt_calculate_ram_needed(cache, volume);
ocf_volume_close(volume);
ocf_volume_deinit(volume);
ocf_volume_destroy(volume);
return 0;
}