Add function to check for lazy write cache mode (WO or WB)
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
parent
a6312eb8aa
commit
b97bb6f53b
@ -695,6 +695,17 @@ typedef void (*ocf_mngt_cache_save_end_t)(ocf_cache_t cache,
|
|||||||
void ocf_mngt_cache_save(ocf_cache_t cache,
|
void ocf_mngt_cache_save(ocf_cache_t cache,
|
||||||
ocf_mngt_cache_save_end_t cmpl, void *priv);
|
ocf_mngt_cache_save_end_t cmpl, void *priv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Determines whether given cache mode has write-back semantics, i.e. it
|
||||||
|
* allows for writes to be serviced in cache and lazily propagated to core.
|
||||||
|
*
|
||||||
|
* @param[in] mode input cache mode
|
||||||
|
*/
|
||||||
|
static inline bool ocf_mngt_cache_mode_has_lazy_write(ocf_cache_mode_t mode)
|
||||||
|
{
|
||||||
|
return mode == ocf_cache_mode_wb || mode == ocf_cache_mode_wo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set cache mode in given cache
|
* @brief Set cache mode in given cache
|
||||||
*
|
*
|
||||||
|
@ -59,6 +59,13 @@ static inline bool ocf_cache_mode_is_valid(ocf_cache_mode_t mode)
|
|||||||
return mode >= ocf_cache_mode_wt && mode < ocf_cache_mode_max;
|
return mode >= ocf_cache_mode_wt && mode < ocf_cache_mode_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool ocf_req_cache_mode_has_lazy_write(ocf_req_cache_mode_t mode)
|
||||||
|
{
|
||||||
|
return ocf_cache_mode_is_valid((ocf_cache_mode_t)mode) &&
|
||||||
|
ocf_mngt_cache_mode_has_lazy_write(
|
||||||
|
(ocf_cache_mode_t)mode);
|
||||||
|
}
|
||||||
|
|
||||||
void ocf_seq_cutoff_update(ocf_core_t core, struct ocf_request *req);
|
void ocf_seq_cutoff_update(ocf_core_t core, struct ocf_request *req);
|
||||||
|
|
||||||
bool ocf_fallback_pt_is_on(ocf_cache_t cache);
|
bool ocf_fallback_pt_is_on(ocf_cache_t cache);
|
||||||
|
@ -2147,8 +2147,10 @@ static int _cache_mngt_set_cache_mode(ocf_cache_t cache, ocf_cache_mode_t mode)
|
|||||||
|
|
||||||
cache->conf_meta->cache_mode = mode;
|
cache->conf_meta->cache_mode = mode;
|
||||||
|
|
||||||
if (mode_old == ocf_cache_mode_wb)
|
if (ocf_mngt_cache_mode_has_lazy_write(mode_old) &&
|
||||||
|
!ocf_mngt_cache_mode_has_lazy_write(mode)) {
|
||||||
_cache_mngt_update_initial_dirty_clines(cache);
|
_cache_mngt_update_initial_dirty_clines(cache);
|
||||||
|
}
|
||||||
|
|
||||||
ocf_cache_log(cache, log_info, "Changing cache mode from '%s' to '%s' "
|
ocf_cache_log(cache, log_info, "Changing cache mode from '%s' to '%s' "
|
||||||
"successful\n", ocf_get_io_iface_name(mode_old),
|
"successful\n", ocf_get_io_iface_name(mode_old),
|
||||||
|
@ -251,7 +251,9 @@ void ocf_core_submit_io_mode(struct ocf_io *io, ocf_cache_mode_t cache_mode)
|
|||||||
|
|
||||||
if (cache_mode == ocf_cache_mode_none)
|
if (cache_mode == ocf_cache_mode_none)
|
||||||
req_cache_mode = ocf_get_effective_cache_mode(cache, core, io);
|
req_cache_mode = ocf_get_effective_cache_mode(cache, core, io);
|
||||||
if (req_cache_mode == ocf_req_cache_mode_wb &&
|
|
||||||
|
if (io->dir == OCF_WRITE &&
|
||||||
|
ocf_req_cache_mode_has_lazy_write(req_cache_mode) &&
|
||||||
ocf_io_set_dirty(cache, core_io)) {
|
ocf_io_set_dirty(cache, core_io)) {
|
||||||
req_cache_mode = ocf_req_cache_mode_wt;
|
req_cache_mode = ocf_req_cache_mode_wt;
|
||||||
}
|
}
|
||||||
@ -319,7 +321,9 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
|
|||||||
}
|
}
|
||||||
|
|
||||||
req_cache_mode = ocf_get_effective_cache_mode(cache, core, io);
|
req_cache_mode = ocf_get_effective_cache_mode(cache, core, io);
|
||||||
if (req_cache_mode == ocf_req_cache_mode_wb &&
|
|
||||||
|
if (io->dir == OCF_WRITE &&
|
||||||
|
ocf_req_cache_mode_has_lazy_write(req_cache_mode) &&
|
||||||
ocf_io_set_dirty(cache, core_io)) {
|
ocf_io_set_dirty(cache, core_io)) {
|
||||||
req_cache_mode = ocf_req_cache_mode_wt;
|
req_cache_mode = ocf_req_cache_mode_wt;
|
||||||
}
|
}
|
||||||
@ -328,6 +332,7 @@ int ocf_core_submit_io_fast(struct ocf_io *io)
|
|||||||
case ocf_req_cache_mode_pt:
|
case ocf_req_cache_mode_pt:
|
||||||
return -OCF_ERR_IO;
|
return -OCF_ERR_IO;
|
||||||
case ocf_req_cache_mode_wb:
|
case ocf_req_cache_mode_wb:
|
||||||
|
case ocf_req_cache_mode_wo:
|
||||||
req_cache_mode = ocf_req_cache_mode_fast;
|
req_cache_mode = ocf_req_cache_mode_fast;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user