Modify ocf_mngt_get_ram_needed to never fail

Signed-off-by: Amir Haroush <amir.haroush@huawei.com>
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
This commit is contained in:
Amir Haroush 2023-06-20 16:33:11 +03:00 committed by Robert Baldyga
parent 01902e1206
commit ed62866324
2 changed files with 7 additions and 21 deletions

View File

@ -458,14 +458,12 @@ static inline void ocf_mngt_cache_attach_config_set_default(
* @brief Get amount of free RAM needed to attach cache volume
*
* @param[in] cache Cache handle
* @param[in] cfg Caching device configuration
* @param[out] ram_needed Amount of RAM needed in bytes
* @param[in] volume_size Volume size in bytes
*
* @retval 0 Success
* @retval Non-zero Error occurred
* @retval Amount of RAM needed in bytes
*/
int ocf_mngt_get_ram_needed(ocf_cache_t cache,
struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed);
uint64_t ocf_mngt_get_ram_needed(ocf_cache_t cache,
uint64_t volume_size);
/**
* @brief Completion callback of cache attach operation

View File

@ -1405,28 +1405,16 @@ static uint64_t _ocf_mngt_calculate_ram_needed(ocf_cache_line_size_t line_size,
return min_free_ram;
}
int ocf_mngt_get_ram_needed(ocf_cache_t cache,
struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed)
uint64_t ocf_mngt_get_ram_needed(ocf_cache_t cache,
uint64_t volume_size)
{
ocf_cache_line_size_t line_size;
uint64_t volume_size;
int result;
OCF_CHECK_NULL(cache);
OCF_CHECK_NULL(cfg);
OCF_CHECK_NULL(ram_needed);
result = ocf_volume_open(cfg->volume, cfg->volume_params);
if (result)
return result;
line_size = ocf_line_size(cache);
volume_size = ocf_volume_get_length(cfg->volume);
*ram_needed = _ocf_mngt_calculate_ram_needed(line_size, volume_size);
ocf_volume_close(cfg->volume);
return 0;
return _ocf_mngt_calculate_ram_needed(line_size, volume_size);
}
/**