Remove memcpy from collision/eviction policy metadata api

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski
2020-01-14 09:43:18 -05:00
parent ec723e15e1
commit fec61528e6
7 changed files with 140 additions and 326 deletions

View File

@@ -6,24 +6,12 @@
#ifndef __METADATA_CLEANING_POLICY_H__
#define __METADATA_CLEANING_POLICY_H__
/*
* GET
*/
static inline void
static inline struct cleaning_policy_meta *
ocf_metadata_get_cleaning_policy(struct ocf_cache *cache,
ocf_cache_line_t line, struct cleaning_policy_meta *policy)
ocf_cache_line_t line)
{
cache->metadata.iface.get_cleaning_policy(cache, line, policy);
return cache->metadata.iface.get_cleaning_policy(cache, line);
}
/*
* SET
*/
static inline void
ocf_metadata_set_cleaning_policy(struct ocf_cache *cache,
ocf_cache_line_t line, struct cleaning_policy_meta *policy)
{
cache->metadata.iface.set_cleaning_policy(cache, line, policy);
}
#endif /* METADATA_CLEANING_POLICY_H_ */

View File

@@ -6,21 +6,11 @@
#ifndef __METADATA_EVICTION_H__
#define __METADATA_EVICTION_H__
static inline void ocf_metadata_get_evicition_policy(
struct ocf_cache *cache, ocf_cache_line_t line,
union eviction_policy_meta *eviction)
static inline union eviction_policy_meta *
ocf_metadata_get_eviction_policy(
struct ocf_cache *cache, ocf_cache_line_t line)
{
cache->metadata.iface.get_eviction_policy(cache, line, eviction);
}
/*
* SET
*/
static inline void ocf_metadata_set_evicition_policy(
struct ocf_cache *cache, ocf_cache_line_t line,
union eviction_policy_meta *eviction)
{
cache->metadata.iface.set_eviction_policy(cache, line, eviction);
return cache->metadata.iface.get_eviction_policy(cache, line);
}
#endif /* METADATA_EVICTION_H_ */

View File

@@ -2410,39 +2410,15 @@ static void ocf_metadata_hash_set_hash(struct ocf_cache *cache,
/*
* Cleaning policy - Get
*/
static void ocf_metadata_hash_get_cleaning_policy(
struct ocf_cache *cache, ocf_cache_line_t line,
struct cleaning_policy_meta *cleaning_policy)
static struct cleaning_policy_meta *
ocf_metadata_hash_get_cleaning_policy(struct ocf_cache *cache,
ocf_cache_line_t line)
{
int result = 0;
struct ocf_metadata_hash_ctrl *ctrl
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
result = ocf_metadata_raw_get(cache,
&(ctrl->raw_desc[metadata_segment_cleaning]), line,
cleaning_policy);
if (result)
ocf_metadata_error(cache);
}
/*
* Cleaning policy - Set
*/
static void ocf_metadata_hash_set_cleaning_policy(
struct ocf_cache *cache, ocf_cache_line_t line,
struct cleaning_policy_meta *cleaning_policy)
{
int result = 0;
struct ocf_metadata_hash_ctrl *ctrl
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
result = ocf_metadata_raw_set(cache,
&(ctrl->raw_desc[metadata_segment_cleaning]), line,
cleaning_policy);
if (result)
ocf_metadata_error(cache);
return ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_cleaning]), line);
}
/*******************************************************************************
@@ -2452,39 +2428,15 @@ static void ocf_metadata_hash_set_cleaning_policy(
/*
* Eviction policy - Get
*/
static void ocf_metadata_hash_get_eviction_policy(
struct ocf_cache *cache, ocf_cache_line_t line,
union eviction_policy_meta *eviction_policy)
static union eviction_policy_meta *
ocf_metadata_hash_get_eviction_policy(struct ocf_cache *cache,
ocf_cache_line_t line)
{
int result = 0;
struct ocf_metadata_hash_ctrl *ctrl
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
result = ocf_metadata_raw_get(cache,
&(ctrl->raw_desc[metadata_segment_eviction]), line,
eviction_policy);
if (result)
ocf_metadata_error(cache);
}
/*
* Cleaning policy - Set
*/
static void ocf_metadata_hash_set_eviction_policy(
struct ocf_cache *cache, ocf_cache_line_t line,
union eviction_policy_meta *eviction_policy)
{
int result = 0;
struct ocf_metadata_hash_ctrl *ctrl
= (struct ocf_metadata_hash_ctrl *) cache->metadata.iface_priv;
result = ocf_metadata_raw_set(cache,
&(ctrl->raw_desc[metadata_segment_eviction]), line,
eviction_policy);
if (result)
ocf_metadata_error(cache);
return ocf_metadata_raw_wr_access(cache,
&(ctrl->raw_desc[metadata_segment_eviction]), line);
}
/*******************************************************************************
@@ -2837,13 +2789,11 @@ static const struct ocf_metadata_iface metadata_hash_iface = {
* Cleaning Policy
*/
.get_cleaning_policy = ocf_metadata_hash_get_cleaning_policy,
.set_cleaning_policy = ocf_metadata_hash_set_cleaning_policy,
/*
* Eviction Policy
*/
.get_eviction_policy = ocf_metadata_hash_get_eviction_policy,
.set_eviction_policy = ocf_metadata_hash_set_eviction_policy,
};
/*******************************************************************************

View File

@@ -257,46 +257,20 @@ struct ocf_metadata_iface {
*
* @param[in] cache - Cache instance
* @param[in] line - cache line for which eviction policy is requested
* @param[out] eviction_policy - Eviction policy
* @return eviction policy metadata
*/
void (*get_eviction_policy)(struct ocf_cache *cache,
ocf_cache_line_t line,
union eviction_policy_meta *eviction_policy);
/**
* @brief Set eviction policy
*
* @param[in] cache - Cache instance
* @param[in] line - Eviction policy values which will be stored in
* metadata service
* @param[out] eviction_policy - Eviction policy
*/
void (*set_eviction_policy)(struct ocf_cache *cache,
ocf_cache_line_t line,
union eviction_policy_meta *eviction_policy);
union eviction_policy_meta *(*get_eviction_policy)(
struct ocf_cache *cache, ocf_cache_line_t line);
/**
* @brief Get cleaning policy
*
* @param[in] cache - Cache instance
* @param[in] line - cache line for which cleaning policy is requested
* @param[out] cleaning_policy - Cleaning policy
* @return cleaning_policy metadata
*/
void (*get_cleaning_policy)(struct ocf_cache *cache,
ocf_cache_line_t line,
struct cleaning_policy_meta *cleaning_policy);
/**
* @brief Set cleaning policy
*
* @param[in] cache - Cache instance
* @param[in] line
* @param[in] cleaning_policy - Cleaning policy values which will be
* stored in metadata service
*/
void (*set_cleaning_policy)(struct ocf_cache *cache,
ocf_cache_line_t line,
struct cleaning_policy_meta *cleaning_policy);
struct cleaning_policy_meta *(*get_cleaning_policy)(
struct ocf_cache *cache, ocf_cache_line_t line);
/**
* @brief Get hash table for specified index