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:
parent
01902e1206
commit
ed62866324
@ -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
|
* @brief Get amount of free RAM needed to attach cache volume
|
||||||
*
|
*
|
||||||
* @param[in] cache Cache handle
|
* @param[in] cache Cache handle
|
||||||
* @param[in] cfg Caching device configuration
|
* @param[in] volume_size Volume size in bytes
|
||||||
* @param[out] ram_needed Amount of RAM needed in bytes
|
|
||||||
*
|
*
|
||||||
* @retval 0 Success
|
* @retval Amount of RAM needed in bytes
|
||||||
* @retval Non-zero Error occurred
|
|
||||||
*/
|
*/
|
||||||
int ocf_mngt_get_ram_needed(ocf_cache_t cache,
|
uint64_t ocf_mngt_get_ram_needed(ocf_cache_t cache,
|
||||||
struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed);
|
uint64_t volume_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Completion callback of cache attach operation
|
* @brief Completion callback of cache attach operation
|
||||||
|
@ -1405,28 +1405,16 @@ static uint64_t _ocf_mngt_calculate_ram_needed(ocf_cache_line_size_t line_size,
|
|||||||
return min_free_ram;
|
return min_free_ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_mngt_get_ram_needed(ocf_cache_t cache,
|
uint64_t ocf_mngt_get_ram_needed(ocf_cache_t cache,
|
||||||
struct ocf_mngt_cache_device_config *cfg, uint64_t *ram_needed)
|
uint64_t volume_size)
|
||||||
{
|
{
|
||||||
ocf_cache_line_size_t line_size;
|
ocf_cache_line_size_t line_size;
|
||||||
uint64_t volume_size;
|
|
||||||
int result;
|
|
||||||
|
|
||||||
OCF_CHECK_NULL(cache);
|
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);
|
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 _ocf_mngt_calculate_ram_needed(line_size, volume_size);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user