Introduce ocf_metadata_clear_valid_if_clean()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
d7c1404f82
commit
65d3e7a41a
@ -1540,6 +1540,32 @@ bool ocf_metadata_##what(struct ocf_cache *cache, \
|
|||||||
_ocf_metadata_funcs(dirty)
|
_ocf_metadata_funcs(dirty)
|
||||||
_ocf_metadata_funcs(valid)
|
_ocf_metadata_funcs(valid)
|
||||||
|
|
||||||
|
bool ocf_metadata_clear_valid_if_clean(struct ocf_cache *cache,
|
||||||
|
ocf_cache_line_t line, uint8_t start, uint8_t stop)
|
||||||
|
{
|
||||||
|
switch (cache->metadata.line_size) {
|
||||||
|
case ocf_cache_line_size_4:
|
||||||
|
return _ocf_metadata_clear_valid_if_clean_u8(cache,
|
||||||
|
line, start, stop);
|
||||||
|
case ocf_cache_line_size_8:
|
||||||
|
return _ocf_metadata_clear_valid_if_clean_u16(cache,
|
||||||
|
line, start, stop);
|
||||||
|
case ocf_cache_line_size_16:
|
||||||
|
return _ocf_metadata_clear_valid_if_clean_u32(cache,
|
||||||
|
line, start, stop);
|
||||||
|
case ocf_cache_line_size_32:
|
||||||
|
return _ocf_metadata_clear_valid_if_clean_u64(cache,
|
||||||
|
line, start, stop);
|
||||||
|
case ocf_cache_line_size_64:
|
||||||
|
return _ocf_metadata_clear_valid_if_clean_u128(cache,
|
||||||
|
line, start, stop);
|
||||||
|
case ocf_cache_line_size_none:
|
||||||
|
default:
|
||||||
|
ENV_BUG_ON(1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int ocf_metadata_init(struct ocf_cache *cache,
|
int ocf_metadata_init(struct ocf_cache *cache,
|
||||||
ocf_cache_line_size_t cache_line_size)
|
ocf_cache_line_size_t cache_line_size)
|
||||||
{
|
{
|
||||||
|
@ -221,10 +221,36 @@ static bool _ocf_metadata_test_and_clear_##what##_##type( \
|
|||||||
return test; \
|
return test; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
|
#define ocf_metadata_bit_func_basic(type) \
|
||||||
|
static bool _ocf_metadata_clear_valid_if_clean_##type(struct ocf_cache *cache, \
|
||||||
|
ocf_cache_line_t line, uint8_t start, uint8_t stop) \
|
||||||
|
{ \
|
||||||
|
type mask = _get_mask_##type(start, stop); \
|
||||||
|
\
|
||||||
|
struct ocf_metadata_ctrl *ctrl = \
|
||||||
|
(struct ocf_metadata_ctrl *) cache->metadata.priv; \
|
||||||
|
\
|
||||||
|
struct ocf_metadata_raw *raw = \
|
||||||
|
&ctrl->raw_desc[metadata_segment_collision]; \
|
||||||
|
\
|
||||||
|
struct ocf_metadata_map_##type *map = raw->mem_pool; \
|
||||||
|
\
|
||||||
|
_raw_bug_on(raw, line); \
|
||||||
|
\
|
||||||
|
map[line].valid &= ~mask & map[line].dirty; \
|
||||||
|
\
|
||||||
|
if (map[line].valid) { \
|
||||||
|
return true; \
|
||||||
|
} else { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
#define ocf_metadata_bit_funcs(type) \
|
#define ocf_metadata_bit_funcs(type) \
|
||||||
ocf_metadata_bit_struct(type); \
|
ocf_metadata_bit_struct(type); \
|
||||||
ocf_metadata_bit_func(dirty, type); \
|
ocf_metadata_bit_func(dirty, type); \
|
||||||
ocf_metadata_bit_func(valid, type); \
|
ocf_metadata_bit_func(valid, type); \
|
||||||
|
ocf_metadata_bit_func_basic(type); \
|
||||||
|
|
||||||
ocf_metadata_bit_funcs(u8);
|
ocf_metadata_bit_funcs(u8);
|
||||||
ocf_metadata_bit_funcs(u16);
|
ocf_metadata_bit_funcs(u16);
|
||||||
|
@ -26,6 +26,8 @@ bool ocf_metadata_clear_valid(struct ocf_cache *cache, ocf_cache_line_t line, ui
|
|||||||
bool ocf_metadata_set_valid(struct ocf_cache *cache, ocf_cache_line_t line, uint8_t start, uint8_t stop);
|
bool ocf_metadata_set_valid(struct ocf_cache *cache, ocf_cache_line_t line, uint8_t start, uint8_t stop);
|
||||||
bool ocf_metadata_test_and_set_valid(struct ocf_cache *cache, ocf_cache_line_t line, uint8_t start, uint8_t stop, bool all);
|
bool ocf_metadata_test_and_set_valid(struct ocf_cache *cache, ocf_cache_line_t line, uint8_t start, uint8_t stop, bool all);
|
||||||
bool ocf_metadata_test_and_clear_valid(struct ocf_cache *cache, ocf_cache_line_t line, uint8_t start, uint8_t stop, bool all);
|
bool ocf_metadata_test_and_clear_valid(struct ocf_cache *cache, ocf_cache_line_t line, uint8_t start, uint8_t stop, bool all);
|
||||||
|
bool ocf_metadata_clear_valid_if_clean(struct ocf_cache *cache,
|
||||||
|
ocf_cache_line_t line, uint8_t start, uint8_t stop);
|
||||||
|
|
||||||
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)
|
||||||
@ -214,6 +216,13 @@ static inline void metadata_clear_valid(struct ocf_cache *cache,
|
|||||||
ocf_metadata_clear_valid(cache, line, 0, ocf_line_end_sector(cache));
|
ocf_metadata_clear_valid(cache, line, 0, ocf_line_end_sector(cache));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void metadata_clear_valid_if_clean(struct ocf_cache *cache,
|
||||||
|
ocf_cache_line_t line)
|
||||||
|
{
|
||||||
|
ocf_metadata_clear_valid_if_clean(cache, line, 0,
|
||||||
|
ocf_line_end_sector(cache));
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user