Remove utils_device.h

Move core mngt related code to ocf_mngt_core.c

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-05-27 16:44:23 +02:00
parent 7de56940a4
commit bdcd4df0ef
8 changed files with 60 additions and 74 deletions

View File

@ -13,7 +13,6 @@
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../utils/utils_part.h" #include "../utils/utils_part.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_device.h"
#include "../utils/utils_io.h" #include "../utils/utils_io.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_pipeline.h" #include "../utils/utils_pipeline.h"

View File

@ -5,12 +5,12 @@
#include "ocf/ocf.h" #include "ocf/ocf.h"
#include "ocf_mngt_common.h" #include "ocf_mngt_common.h"
#include "ocf_mngt_core_priv.h"
#include "../ocf_priv.h" #include "../ocf_priv.h"
#include "../ocf_ctx_priv.h" #include "../ocf_ctx_priv.h"
#include "../metadata/metadata.h" #include "../metadata/metadata.h"
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../ocf_request.h" #include "../ocf_request.h"
#include "../utils/utils_device.h"
#include "../eviction/ops.h" #include "../eviction/ops.h"
#include "../ocf_logger_priv.h" #include "../ocf_logger_priv.h"
#include "../ocf_queue_priv.h" #include "../ocf_queue_priv.h"
@ -96,7 +96,7 @@ void cache_mng_core_remove_from_meta(struct ocf_cache *cache, int core_id)
cache->core_conf_meta[core_id].added = false; cache->core_conf_meta[core_id].added = false;
/* Clear UUID of core */ /* Clear UUID of core */
ocf_metadata_clear_core_uuid(&cache->core[core_id]); ocf_mngt_core_clear_uuid_metadata(&cache->core[core_id]);
cache->core_conf_meta[core_id].seq_no = OCF_SEQ_NO_INVALID; cache->core_conf_meta[core_id].seq_no = OCF_SEQ_NO_INVALID;
OCF_METADATA_UNLOCK_WR(); OCF_METADATA_UNLOCK_WR();

View File

@ -9,7 +9,6 @@
#include "../ocf_priv.h" #include "../ocf_priv.h"
#include "../metadata/metadata.h" #include "../metadata/metadata.h"
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../utils/utils_device.h"
#include "../utils/utils_pipeline.h" #include "../utils/utils_pipeline.h"
#include "../ocf_stats_priv.h" #include "../ocf_stats_priv.h"
#include "../ocf_def_priv.h" #include "../ocf_def_priv.h"
@ -22,6 +21,59 @@ static ocf_seq_no_t _ocf_mngt_get_core_seq_no(ocf_cache_t cache)
return ++cache->conf_meta->curr_core_seq_no; return ++cache->conf_meta->curr_core_seq_no;
} }
static int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
struct ocf_metadata_uuid *muuid)
{
int result;
if (!uuid->data || !muuid->data)
return -EINVAL;
if (uuid->size > sizeof(muuid->data))
return -ENOBUFS;
result = env_memcpy(muuid->data, sizeof(muuid->data),
uuid->data, uuid->size);
if (result)
return result;
result = env_memset(muuid->data + uuid->size,
sizeof(muuid->data) - uuid->size, 0);
if (result)
return result;
muuid->size = uuid->size;
return 0;
}
static int ocf_mngt_core_set_uuid_metadata(ocf_core_t core,
const struct ocf_volume_uuid *uuid,
struct ocf_volume_uuid *new_uuid)
{
ocf_cache_t cache = ocf_core_get_cache(core);
struct ocf_metadata_uuid *muuid = ocf_metadata_get_core_uuid(cache,
ocf_core_get_id(core));
if (_ocf_uuid_set(uuid, muuid))
return -ENOBUFS;
if (new_uuid) {
new_uuid->data = muuid->data;
new_uuid->size = muuid->size;
}
return 0;
}
void ocf_mngt_core_clear_uuid_metadata(ocf_core_t core)
{
struct ocf_volume_uuid uuid = { .size = 0, };
ocf_mngt_core_set_uuid_metadata(core, &uuid, NULL);
}
static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core, static int _ocf_mngt_cache_try_add_core(ocf_cache_t cache, ocf_core_t *core,
struct ocf_mngt_core_config *cfg) struct ocf_mngt_core_config *cfg)
{ {
@ -118,7 +170,7 @@ static void _ocf_mngt_cache_add_core_handle_error(
ocf_volume_deinit(volume); ocf_volume_deinit(volume);
if (context->flags.uuid_set) if (context->flags.uuid_set)
ocf_metadata_clear_core_uuid(core); ocf_mngt_core_clear_uuid_metadata(core);
} }
static void _ocf_mngt_cache_add_core_flush_sb_complete(void *priv, int error) static void _ocf_mngt_cache_add_core_flush_sb_complete(void *priv, int error)
@ -154,7 +206,7 @@ static void _ocf_mngt_cache_add_core(ocf_cache_t cache,
volume->cache = cache; volume->cache = cache;
/* Set uuid */ /* Set uuid */
result = ocf_metadata_set_core_uuid(core, &cfg->uuid, &new_uuid); result = ocf_mngt_core_set_uuid_metadata(core, &cfg->uuid, &new_uuid);
if (result) if (result)
OCF_PL_FINISH_RET(context->pipeline, result); OCF_PL_FINISH_RET(context->pipeline, result);
@ -830,7 +882,7 @@ int ocf_mngt_core_set_uuid(ocf_core_t core, const struct ocf_volume_uuid *uuid)
return 0; return 0;
} }
result = ocf_metadata_set_core_uuid(core, uuid, NULL); result = ocf_mngt_core_set_uuid_metadata(core, uuid, NULL);
if (result) if (result)
return result; return result;

