Get rid of struct ocf_cache_line_settings
Remove struct that contains redundant data. Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
fd4400476e
commit
12a82d7fb1
@ -47,10 +47,10 @@ enum {
|
|||||||
ocf_metadata_status_type_max
|
ocf_metadata_status_type_max
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline size_t ocf_metadata_status_sizeof(
|
static inline size_t ocf_metadata_status_sizeof(ocf_cache_line_size_t line_size)
|
||||||
const struct ocf_cache_line_settings *settings) {
|
{
|
||||||
/* Number of bytes required to mark cache line status */
|
/* Number of bytes required to mark cache line status */
|
||||||
size_t size = settings->sector_count / 8;
|
size_t size = BYTES_TO_SECTORS(line_size) / 8;
|
||||||
|
|
||||||
/* Number of types of status (valid, dirty, etc...) */
|
/* Number of types of status (valid, dirty, etc...) */
|
||||||
size *= ocf_metadata_status_type_max;
|
size *= ocf_metadata_status_type_max;
|
||||||
@ -117,11 +117,11 @@ static ocf_cache_line_t ocf_metadata_get_entries(
|
|||||||
*/
|
*/
|
||||||
static int64_t ocf_metadata_get_element_size(
|
static int64_t ocf_metadata_get_element_size(
|
||||||
enum ocf_metadata_segment_id type,
|
enum ocf_metadata_segment_id type,
|
||||||
const struct ocf_cache_line_settings *settings)
|
ocf_cache_line_size_t line_size)
|
||||||
{
|
{
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
|
|
||||||
ENV_BUG_ON(type >= metadata_segment_variable_size_start && !settings);
|
ENV_BUG_ON(type >= metadata_segment_variable_size_start && !line_size);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case metadata_segment_lru:
|
case metadata_segment_lru:
|
||||||
@ -134,7 +134,7 @@ static int64_t ocf_metadata_get_element_size(
|
|||||||
|
|
||||||
case metadata_segment_collision:
|
case metadata_segment_collision:
|
||||||
size = sizeof(struct ocf_metadata_map)
|
size = sizeof(struct ocf_metadata_map)
|
||||||
+ ocf_metadata_status_sizeof(settings);
|
+ ocf_metadata_status_sizeof(line_size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case metadata_segment_list_info:
|
case metadata_segment_list_info:
|
||||||
@ -229,7 +229,7 @@ static bool ocf_metadata_calculate_exception_hndl(ocf_cache_t cache,
|
|||||||
static int ocf_metadata_calculate_metadata_size(
|
static int ocf_metadata_calculate_metadata_size(
|
||||||
struct ocf_cache *cache,
|
struct ocf_cache *cache,
|
||||||
struct ocf_metadata_ctrl *ctrl,
|
struct ocf_metadata_ctrl *ctrl,
|
||||||
const struct ocf_cache_line_settings *settings)
|
ocf_cache_line_size_t line_size)
|
||||||
{
|
{
|
||||||
int64_t i_diff = 0, diff_lines = 0, cache_lines = ctrl->device_lines;
|
int64_t i_diff = 0, diff_lines = 0, cache_lines = ctrl->device_lines;
|
||||||
int64_t lowest_diff;
|
int64_t lowest_diff;
|
||||||
@ -286,11 +286,11 @@ static int ocf_metadata_calculate_metadata_size(
|
|||||||
/* Calculate diff of cache lines */
|
/* Calculate diff of cache lines */
|
||||||
|
|
||||||
/* Cache size in bytes */
|
/* Cache size in bytes */
|
||||||
diff_lines = ctrl->device_lines * settings->size;
|
diff_lines = ctrl->device_lines * line_size;
|
||||||
/* Sub metadata size which is in 4 kiB unit */
|
/* Sub metadata size which is in 4 kiB unit */
|
||||||
diff_lines -= count_pages * PAGE_SIZE;
|
diff_lines -= count_pages * PAGE_SIZE;
|
||||||
/* Convert back to cache lines */
|
/* Convert back to cache lines */
|
||||||
diff_lines /= settings->size;
|
diff_lines /= line_size;
|
||||||
/* Calculate difference */
|
/* Calculate difference */
|
||||||
diff_lines -= cache_lines;
|
diff_lines -= cache_lines;
|
||||||
|
|
||||||
@ -416,22 +416,16 @@ void ocf_metadata_deinit_variable_size(struct ocf_cache *cache)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ocf_metadata_config_init(struct ocf_cache *cache,
|
static inline void ocf_metadata_config_init(ocf_cache_t cache, size_t size)
|
||||||
struct ocf_cache_line_settings *settings, size_t size)
|
|
||||||
{
|
{
|
||||||
ENV_BUG_ON(!ocf_cache_line_size_is_valid(size));
|
ENV_BUG_ON(!ocf_cache_line_size_is_valid(size));
|
||||||
|
|
||||||
ENV_BUG_ON(env_memset(settings, sizeof(*settings), 0));
|
cache->metadata.line_size = size;
|
||||||
|
|
||||||
settings->size = size;
|
|
||||||
settings->sector_count = BYTES_TO_SECTORS(settings->size);
|
|
||||||
settings->sector_start = 0;
|
|
||||||
settings->sector_end = settings->sector_count - 1;
|
|
||||||
|
|
||||||
OCF_DEBUG_PARAM(cache, "Cache line size = %lu, bits count = %llu, "
|
OCF_DEBUG_PARAM(cache, "Cache line size = %lu, bits count = %llu, "
|
||||||
"status size = %lu",
|
"status size = %lu",
|
||||||
settings->size, settings->sector_count,
|
size, ocf_line_sectors(cache),
|
||||||
ocf_metadata_status_sizeof(settings));
|
ocf_metadata_status_sizeof(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ocf_metadata_deinit_fixed_size(struct ocf_cache *cache)
|
static void ocf_metadata_deinit_fixed_size(struct ocf_cache *cache)
|
||||||
@ -487,7 +481,7 @@ static struct ocf_metadata_ctrl *ocf_metadata_ctrl_init(
|
|||||||
|
|
||||||
/* Entry size configuration */
|
/* Entry size configuration */
|
||||||
raw->entry_size
|
raw->entry_size
|
||||||
= ocf_metadata_get_element_size(i, NULL);
|
= ocf_metadata_get_element_size(i, 0);
|
||||||
raw->entries_in_page = PAGE_SIZE / raw->entry_size;
|
raw->entries_in_page = PAGE_SIZE / raw->entry_size;
|
||||||
|
|
||||||
/* Setup number of entries */
|
/* Setup number of entries */
|
||||||
@ -514,8 +508,6 @@ static int ocf_metadata_init_fixed_size(struct ocf_cache *cache,
|
|||||||
{
|
{
|
||||||
struct ocf_metadata_ctrl *ctrl = NULL;
|
struct ocf_metadata_ctrl *ctrl = NULL;
|
||||||
struct ocf_metadata *metadata = &cache->metadata;
|
struct ocf_metadata *metadata = &cache->metadata;
|
||||||
struct ocf_cache_line_settings *settings =
|
|
||||||
(struct ocf_cache_line_settings *)&metadata->settings;
|
|
||||||
struct ocf_core_meta_config *core_meta_config;
|
struct ocf_core_meta_config *core_meta_config;
|
||||||
struct ocf_core_meta_runtime *core_meta_runtime;
|
struct ocf_core_meta_runtime *core_meta_runtime;
|
||||||
struct ocf_user_part_config *part_config;
|
struct ocf_user_part_config *part_config;
|
||||||
@ -530,7 +522,7 @@ static int ocf_metadata_init_fixed_size(struct ocf_cache *cache,
|
|||||||
|
|
||||||
ENV_WARN_ON(metadata->priv);
|
ENV_WARN_ON(metadata->priv);
|
||||||
|
|
||||||
ocf_metadata_config_init(cache, settings, cache_line_size);
|
ocf_metadata_config_init(cache, cache_line_size);
|
||||||
|
|
||||||
ctrl = ocf_metadata_ctrl_init(metadata->is_volatile);
|
ctrl = ocf_metadata_ctrl_init(metadata->is_volatile);
|
||||||
if (!ctrl)
|
if (!ctrl)
|
||||||
@ -626,14 +618,12 @@ static void ocf_metadata_init_layout(struct ocf_cache *cache,
|
|||||||
* Initialize hash metadata interface
|
* Initialize hash metadata interface
|
||||||
*/
|
*/
|
||||||
int ocf_metadata_init_variable_size(struct ocf_cache *cache,
|
int ocf_metadata_init_variable_size(struct ocf_cache *cache,
|
||||||
uint64_t device_size, ocf_cache_line_size_t cache_line_size,
|
uint64_t device_size, ocf_cache_line_size_t line_size,
|
||||||
ocf_metadata_layout_t layout)
|
ocf_metadata_layout_t layout)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
struct ocf_metadata_ctrl *ctrl = NULL;
|
struct ocf_metadata_ctrl *ctrl = NULL;
|
||||||
struct ocf_cache_line_settings *settings =
|
|
||||||
(struct ocf_cache_line_settings *)&cache->metadata.settings;
|
|
||||||
ocf_flush_page_synch_t lock_page, unlock_page;
|
ocf_flush_page_synch_t lock_page, unlock_page;
|
||||||
uint64_t device_lines;
|
uint64_t device_lines;
|
||||||
struct ocf_metadata_segment *superblock;
|
struct ocf_metadata_segment *superblock;
|
||||||
@ -644,7 +634,7 @@ int ocf_metadata_init_variable_size(struct ocf_cache *cache,
|
|||||||
|
|
||||||
ctrl = cache->metadata.priv;
|
ctrl = cache->metadata.priv;
|
||||||
|
|
||||||
device_lines = device_size / cache_line_size;
|
device_lines = device_size / line_size;
|
||||||
if (device_lines >= (ocf_cache_line_t)(-1)){
|
if (device_lines >= (ocf_cache_line_t)(-1)){
|
||||||
/* TODO: This is just a rough check. Most optimal one would be
|
/* TODO: This is just a rough check. Most optimal one would be
|
||||||
* located in calculate_metadata_size. */
|
* located in calculate_metadata_size. */
|
||||||
@ -655,11 +645,11 @@ int ocf_metadata_init_variable_size(struct ocf_cache *cache,
|
|||||||
|
|
||||||
ctrl->device_lines = device_lines;
|
ctrl->device_lines = device_lines;
|
||||||
|
|
||||||
if (settings->size != cache_line_size)
|
if (cache->metadata.line_size != line_size)
|
||||||
/* Re-initialize settings with different cache line size */
|
/* Re-initialize metadata with different cache line size */
|
||||||
ocf_metadata_config_init(cache, settings, cache_line_size);
|
ocf_metadata_config_init(cache, line_size);
|
||||||
|
|
||||||
ctrl->mapping_size = ocf_metadata_status_sizeof(settings)
|
ctrl->mapping_size = ocf_metadata_status_sizeof(line_size)
|
||||||
+ sizeof(struct ocf_metadata_map);
|
+ sizeof(struct ocf_metadata_map);
|
||||||
|
|
||||||
ocf_metadata_init_layout(cache, layout);
|
ocf_metadata_init_layout(cache, layout);
|
||||||
@ -683,12 +673,11 @@ int ocf_metadata_init_variable_size(struct ocf_cache *cache,
|
|||||||
|
|
||||||
/* Entry size configuration */
|
/* Entry size configuration */
|
||||||
raw->entry_size
|
raw->entry_size
|
||||||
= ocf_metadata_get_element_size(i, settings);
|
= ocf_metadata_get_element_size(i, line_size);
|
||||||
raw->entries_in_page = PAGE_SIZE / raw->entry_size;
|
raw->entries_in_page = PAGE_SIZE / raw->entry_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ocf_metadata_calculate_metadata_size(cache, ctrl,
|
if (0 != ocf_metadata_calculate_metadata_size(cache, ctrl, line_size)) {
|
||||||
settings)) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,12 +756,12 @@ finalize:
|
|||||||
cache->device->metadata_offset = ctrl->count_pages * PAGE_SIZE;
|
cache->device->metadata_offset = ctrl->count_pages * PAGE_SIZE;
|
||||||
|
|
||||||
cache->conf_meta->cachelines = ctrl->cachelines;
|
cache->conf_meta->cachelines = ctrl->cachelines;
|
||||||
cache->conf_meta->line_size = cache_line_size;
|
cache->conf_meta->line_size = line_size;
|
||||||
|
|
||||||
ocf_metadata_raw_info(cache, ctrl);
|
ocf_metadata_raw_info(cache, ctrl);
|
||||||
|
|
||||||
ocf_cache_log(cache, log_info, "Cache line size: %llu kiB\n",
|
ocf_cache_log(cache, log_info, "Cache line size: %llu kiB\n",
|
||||||
settings->size / KiB);
|
line_size / KiB);
|
||||||
|
|
||||||
ocf_cache_log(cache, log_info, "Metadata capacity: %llu MiB\n",
|
ocf_cache_log(cache, log_info, "Metadata capacity: %llu MiB\n",
|
||||||
(uint64_t)ocf_metadata_size_of(cache) / MiB);
|
(uint64_t)ocf_metadata_size_of(cache) / MiB);
|
||||||
@ -1499,7 +1488,7 @@ void ocf_metadata_set_hash(struct ocf_cache *cache, ocf_cache_line_t index,
|
|||||||
bool ocf_metadata_##what(struct ocf_cache *cache, \
|
bool ocf_metadata_##what(struct ocf_cache *cache, \
|
||||||
ocf_cache_line_t line, uint8_t start, uint8_t stop, bool all) \
|
ocf_cache_line_t line, uint8_t start, uint8_t stop, bool all) \
|
||||||
{ \
|
{ \
|
||||||
switch (cache->metadata.settings.size) { \
|
switch (cache->metadata.line_size) { \
|
||||||
case ocf_cache_line_size_4: \
|
case ocf_cache_line_size_4: \
|
||||||
return _ocf_metadata_##what##_u8(cache, line, start, stop, all); \
|
return _ocf_metadata_##what##_u8(cache, line, start, stop, all); \
|
||||||
case ocf_cache_line_size_8: \
|
case ocf_cache_line_size_8: \
|
||||||
@ -1522,7 +1511,7 @@ bool ocf_metadata_##what(struct ocf_cache *cache, \
|
|||||||
bool ocf_metadata_##what(struct ocf_cache *cache, \
|
bool ocf_metadata_##what(struct ocf_cache *cache, \
|
||||||
ocf_cache_line_t line, uint8_t start, uint8_t stop) \
|
ocf_cache_line_t line, uint8_t start, uint8_t stop) \
|
||||||
{ \
|
{ \
|
||||||
switch (cache->metadata.settings.size) { \
|
switch (cache->metadata.line_size) { \
|
||||||
case ocf_cache_line_size_4: \
|
case ocf_cache_line_size_4: \
|
||||||
return _ocf_metadata_##what##_u8(cache, line, start, stop); \
|
return _ocf_metadata_##what##_u8(cache, line, start, stop); \
|
||||||
case ocf_cache_line_size_8: \
|
case ocf_cache_line_size_8: \
|
||||||
|
24
src/metadata/metadata_cache_line.h
Normal file
24
src/metadata/metadata_cache_line.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright(c) 2012-2021 Intel Corporation
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __METADATA_CACHE_LINE_H__
|
||||||
|
#define __METADATA_CACHE_LINE_H__
|
||||||
|
|
||||||
|
static inline ocf_cache_line_size_t ocf_line_size(struct ocf_cache *cache)
|
||||||
|
{
|
||||||
|
return cache->metadata.line_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t ocf_line_sectors(struct ocf_cache *cache)
|
||||||
|
{
|
||||||
|
return BYTES_TO_SECTORS(cache->metadata.line_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t ocf_line_end_sector(struct ocf_cache *cache)
|
||||||
|
{
|
||||||
|
return ocf_line_sectors(cache) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __METADATA_CACHE_LINE_H__ */
|
@ -7,6 +7,7 @@
|
|||||||
#define __METADATA_STATUS_H__
|
#define __METADATA_STATUS_H__
|
||||||
|
|
||||||
#include "../concurrency/ocf_metadata_concurrency.h"
|
#include "../concurrency/ocf_metadata_concurrency.h"
|
||||||
|
#include "metadata_cache_line.h"
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Dirty
|
* Dirty
|
||||||
@ -29,12 +30,8 @@ bool ocf_metadata_test_and_clear_valid(struct ocf_cache *cache, ocf_cache_line_t
|
|||||||
static inline void metadata_init_status_bits(struct ocf_cache *cache,
|
static inline void metadata_init_status_bits(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
ocf_metadata_clear_dirty(cache, line,
|
ocf_metadata_clear_dirty(cache, line, 0, ocf_line_end_sector(cache));
|
||||||
cache->metadata.settings.sector_start,
|
ocf_metadata_clear_valid(cache, line, 0, ocf_line_end_sector(cache));
|
||||||
cache->metadata.settings.sector_end);
|
|
||||||
ocf_metadata_clear_valid(cache, line,
|
|
||||||
cache->metadata.settings.sector_start,
|
|
||||||
cache->metadata.settings.sector_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool metadata_test_dirty_all(struct ocf_cache *cache,
|
static inline bool metadata_test_dirty_all(struct ocf_cache *cache,
|
||||||
@ -42,9 +39,8 @@ static inline bool metadata_test_dirty_all(struct ocf_cache *cache,
|
|||||||
{
|
{
|
||||||
bool test;
|
bool test;
|
||||||
|
|
||||||
test = ocf_metadata_test_dirty(cache, line,
|
test = ocf_metadata_test_dirty(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), true);
|
||||||
cache->metadata.settings.sector_end, true);
|
|
||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
@ -54,9 +50,8 @@ static inline bool metadata_test_dirty(struct ocf_cache *cache,
|
|||||||
{
|
{
|
||||||
bool test;
|
bool test;
|
||||||
|
|
||||||
test = ocf_metadata_test_dirty(cache, line,
|
test = ocf_metadata_test_dirty(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), false);
|
||||||
cache->metadata.settings.sector_end, false);
|
|
||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
@ -64,33 +59,27 @@ static inline bool metadata_test_dirty(struct ocf_cache *cache,
|
|||||||
static inline void metadata_set_dirty(struct ocf_cache *cache,
|
static inline void metadata_set_dirty(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
ocf_metadata_set_dirty(cache, line,
|
ocf_metadata_set_dirty(cache, line, 0, ocf_line_end_sector(cache));
|
||||||
cache->metadata.settings.sector_start,
|
|
||||||
cache->metadata.settings.sector_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void metadata_clear_dirty(struct ocf_cache *cache,
|
static inline void metadata_clear_dirty(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
ocf_metadata_clear_dirty(cache, line,
|
ocf_metadata_clear_dirty(cache, line, 0, ocf_line_end_sector(cache));
|
||||||
cache->metadata.settings.sector_start,
|
|
||||||
cache->metadata.settings.sector_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool metadata_test_and_clear_dirty(
|
static inline bool metadata_test_and_clear_dirty(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t line)
|
struct ocf_cache *cache, ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
return ocf_metadata_test_and_clear_dirty(cache, line,
|
return ocf_metadata_test_and_clear_dirty(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), false);
|
||||||
cache->metadata.settings.sector_end, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool metadata_test_and_set_dirty(struct ocf_cache *cache,
|
static inline bool metadata_test_and_set_dirty(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
return ocf_metadata_test_and_set_dirty(cache, line,
|
return ocf_metadata_test_and_set_dirty(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), false);
|
||||||
cache->metadata.settings.sector_end, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -202,49 +191,41 @@ static inline bool metadata_set_dirty_sec_changed(
|
|||||||
static inline bool metadata_test_valid_any(struct ocf_cache *cache,
|
static inline bool metadata_test_valid_any(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
return ocf_metadata_test_valid(cache, line,
|
return ocf_metadata_test_valid(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), false);
|
||||||
cache->metadata.settings.sector_end, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool metadata_test_valid(struct ocf_cache *cache,
|
static inline bool metadata_test_valid(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
return ocf_metadata_test_valid(cache, line,
|
return ocf_metadata_test_valid(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), true);
|
||||||
cache->metadata.settings.sector_end, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void metadata_set_valid(struct ocf_cache *cache,
|
static inline void metadata_set_valid(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
ocf_metadata_set_valid(cache, line,
|
ocf_metadata_set_valid(cache, line, 0, ocf_line_end_sector(cache));
|
||||||
cache->metadata.settings.sector_start,
|
|
||||||
cache->metadata.settings.sector_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void metadata_clear_valid(struct ocf_cache *cache,
|
static inline void metadata_clear_valid(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
ocf_metadata_clear_valid(cache, line,
|
ocf_metadata_clear_valid(cache, line, 0, ocf_line_end_sector(cache));
|
||||||
cache->metadata.settings.sector_start,
|
|
||||||
cache->metadata.settings.sector_end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool metadata_test_and_clear_valid(
|
static inline bool metadata_test_and_clear_valid(
|
||||||
struct ocf_cache *cache, ocf_cache_line_t line)
|
struct ocf_cache *cache, ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
return ocf_metadata_test_and_clear_valid(cache, line,
|
return ocf_metadata_test_and_clear_valid(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), true);
|
||||||
cache->metadata.settings.sector_end, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool metadata_test_and_set_valid(struct ocf_cache *cache,
|
static inline bool metadata_test_and_set_valid(struct ocf_cache *cache,
|
||||||
ocf_cache_line_t line)
|
ocf_cache_line_t line)
|
||||||
{
|
{
|
||||||
return ocf_metadata_test_and_set_valid(cache, line,
|
return ocf_metadata_test_and_set_valid(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), true);
|
||||||
cache->metadata.settings.sector_end, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -317,9 +298,8 @@ static inline bool metadata_clear_valid_sec_changed(
|
|||||||
{
|
{
|
||||||
bool was_any_valid;
|
bool was_any_valid;
|
||||||
|
|
||||||
was_any_valid = ocf_metadata_test_valid(cache, line,
|
was_any_valid = ocf_metadata_test_valid(cache, line, 0,
|
||||||
cache->metadata.settings.sector_start,
|
ocf_line_end_sector(cache), false);
|
||||||
cache->metadata.settings.sector_end, false);
|
|
||||||
|
|
||||||
*is_valid = ocf_metadata_clear_valid(cache, line,
|
*is_valid = ocf_metadata_clear_valid(cache, line,
|
||||||
start, stop);
|
start, stop);
|
||||||
|
@ -36,14 +36,6 @@ enum ocf_metadata_shutdown_status {
|
|||||||
typedef void (*ocf_metadata_query_cores_end_t)(void *priv, int error,
|
typedef void (*ocf_metadata_query_cores_end_t)(void *priv, int error,
|
||||||
unsigned int num_cores);
|
unsigned int num_cores);
|
||||||
|
|
||||||
struct ocf_cache_line_settings {
|
|
||||||
ocf_cache_line_size_t size;
|
|
||||||
uint64_t sector_count;
|
|
||||||
uint64_t sector_start;
|
|
||||||
uint64_t sector_end;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define OCF_METADATA_GLOBAL_LOCK_IDX_BITS 2
|
#define OCF_METADATA_GLOBAL_LOCK_IDX_BITS 2
|
||||||
#define OCF_NUM_GLOBAL_META_LOCKS (1 << (OCF_METADATA_GLOBAL_LOCK_IDX_BITS))
|
#define OCF_NUM_GLOBAL_META_LOCKS (1 << (OCF_METADATA_GLOBAL_LOCK_IDX_BITS))
|
||||||
|
|
||||||
@ -74,8 +66,8 @@ struct ocf_metadata {
|
|||||||
void *priv;
|
void *priv;
|
||||||
/*!< Private data of metadata service interface */
|
/*!< Private data of metadata service interface */
|
||||||
|
|
||||||
const struct ocf_cache_line_settings settings;
|
ocf_cache_line_size_t line_size;
|
||||||
/*!< Cache line configuration */
|
/*!< Cache line size */
|
||||||
|
|
||||||
bool is_volatile;
|
bool is_volatile;
|
||||||
/*!< true if metadata used in volatile mode (RAM only) */
|
/*!< true if metadata used in volatile mode (RAM only) */
|
||||||
|
@ -514,8 +514,7 @@ static void _recovery_invalidate_clean_sec(struct ocf_cache *cache,
|
|||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
for (i = ocf_line_start_sector(cache);
|
for (i = 0; i <= ocf_line_sectors(cache); i++) {
|
||||||
i <= ocf_line_end_sector(cache); i++) {
|
|
||||||
if (!metadata_test_dirty_one(cache, cline, i)) {
|
if (!metadata_test_dirty_one(cache, cline, i)) {
|
||||||
/* Invalidate clear sectors */
|
/* Invalidate clear sectors */
|
||||||
metadata_clear_valid_sec_one(cache, cline, i);
|
metadata_clear_valid_sec_one(cache, cline, i);
|
||||||
@ -1086,7 +1085,7 @@ static void _ocf_mngt_attach_prepare_metadata(ocf_pipeline_t pipeline,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
context->metadata.line_size = context->metadata.line_size ?:
|
context->metadata.line_size = context->metadata.line_size ?:
|
||||||
cache->metadata.settings.size;
|
cache->metadata.line_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize variable size metadata segments
|
* Initialize variable size metadata segments
|
||||||
@ -2144,7 +2143,7 @@ static void _ocf_mngt_activate_check_superblock_complete(void *priv, int error)
|
|||||||
-OCF_ERR_METADATA_LAYOUT_MISMATCH);
|
-OCF_ERR_METADATA_LAYOUT_MISMATCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache->conf_meta->line_size != cache->metadata.settings.size) {
|
if (cache->conf_meta->line_size != cache->metadata.line_size) {
|
||||||
OCF_PL_FINISH_RET(context->pipeline,
|
OCF_PL_FINISH_RET(context->pipeline,
|
||||||
-OCF_ERR_CACHE_LINE_SIZE_MISMATCH);
|
-OCF_ERR_CACHE_LINE_SIZE_MISMATCH);
|
||||||
}
|
}
|
||||||
|
@ -19,32 +19,6 @@
|
|||||||
* @brief OCF utilities for cache line operations
|
* @brief OCF utilities for cache line operations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline ocf_cache_line_size_t ocf_line_size(
|
|
||||||
struct ocf_cache *cache)
|
|
||||||
{
|
|
||||||
return cache->metadata.settings.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t ocf_line_pages(struct ocf_cache *cache)
|
|
||||||
{
|
|
||||||
return cache->metadata.settings.size / PAGE_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t ocf_line_sectors(struct ocf_cache *cache)
|
|
||||||
{
|
|
||||||
return cache->metadata.settings.sector_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t ocf_line_end_sector(struct ocf_cache *cache)
|
|
||||||
{
|
|
||||||
return cache->metadata.settings.sector_end;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t ocf_line_start_sector(struct ocf_cache *cache)
|
|
||||||
{
|
|
||||||
return cache->metadata.settings.sector_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t ocf_bytes_round_lines(struct ocf_cache *cache,
|
static inline uint64_t ocf_bytes_round_lines(struct ocf_cache *cache,
|
||||||
uint64_t bytes)
|
uint64_t bytes)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user