Fix race condition during cache attach
After attaching new cache device handle all the IOs in Pass-Through mode until all the d2c requests are completed. Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
This commit is contained in:
parent
2c28f33e37
commit
0d06b3a597
@ -162,6 +162,11 @@ void ocf_resolve_effective_cache_mode(ocf_cache_t cache,
|
||||
return;
|
||||
}
|
||||
|
||||
if (env_atomic_read(&cache->attach_pt)) {
|
||||
req->cache_mode = ocf_req_cache_mode_pt;
|
||||
return;
|
||||
}
|
||||
|
||||
if (cache->pt_unaligned_io && !ocf_req_is_4k(req->addr, req->bytes)) {
|
||||
req->cache_mode = ocf_req_cache_mode_pt;
|
||||
return;
|
||||
|
@ -1901,18 +1901,35 @@ static void _ocf_mngt_attach_shutdown_status(ocf_pipeline_t pipeline,
|
||||
_ocf_mngt_attach_shutdown_status_complete, context);
|
||||
}
|
||||
|
||||
|
||||
static void _ocf_mngt_attach_post_init_finish(void *priv)
|
||||
{
|
||||
struct ocf_cache_attach_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
|
||||
ocf_refcnt_unfreeze(&cache->refcnt.d2c);
|
||||
|
||||
env_atomic_set(&cache->attach_pt, 0);
|
||||
|
||||
ocf_cache_log(cache, log_debug, "Cache attached\n");
|
||||
|
||||
ocf_pipeline_next(context->pipeline);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_attach_post_init(ocf_pipeline_t pipeline,
|
||||
void *priv, ocf_pipeline_arg_t arg)
|
||||
{
|
||||
struct ocf_cache_attach_context *context = priv;
|
||||
ocf_cache_t cache = context->cache;
|
||||
|
||||
env_atomic_set(&cache->attach_pt, 1);
|
||||
|
||||
ocf_cleaner_refcnt_unfreeze(cache);
|
||||
ocf_refcnt_unfreeze(&cache->refcnt.metadata);
|
||||
|
||||
ocf_cache_log(cache, log_debug, "Cache attached\n");
|
||||
|
||||
ocf_pipeline_next(pipeline);
|
||||
ocf_refcnt_freeze(&cache->refcnt.d2c);
|
||||
ocf_refcnt_register_zero_cb(&cache->refcnt.d2c,
|
||||
_ocf_mngt_attach_post_init_finish, context);
|
||||
}
|
||||
|
||||
static void _ocf_mngt_attach_handle_error(
|
||||
|
@ -106,6 +106,8 @@ struct ocf_cache {
|
||||
env_atomic flush_in_progress;
|
||||
env_mutex flush_mutex;
|
||||
|
||||
env_atomic attach_pt;
|
||||
|
||||
struct ocf_cleaner cleaner;
|
||||
|
||||
struct list_head io_queues;
|
||||
|
Loading…
Reference in New Issue
Block a user