View File

@ -10,4 +10,6 @@
int ocf_mngt_core_init_front_volume(ocf_core_t core); int ocf_mngt_core_init_front_volume(ocf_core_t core);
void ocf_mngt_core_clear_uuid_metadata(ocf_core_t core);
#endif /* __OCF_MNGT_CORE_PRIV_H__ */ #endif /* __OCF_MNGT_CORE_PRIV_H__ */

View File

@ -11,7 +11,6 @@
#include "engine/cache_engine.h" #include "engine/cache_engine.h"
#include "ocf_request.h" #include "ocf_request.h"
#include "utils/utils_part.h" #include "utils/utils_part.h"
#include "utils/utils_device.h"
#include "ocf_request.h" #include "ocf_request.h"
#include "ocf_trace_priv.h" #include "ocf_trace_priv.h"

View File

@ -1,64 +0,0 @@
/*
* Copyright(c) 2012-2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
#ifndef UTILS_DEVICE_H_
#define UTILS_DEVICE_H_
static inline int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
struct ocf_metadata_uuid *muuid)
{
int result;
if (!uuid || !muuid) {
return -EINVAL;
}
if (!uuid->data || !muuid->data) {
return -EINVAL;
}
if (uuid->size > sizeof(muuid->data)) {
return -ENOBUFS;
}
result = env_memcpy(muuid->data, sizeof(muuid->data), uuid->data, uuid->size);
if (result)
return result;
result = env_memset(muuid->data + uuid->size,
sizeof(muuid->data) - uuid->size, 0);
if (result)
return result;
muuid->size = uuid->size;
return 0;
}
static inline int ocf_metadata_set_core_uuid(ocf_core_t core,
const struct ocf_volume_uuid *uuid,
struct ocf_volume_uuid *new_uuid)
{
ocf_cache_t cache = ocf_core_get_cache(core);
struct ocf_metadata_uuid *muuid = ocf_metadata_get_core_uuid(cache,
ocf_core_get_id(core));
if (_ocf_uuid_set(uuid, muuid))
return -ENOBUFS;
if (new_uuid) {
new_uuid->data = muuid->data;
new_uuid->size = muuid->size;
}
return 0;
}
static inline void ocf_metadata_clear_core_uuid(ocf_core_t core)
{
struct ocf_volume_uuid uuid = { .size = 0, };
ocf_metadata_set_core_uuid(core, &uuid, NULL);
}
#endif /* UTILS_MEM_H_ */

View File

@ -31,7 +31,6 @@
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../utils/utils_part.h" #include "../utils/utils_part.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_device.h"
#include "../utils/utils_io.h" #include "../utils/utils_io.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_pipeline.h" #include "../utils/utils_pipeline.h"

View File

@ -26,7 +26,6 @@
#include "../engine/cache_engine.h" #include "../engine/cache_engine.h"
#include "../utils/utils_part.h" #include "../utils/utils_part.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_device.h"
#include "../utils/utils_io.h" #include "../utils/utils_io.h"
#include "../utils/utils_cache_line.h" #include "../utils/utils_cache_line.h"
#include "../utils/utils_pipeline.h" #include "../utils/utils_pipeline.h"