Metadata clear_dirty_if_invalid()
utility
Fix cacheline's metadata if it is dirty and invalid Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
parent
800190153b
commit
bb0ff67fe9
@ -1566,6 +1566,31 @@ bool ocf_metadata_clear_valid_if_clean(struct ocf_cache *cache,
|
||||
}
|
||||
}
|
||||
|
||||
void ocf_metadata_clear_dirty_if_invalid(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_dirty_if_invalid_u8(cache,
|
||||
line, start, stop);
|
||||
case ocf_cache_line_size_8:
|
||||
return _ocf_metadata_clear_dirty_if_invalid_u16(cache,
|
||||
line, start, stop);
|
||||
case ocf_cache_line_size_16:
|
||||
return _ocf_metadata_clear_dirty_if_invalid_u32(cache,
|
||||
line, start, stop);
|
||||
case ocf_cache_line_size_32:
|
||||
return _ocf_metadata_clear_dirty_if_invalid_u64(cache,
|
||||
line, start, stop);
|
||||
case ocf_cache_line_size_64:
|
||||
return _ocf_metadata_clear_dirty_if_invalid_u128(cache,
|
||||
line, start, stop);
|
||||
case ocf_cache_line_size_none:
|
||||
default:
|
||||
ENV_BUG();
|
||||
}
|
||||
}
|
||||
|
||||
int ocf_metadata_init(struct ocf_cache *cache,
|
||||
ocf_cache_line_size_t cache_line_size)
|
||||
{
|
||||
|
@ -245,6 +245,24 @@ static bool _ocf_metadata_clear_valid_if_clean_##type(struct ocf_cache *cache, \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void _ocf_metadata_clear_dirty_if_invalid_##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].dirty &= (mask & map[line].valid) | (~mask); \
|
||||
} \
|
||||
|
||||
#define ocf_metadata_bit_funcs(type) \
|
||||
ocf_metadata_bit_struct(type); \
|
||||
|
@ -40,6 +40,8 @@ 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);
|
||||
void ocf_metadata_clear_dirty_if_invalid(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,
|
||||
ocf_cache_line_t line)
|
||||
@ -249,6 +251,13 @@ static inline bool metadata_test_and_set_valid(struct ocf_cache *cache,
|
||||
ocf_line_end_sector(cache), true);
|
||||
}
|
||||
|
||||
static inline void metadata_clear_dirty_if_invalid(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
ocf_metadata_clear_dirty_if_invalid(cache, line, 0,
|
||||
ocf_line_end_sector(cache));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Valid - Sector Implementation
|
||||
******************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user