Wait for metadata requests in stop
@@ -1907,15 +1907,22 @@ struct ocf_mngt_cache_stop_context {
int cache_write_error;
};
-static void ocf_mngt_cache_stop_wait_io(ocf_pipeline_t pipeline,
+static void ocf_mngt_cache_stop_wait_metadata_io_finish(void *priv)
+{
+ struct ocf_mngt_cache_stop_context *context = priv;
+
+ ocf_pipeline_next(context->pipeline);
+}
+
+static void ocf_mngt_cache_stop_wait_metadata_io(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
struct ocf_mngt_cache_stop_context *context = priv;
ocf_cache_t cache = context->cache;
- /* TODO: Make this asynchronous! */
- ocf_cache_wait_for_io_finish(cache);
- ocf_pipeline_next(pipeline);
+ ocf_refcnt_freeze(&cache->refcnt.metadata);
+ ocf_refcnt_register_zero_cb(&cache->refcnt.metadata,
+ ocf_mngt_cache_stop_wait_metadata_io_finish, context);
}
static void ocf_mngt_cache_stop_remove_cores(ocf_pipeline_t pipeline,
@@ -1995,6 +2002,9 @@ static void ocf_mngt_cache_stop_finish(ocf_pipeline_t pipeline,
list_del(&cache->list);
env_mutex_unlock(&ctx->lock);
} else {
+ /* undo metadata counter freeze */
+ ocf_refcnt_unfreeze(&cache->refcnt.metadata);
+
env_bit_clear(ocf_cache_state_stopping, &cache->cache_state);
env_bit_set(ocf_cache_state_running, &cache->cache_state);
}
@@ -2028,7 +2038,7 @@ struct ocf_pipeline_properties ocf_mngt_cache_stop_pipeline_properties = {
.priv_size = sizeof(struct ocf_mngt_cache_stop_context),
.finish = ocf_mngt_cache_stop_finish,
.steps = {
- OCF_PL_STEP(ocf_mngt_cache_stop_wait_io),
+ OCF_PL_STEP(ocf_mngt_cache_stop_wait_metadata_io),
OCF_PL_STEP(ocf_mngt_cache_stop_remove_cores),
OCF_PL_STEP(ocf_mngt_cache_stop_unplug),
OCF_PL_STEP(ocf_mngt_cache_stop_put_io_queues),
