Prevent adding ioclass with the same id twice
Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
ac2effb83d
commit
c643a41977
@ -31,6 +31,8 @@ int ocf_mngt_add_partition_to_cache(struct ocf_cache *cache,
|
||||
uint32_t max_size, uint8_t priority, bool valid)
|
||||
{
|
||||
uint32_t size;
|
||||
struct ocf_lst_entry *iter;
|
||||
uint32_t iter_id;
|
||||
|
||||
if (!name)
|
||||
return -OCF_ERR_INVAL;
|
||||
@ -51,6 +53,14 @@ int ocf_mngt_add_partition_to_cache(struct ocf_cache *cache,
|
||||
return -OCF_ERR_INVAL;
|
||||
}
|
||||
|
||||
for_each_lst(&cache->lst_part, iter, iter_id) {
|
||||
if (iter_id == part_id) {
|
||||
ocf_cache_log(cache, log_err,
|
||||
"Part with id %hu already exists\n", part_id);
|
||||
return -OCF_ERR_INVAL;
|
||||
}
|
||||
}
|
||||
|
||||
size = sizeof(cache->user_parts[part_id].config->name);
|
||||
if (env_strncpy(cache->user_parts[part_id].config->name, size, name, size))
|
||||
return -OCF_ERR_INVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user