Remove metadata layout abstraction
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
d2af0bafda
commit
d796e1f400
@ -38,19 +38,11 @@ struct ocf_metadata_map {
|
|||||||
/*!< Entry status structure e.g. valid, dirty...*/
|
/*!< Entry status structure e.g. valid, dirty...*/
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
static inline ocf_cache_line_t ocf_metadata_map_lg2phy(
|
ocf_cache_line_t ocf_metadata_map_lg2phy(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t coll_idx)
|
struct ocf_cache *cache, ocf_cache_line_t coll_idx);
|
||||||
{
|
|
||||||
return cache->metadata.iface.layout_iface->lg2phy(cache,
|
|
||||||
coll_idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline ocf_cache_line_t ocf_metadata_map_phy2lg(
|
ocf_cache_line_t ocf_metadata_map_phy2lg(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t cache_line)
|
struct ocf_cache *cache, ocf_cache_line_t cache_line);
|
||||||
{
|
|
||||||
return cache->metadata.iface.layout_iface->phy2lg(cache,
|
|
||||||
cache_line);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ocf_metadata_set_collision_info(
|
static inline void ocf_metadata_set_collision_info(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||||
|
@ -2455,6 +2455,34 @@ static ocf_cache_line_t ocf_metadata_hash_map_phy2lg_seq(
|
|||||||
return cache_line;
|
return cache_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is mapping collision index to appropriate cache line
|
||||||
|
* (logical cache line to physical one mapping).
|
||||||
|
*
|
||||||
|
* It is necessary because we want to generate sequential workload with
|
||||||
|
* data to cache device.
|
||||||
|
* Our collision list, for example, looks:
|
||||||
|
* 0 3 6 9
|
||||||
|
* 1 4 7 10
|
||||||
|
* 2 5 8
|
||||||
|
* All collision index in each column is on the same page
|
||||||
|
* on cache device. We don't want send request x times to the same
|
||||||
|
* page. To don't do it we use collision index by row, but in this
|
||||||
|
* case we can't use collision index directly as cache line,
|
||||||
|
* because we will generate non sequential workload (we will write
|
||||||
|
* pages: 0 -> 3 -> 6 ...). To map collision index in correct way
|
||||||
|
* we use this function.
|
||||||
|
*
|
||||||
|
* After use this function, collision index in the above array
|
||||||
|
* corresponds with below cache line:
|
||||||
|
* 0 1 2 3
|
||||||
|
* 4 5 6 7
|
||||||
|
* 8 9 10
|
||||||
|
*
|
||||||
|
* @param cache - cache instance
|
||||||
|
* @param idx - index in collision list
|
||||||
|
* @return mapped cache line
|
||||||
|
*/
|
||||||
static ocf_cache_line_t ocf_metadata_hash_map_lg2phy_striping(
|
static ocf_cache_line_t ocf_metadata_hash_map_lg2phy_striping(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t coll_idx)
|
struct ocf_cache *cache, ocf_cache_line_t coll_idx)
|
||||||
{
|
{
|
||||||
@ -2480,6 +2508,14 @@ static ocf_cache_line_t ocf_metadata_hash_map_lg2phy_striping(
|
|||||||
return cache_line;
|
return cache_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Map physical cache line on cache device to logical one
|
||||||
|
* @note This function is the inverse of map_coll_idx_to_cache_line
|
||||||
|
*
|
||||||
|
* @param cache Cache instance
|
||||||
|
* @param phy Physical cache line of cache device
|
||||||
|
* @return Logical cache line
|
||||||
|
*/
|
||||||
static ocf_cache_line_t ocf_metadata_hash_map_phy2lg_striping(
|
static ocf_cache_line_t ocf_metadata_hash_map_phy2lg_striping(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t cache_line)
|
struct ocf_cache *cache, ocf_cache_line_t cache_line)
|
||||||
{
|
{
|
||||||
@ -2514,6 +2550,45 @@ static ocf_cache_line_t ocf_metadata_hash_map_phy2lg_striping(
|
|||||||
return coll_idx;
|
return coll_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ocf_cache_line_t ocf_metadata_map_lg2phy(
|
||||||
|
struct ocf_cache *cache, ocf_cache_line_t coll_idx)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_iface *iface = (struct ocf_metadata_iface *)
|
||||||
|
&cache->metadata.iface;
|
||||||
|
|
||||||
|
switch (iface->layout) {
|
||||||
|
case ocf_metadata_layout_striping:
|
||||||
|
return ocf_metadata_hash_map_lg2phy_striping(
|
||||||
|
cache, coll_idx);
|
||||||
|
case ocf_metadata_layout_seq:
|
||||||
|
return ocf_metadata_hash_map_lg2phy_seq(
|
||||||
|
cache, coll_idx);
|
||||||
|
default:
|
||||||
|
ENV_BUG();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ocf_cache_line_t ocf_metadata_map_phy2lg(
|
||||||
|
struct ocf_cache *cache, ocf_cache_line_t cache_line)
|
||||||
|
{
|
||||||
|
struct ocf_metadata_iface *iface = (struct ocf_metadata_iface *)
|
||||||
|
&cache->metadata.iface;
|
||||||
|
|
||||||
|
switch (iface->layout) {
|
||||||
|
case ocf_metadata_layout_striping:
|
||||||
|
return ocf_metadata_hash_map_phy2lg_striping(
|
||||||
|
cache, cache_line);
|
||||||
|
case ocf_metadata_layout_seq:
|
||||||
|
return ocf_metadata_hash_map_phy2lg_seq(
|
||||||
|
cache, cache_line);
|
||||||
|
default:
|
||||||
|
ENV_BUG();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void ocf_metadata_hash_set_collision_info(
|
static void ocf_metadata_hash_set_collision_info(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t line,
|
struct ocf_cache *cache, ocf_cache_line_t line,
|
||||||
ocf_cache_line_t next, ocf_cache_line_t prev)
|
ocf_cache_line_t next, ocf_cache_line_t prev)
|
||||||
@ -2720,7 +2795,7 @@ static const struct ocf_metadata_iface metadata_hash_iface = {
|
|||||||
.init_hash_table = ocf_metadata_hash_init_hash_table,
|
.init_hash_table = ocf_metadata_hash_init_hash_table,
|
||||||
.init_collision = ocf_metadata_hash_init_collision,
|
.init_collision = ocf_metadata_hash_init_collision,
|
||||||
|
|
||||||
.layout_iface = NULL,
|
.layout = ocf_metadata_layout_default,
|
||||||
.pages = ocf_metadata_hash_pages,
|
.pages = ocf_metadata_hash_pages,
|
||||||
.cachelines = ocf_metadata_hash_cachelines,
|
.cachelines = ocf_metadata_hash_cachelines,
|
||||||
.size_of = ocf_metadata_hash_size_of,
|
.size_of = ocf_metadata_hash_size_of,
|
||||||
@ -2803,18 +2878,6 @@ static const struct ocf_metadata_iface metadata_hash_iface = {
|
|||||||
|
|
||||||
#include "metadata_bit.h"
|
#include "metadata_bit.h"
|
||||||
|
|
||||||
static const struct ocf_metadata_layout_iface layout_ifaces[ocf_metadata_layout_max] = {
|
|
||||||
[ocf_metadata_layout_striping] = {
|
|
||||||
.lg2phy = ocf_metadata_hash_map_lg2phy_striping,
|
|
||||||
.phy2lg = ocf_metadata_hash_map_phy2lg_striping
|
|
||||||
},
|
|
||||||
[ocf_metadata_layout_seq] = {
|
|
||||||
.lg2phy = ocf_metadata_hash_map_lg2phy_seq,
|
|
||||||
.phy2lg = ocf_metadata_hash_map_phy2lg_seq
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void ocf_metadata_hash_init_iface(struct ocf_cache *cache,
|
static void ocf_metadata_hash_init_iface(struct ocf_cache *cache,
|
||||||
ocf_metadata_layout_t layout)
|
ocf_metadata_layout_t layout)
|
||||||
{
|
{
|
||||||
@ -2826,7 +2889,7 @@ static void ocf_metadata_hash_init_iface(struct ocf_cache *cache,
|
|||||||
/* Initialize metadata location interface*/
|
/* Initialize metadata location interface*/
|
||||||
if (cache->device->init_mode == ocf_init_mode_metadata_volatile)
|
if (cache->device->init_mode == ocf_init_mode_metadata_volatile)
|
||||||
layout = ocf_metadata_layout_seq;
|
layout = ocf_metadata_layout_seq;
|
||||||
iface->layout_iface = &layout_ifaces[layout];
|
iface->layout = layout;
|
||||||
|
|
||||||
/* Initialize bit status function */
|
/* Initialize bit status function */
|
||||||
|
|
||||||
|
@ -26,53 +26,6 @@ enum ocf_metadata_shutdown_status {
|
|||||||
ocf_metadata_detached = 2, /*!< Cache device detached */
|
ocf_metadata_detached = 2, /*!< Cache device detached */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Metadata cache line location on pages interface
|
|
||||||
*/
|
|
||||||
struct ocf_metadata_layout_iface {
|
|
||||||
/**
|
|
||||||
* This function is mapping collision index to appropriate cache line
|
|
||||||
* (logical cache line to physical one mapping).
|
|
||||||
*
|
|
||||||
* It is necessary because we want to generate sequential workload with
|
|
||||||
* data to cache device.
|
|
||||||
* Our collision list, for example, looks:
|
|
||||||
* 0 3 6 9
|
|
||||||
* 1 4 7 10
|
|
||||||
* 2 5 8
|
|
||||||
* All collision index in each column is on the same page
|
|
||||||
* on cache device. We don't want send request x times to the same
|
|
||||||
* page. To don't do it we use collision index by row, but in this
|
|
||||||
* case we can't use collision index directly as cache line,
|
|
||||||
* because we will generate non sequential workload (we will write
|
|
||||||
* pages: 0 -> 3 -> 6 ...). To map collision index in correct way
|
|
||||||
* we use this function.
|
|
||||||
*
|
|
||||||
* After use this function, collision index in the above array
|
|
||||||
* corresponds with below cache line:
|
|
||||||
* 0 1 2 3
|
|
||||||
* 4 5 6 7
|
|
||||||
* 8 9 10
|
|
||||||
*
|
|
||||||
* @param cache - cache instance
|
|
||||||
* @param idx - index in collision list
|
|
||||||
* @return mapped cache line
|
|
||||||
*/
|
|
||||||
ocf_cache_line_t (*lg2phy)(struct ocf_cache *cache,
|
|
||||||
ocf_cache_line_t coll_idx);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Map physical cache line on cache device to logical one
|
|
||||||
* @note This function is the inverse of map_coll_idx_to_cache_line
|
|
||||||
*
|
|
||||||
* @param cache Cache instance
|
|
||||||
* @param phy Physical cache line of cache device
|
|
||||||
* @return Logical cache line
|
|
||||||
*/
|
|
||||||
ocf_cache_line_t (*phy2lg)(struct ocf_cache *cache,
|
|
||||||
ocf_cache_line_t phy);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Query cores completion callback
|
* @brief Query cores completion callback
|
||||||
*
|
*
|
||||||
@ -126,9 +79,9 @@ struct ocf_metadata_iface {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Metadata cache line location on pages interface
|
* @brief Per-cacheline metadata layout
|
||||||
*/
|
*/
|
||||||
const struct ocf_metadata_layout_iface *layout_iface;
|
ocf_metadata_layout_t layout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize hash table
|
* @brief Initialize hash table
|
||||||
|
Loading…
Reference in New Issue
Block a user