OCF update

Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
Michal Rakowski 2019-10-01 09:25:24 +02:00
parent be769d7a6d
commit 4cbf555793
7 changed files with 87 additions and 59 deletions

View File

@ -157,7 +157,8 @@ static inline int mngt_get_cache_by_id(ocf_ctx_t ctx, uint16_t id,
cache_name_from_id(cache_name, id);
return ocf_mngt_cache_get_by_name(ctx, cache_name, cache);
return ocf_mngt_cache_get_by_name(ctx, cache_name,
OCF_CACHE_NAME_SIZE, cache);
}
static inline int get_core_by_id(ocf_cache_t cache, uint16_t id,
@ -167,7 +168,7 @@ static inline int get_core_by_id(ocf_cache_t cache, uint16_t id,
core_name_from_id(core_name, id);
return ocf_core_get_by_name(cache, core_name, core);
return ocf_core_get_by_name(cache, core_name, OCF_CORE_NAME_SIZE, core);
}

View File

@ -216,13 +216,15 @@ static void mark_core_id_free(uint64_t *bitmap, uint16_t core_id)
clear_bit(core_id, (unsigned long *)bitmap);
}
int cache_mngt_flush_object(const char *cache_name, const char *core_name)
int cache_mngt_flush_object(const char *cache_name, size_t cache_name_len,
const char *core_name, size_t core_name_len)
{
ocf_cache_t cache;
ocf_core_t core;
int result;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
cache_name_len, &cache);
if (result)
return result;
@ -232,7 +234,7 @@ int cache_mngt_flush_object(const char *cache_name, const char *core_name)
return result;
}
result = ocf_core_get_by_name(cache, core_name, &core);
result = ocf_core_get_by_name(cache, core_name, core_name_len, &core);
if (result)
goto out;
@ -244,12 +246,13 @@ out:
return result;
}
int cache_mngt_flush_device(const char *cache_name)
int cache_mngt_flush_device(const char *cache_name, size_t name_len)
{
int result;
ocf_cache_t cache;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
name_len, &cache);
if (result)
return result;
@ -563,7 +566,8 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
snprintf(core_name, sizeof(core_name), "core%d", cmd_info->core_id);
memset(cfg, 0, sizeof(*cfg));
cfg->name = core_name;
env_strncpy(cfg->name, OCF_CORE_NAME_SIZE, core_name, OCF_CORE_NAME_SIZE);
cfg->uuid.data = cmd_info->core_path_name;
cfg->uuid.size = strnlen(cmd_info->core_path_name, MAX_STR_LEN) + 1;
cfg->try_add = cmd_info->try_add;
@ -595,7 +599,7 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
}
static int cache_mngt_update_core_uuid(ocf_cache_t cache, const char *core_name,
ocf_uuid_t uuid)
size_t name_len, ocf_uuid_t uuid)
{
ocf_core_t core;
ocf_volume_t vol;
@ -604,7 +608,7 @@ static int cache_mngt_update_core_uuid(ocf_cache_t cache, const char *core_name,
bool match;
int result;
if (ocf_core_get_by_name(cache, core_name, &core)) {
if (ocf_core_get_by_name(cache, core_name, name_len, &core)) {
/* no such core */
return -ENODEV;
}
@ -690,7 +694,7 @@ static void _cache_mngt_add_core_complete(ocf_cache_t cache,
static void _cache_mngt_remove_core_complete(void *priv, int error);
int cache_mngt_add_core_to_cache(const char *cache_name,
int cache_mngt_add_core_to_cache(const char *cache_name, size_t name_len,
struct ocf_mngt_core_config *cfg,
struct kcas_insert_core *cmd_info)
{
@ -701,7 +705,8 @@ int cache_mngt_add_core_to_cache(const char *cache_name,
int result, remove_core_result;
struct cache_priv *cache_priv;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
name_len, &cache);
if (cfg->try_add && (result == -OCF_ERR_CACHE_NOT_EXIST)) {
result = ocf_mngt_core_pool_add(cas_ctx, &cfg->uuid,
cfg->volume_type);
@ -728,7 +733,8 @@ int cache_mngt_add_core_to_cache(const char *cache_name,
}
if (cmd_info && cmd_info->update_path) {
result = cache_mngt_update_core_uuid(cache, cfg->name, &cfg->uuid);
result = cache_mngt_update_core_uuid(cache, cfg->name,
OCF_CORE_NAME_SIZE, &cfg->uuid);
ocf_mngt_cache_unlock(cache);
ocf_mngt_cache_put(cache);
return result;
@ -928,13 +934,15 @@ rd_unlock:
return result;
}
int cache_mngt_reset_stats(const char *cache_name, const char *core_name)
int cache_mngt_reset_stats(const char *cache_name, size_t cache_name_len,
const char *core_name, size_t core_name_len)
{
ocf_cache_t cache;
ocf_core_t core;
int result = 0;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, cache_name_len,
&cache);
if (result)
return result;
@ -945,7 +953,8 @@ int cache_mngt_reset_stats(const char *cache_name, const char *core_name)
}
if (core_name) {
result = ocf_core_get_by_name(cache, core_name, &core);
result = ocf_core_get_by_name(cache, core_name,
core_name_len, &core);
if (result)
goto out;
@ -971,7 +980,7 @@ static inline void io_class_info2cfg(ocf_part_id_t part_id,
cfg->max_size = info->max_size;
}
int cache_mngt_set_partitions(const char *cache_name,
int cache_mngt_set_partitions(const char *cache_name, size_t name_len,
struct kcas_io_classes *cfg)
{
ocf_cache_t cache;
@ -997,7 +1006,8 @@ int cache_mngt_set_partitions(const char *cache_name,
&io_class_cfg->config[class_id]);
}
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
name_len, &cache);
if (result)
goto out_get;
@ -1672,14 +1682,15 @@ int cache_mngt_get_seq_cutoff_policy(ocf_core_t core,
* @param flush shall we flush dirty data during switch, or shall we flush
* all remaining dirty data before entering new mode?
*/
int cache_mngt_set_cache_mode(const char *cache_name, ocf_cache_mode_t mode,
uint8_t flush)
int cache_mngt_set_cache_mode(const char *cache_name, size_t name_len,
ocf_cache_mode_t mode, uint8_t flush)
{
ocf_cache_mode_t old_mode;
ocf_cache_t cache;
int result;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
name_len, &cache);
if (result)
return result;
@ -1720,14 +1731,15 @@ out:
* if yes, flushing may still be interrupted by user (in which case
* device won't be actually removed and error will be returned)
*/
int cache_mngt_exit_instance(const char *cache_name, int flush)
int cache_mngt_exit_instance(const char *cache_name, size_t name_len, int flush)
{
ocf_cache_t cache;
struct cache_priv *cache_priv;
int status, flush_status = 0;
/* Get cache */
status = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
status = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
name_len, &cache);
if (status)
return status;
@ -1857,13 +1869,14 @@ int cache_mngt_list_caches(struct kcas_cache_list *list)
return ocf_mngt_cache_visit(cas_ctx, cache_mngt_list_caches_visitor, list);
}
int cache_mngt_interrupt_flushing(const char *cache_name)
int cache_mngt_interrupt_flushing(const char *cache_name, size_t name_len)
{
ocf_cache_t cache;
struct cache_priv *cache_priv;
int result;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
name_len, &cache);
if (result)
return result;

View File

@ -30,18 +30,20 @@ int cache_mngt_set_promotion_param(ocf_cache_t cache, uint32_t param_id,
int cache_mngt_get_promotion_param(ocf_cache_t cache, uint32_t param_id,
uint32_t *param_value);
int cache_mngt_add_core_to_cache(const char *cache_name,
int cache_mngt_add_core_to_cache(const char *cache_name, size_t name_len,
struct ocf_mngt_core_config *cfg,
struct kcas_insert_core *cmd_info);
int cache_mngt_remove_core_from_cache(struct kcas_remove_core *cmd);
int cache_mngt_reset_stats(const char *cache_name, const char *core_name);
int cache_mngt_reset_stats(const char *cache_name, size_t cache_name_len,
const char *core_name, size_t core_name_len);
int cache_mngt_set_partitions(const char *cache_name,
int cache_mngt_set_partitions(const char *cache_name, size_t name_len,
struct kcas_io_classes *cfg);
int cache_mngt_exit_instance(const char *cache_name, int flush);
int cache_mngt_exit_instance(const char *cache_name, size_t name_len,
int flush);
int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
struct ocf_mngt_cache_device_config *device_cfg,
@ -72,16 +74,17 @@ int cache_mngt_get_seq_cutoff_threshold(ocf_core_t core, uint32_t *thresh);
int cache_mngt_get_seq_cutoff_policy(ocf_core_t core,
ocf_seq_cutoff_policy *policy);
int cache_mngt_set_cache_mode(const char *cache_name, ocf_cache_mode_t mode,
uint8_t flush);
int cache_mngt_set_cache_mode(const char *cache_name, size_t name_len,
ocf_cache_mode_t mode, uint8_t flush);
int cache_mngt_flush_object(const char *cache_name, const char *core_name);
int cache_mngt_flush_object(const char *cache_name, size_t cache_name_len,
const char *core_name, size_t core_name_len);
int cache_mngt_flush_device(const char *cache_name);
int cache_mngt_flush_device(const char *cache_name, size_t name_len);
int cache_mngt_list_caches(struct kcas_cache_list *list);
int cache_mngt_interrupt_flushing(const char *cache_name);
int cache_mngt_interrupt_flushing(const char *cache_name, size_t name_len);
int cache_mngt_get_stats(struct kcas_get_stats *stats);

View File

@ -828,11 +828,11 @@ int _cas_upgrade_set_pt_and_flush_visitor_cache(ocf_cache_t cache, void *cntx)
const char *cache_name = ocf_cache_get_name(cache);
*result = cache_mngt_set_cache_mode(cache_name,
ocf_cache_mode_pt, false);
OCF_CACHE_NAME_SIZE, ocf_cache_mode_pt, false);
if (*result)
return *result;
*result = cache_mngt_flush_device(cache_name);
*result = cache_mngt_flush_device(cache_name, OCF_CACHE_NAME_SIZE);
if (*result)
return *result;
@ -866,7 +866,8 @@ int _cas_upgrade_stop_devices_visitor_exit(ocf_cache_t cache, void *cntx)
{
int *result = (int*) cntx;
*result = cache_mngt_exit_instance(ocf_cache_get_name(cache), true);
*result = cache_mngt_exit_instance(ocf_cache_get_name(cache),
OCF_CACHE_NAME_SIZE, true);
return *result;
}
@ -986,7 +987,6 @@ static int _cas_upgrade_restore_conf_core(struct cas_properties *cache_props,
int result = 0;
unsigned long i = 0;
uint64_t core_no, version;
char core_name[OCF_CORE_NAME_SIZE];
char *core_path = NULL;
char *key = NULL;
@ -1031,18 +1031,17 @@ static int _cas_upgrade_restore_conf_core(struct cas_properties *cache_props,
goto error;
result = cas_properties_get_string(cache_props, key,
core_name, OCF_CORE_NAME_SIZE);
cfg.name, OCF_CORE_NAME_SIZE);
if (result)
goto error;
cfg.name = core_name;
cfg.try_add = 0;
cfg.volume_type = BLOCK_DEVICE_VOLUME;
cfg.uuid.data = core_path;
cfg.uuid.size = strnlen(core_path, MAX_STR_LEN) + 1;
result = cache_mngt_add_core_to_cache(ocf_cache_get_name(cache),
&cfg, NULL);
OCF_CACHE_NAME_SIZE, &cfg, NULL);
if (result)
goto error;
}
@ -1319,7 +1318,8 @@ static int _cas_upgrade_restore_conf_io_class(
cfg->info[part_id].min_size = (uint32_t)min_size;
}
result = cache_mngt_set_partitions(ocf_cache_get_name(cache), cfg);
result = cache_mngt_set_partitions(ocf_cache_get_name(cache),
OCF_CACHE_NAME_SIZE, cfg);
error_after_alloc_buffers:
kfree(key);
@ -1340,7 +1340,8 @@ static int _cas_upgrade_restore_cache(struct cas_properties *cache_props)
if (result)
return result;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
OCF_CACHE_NAME_SIZE, &cache);
if (result)
return result;
@ -1390,7 +1391,8 @@ static int _cas_upgrade_restore_cache_mode(struct cas_properties *cache_props)
if (result)
return result;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
OCF_CACHE_NAME_SIZE, &cache);
if (result)
return result;
@ -1401,7 +1403,7 @@ static int _cas_upgrade_restore_cache_mode(struct cas_properties *cache_props)
if (ocf_cache_get_mode(cache) != cache_mode) {
result = cache_mngt_set_cache_mode(ocf_cache_get_name(cache),
cache_mode, false);
OCF_CACHE_NAME_SIZE, cache_mode, false);
if (result)
goto error;
@ -1428,7 +1430,8 @@ static int _cas_upgrade_restore_cache_after_error(
if (result)
return result;
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name, &cache);
result = ocf_mngt_cache_get_by_name(cas_ctx, cache_name,
OCF_CACHE_NAME_SIZE, &cache);
if (result == -OCF_ERR_CACHE_NOT_EXIST) {
result = _cas_upgrade_restore_cache(cache_props);
} else if (result == 0) {

View File

@ -421,9 +421,10 @@ static inline u64 env_atomic64_cmpxchg(atomic64_t *a, u64 old, u64 new)
typedef spinlock_t env_spinlock;
static inline void env_spinlock_init(env_spinlock *l)
static inline int env_spinlock_init(env_spinlock *l)
{
spin_lock_init(l);
return 0;
}
static inline void env_spinlock_lock(env_spinlock *l)
@ -592,7 +593,8 @@ static inline void env_msleep(uint64_t n)
})
#define env_strdup kstrdup
#define env_strnlen(s, smax) strnlen(s, smax)
#define env_strncmp strncmp
#define env_strncmp(s1, slen1, s2, slen2) strncmp(s1, s2, \
min_t(size_t, slen1, slen2))
#define env_strncpy(dest, dmax, src, slen) ({ \
strlcpy(dest, src, min_t(int, dmax, slen)); \
0; \

View File

@ -83,7 +83,7 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
cache_name_from_id(cache_name, cmd_info->cache_id);
retval = cache_mngt_exit_instance(cache_name,
retval = cache_mngt_exit_instance(cache_name, OCF_CACHE_NAME_SIZE,
cmd_info->flush_data);
RETURN_CMD_RESULT(cmd_info, arg, retval);
@ -98,7 +98,8 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
cache_name_from_id(cache_name, cmd_info->cache_id);
retval = cache_mngt_set_cache_mode(cache_name,
cmd_info->caching_mode, cmd_info->flush_data);
OCF_CACHE_NAME_SIZE, cmd_info->caching_mode,
cmd_info->flush_data);
RETURN_CMD_RESULT(cmd_info, arg, retval);
}
@ -116,8 +117,8 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
if (retval)
RETURN_CMD_RESULT(cmd_info, arg, retval);
retval = cache_mngt_add_core_to_cache(cache_name, &cfg,
cmd_info);
retval = cache_mngt_add_core_to_cache(cache_name,
OCF_CACHE_NAME_SIZE, &cfg, cmd_info);
RETURN_CMD_RESULT(cmd_info, arg, retval);
}
@ -144,9 +145,11 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
if (cmd_info->core_id != OCF_CORE_ID_INVALID)
core_name_from_id(core_name, cmd_info->core_id);
retval = cache_mngt_reset_stats(cache_name,
retval = cache_mngt_reset_stats(cache_name, OCF_CACHE_NAME_SIZE,
cmd_info->core_id != OCF_CORE_ID_INVALID ?
core_name : NULL);
core_name : NULL,
cmd_info->core_id != OCF_CORE_ID_INVALID ?
OCF_CORE_NAME_SIZE : 0);
RETURN_CMD_RESULT(cmd_info, arg, retval);
}
@ -159,7 +162,7 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
cache_name_from_id(cache_name, cmd_info->cache_id);
retval = cache_mngt_flush_device(cache_name);
retval = cache_mngt_flush_device(cache_name, OCF_CACHE_NAME_SIZE);
RETURN_CMD_RESULT(cmd_info, arg, retval);
}
@ -172,7 +175,8 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
cache_name_from_id(cache_name, cmd_info->cache_id);
retval = cache_mngt_interrupt_flushing(cache_name);
retval = cache_mngt_interrupt_flushing(cache_name,
OCF_CACHE_NAME_SIZE);
RETURN_CMD_RESULT(cmd_info, arg, retval);
}
@ -188,7 +192,8 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
core_name_from_id(core_name, cmd_info->core_id);
retval = cache_mngt_flush_object(cache_name, core_name);
retval = cache_mngt_flush_object(cache_name, OCF_CACHE_NAME_SIZE,
core_name, OCF_CORE_NAME_SIZE);
RETURN_CMD_RESULT(cmd_info, arg, retval);
}
@ -244,7 +249,8 @@ long cas_service_ioctl_ctrl(struct file *filp, unsigned int cmd,
cache_name_from_id(cache_name, cmd_info->cache_id);
retval = cache_mngt_set_partitions(cache_name, cmd_info);
retval = cache_mngt_set_partitions(cache_name,
OCF_CACHE_NAME_SIZE, cmd_info);
/* return just sizeof(struct kcas_io_classes) bytes of data */
RETURN_CMD_RESULT(cmd_info, arg, retval);

2
ocf

@ -1 +1 @@
Subproject commit 75569ecabadb1e47bbcfa016f9244df9dbefb442
Subproject commit 79a2d866ae5079f97390995e2fb8e092a03136f8