Add API function ocf_cache_wait_for_io_finish()
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
435cc6209a
commit
44ed250d41
@ -172,6 +172,13 @@ bool ocf_cache_is_device_attached(ocf_cache_t cache);
|
|||||||
*/
|
*/
|
||||||
bool ocf_cache_is_running(ocf_cache_t cache);
|
bool ocf_cache_is_running(ocf_cache_t cache);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait for all IO to finish
|
||||||
|
*
|
||||||
|
* @param[in] cache Cache object
|
||||||
|
*/
|
||||||
|
void ocf_cache_wait_for_io_finish(ocf_cache_t cache);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get cache mode of given cache object
|
* @brief Get cache mode of given cache object
|
||||||
*
|
*
|
||||||
|
@ -1579,7 +1579,7 @@ static int _ocf_mngt_cache_stop(ocf_cache_t cache)
|
|||||||
env_bit_set(ocf_cache_state_stopping, &cache->cache_state);
|
env_bit_set(ocf_cache_state_stopping, &cache->cache_state);
|
||||||
env_bit_clear(ocf_cache_state_running, &cache->cache_state);
|
env_bit_clear(ocf_cache_state_running, &cache->cache_state);
|
||||||
|
|
||||||
ocf_mngt_wait_for_io_finish(cache);
|
ocf_cache_wait_for_io_finish(cache);
|
||||||
|
|
||||||
/* All exported objects removed, cleaning up rest. */
|
/* All exported objects removed, cleaning up rest. */
|
||||||
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
|
for (i = 0, j = 0; j < no && i < OCF_CORE_MAX; i++) {
|
||||||
@ -1681,7 +1681,7 @@ int ocf_mngt_cache_stop(ocf_cache_t cache)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
char cache_name[OCF_CACHE_NAME_SIZE];
|
char cache_name[OCF_CACHE_NAME_SIZE];
|
||||||
ocf_ctx_t context;
|
ocf_ctx_t ctx;
|
||||||
|
|
||||||
OCF_CHECK_NULL(cache);
|
OCF_CHECK_NULL(cache);
|
||||||
|
|
||||||
@ -1690,21 +1690,21 @@ int ocf_mngt_cache_stop(ocf_cache_t cache)
|
|||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
context = ocf_cache_get_ctx(cache);
|
ctx = ocf_cache_get_ctx(cache);
|
||||||
|
|
||||||
ocf_cache_log(cache, log_info, "Stopping cache\n");
|
ocf_cache_log(cache, log_info, "Stopping cache\n");
|
||||||
|
|
||||||
result = _ocf_mngt_cache_stop(cache);
|
result = _ocf_mngt_cache_stop(cache);
|
||||||
|
|
||||||
if (result == -OCF_ERR_WRITE_CACHE) {
|
if (result == -OCF_ERR_WRITE_CACHE) {
|
||||||
ocf_log(context, log_warn, "Stopped cache %s with "
|
ocf_log(ctx, log_warn, "Stopped cache %s with errors\n",
|
||||||
"errors\n", cache_name);
|
cache_name);
|
||||||
} else if (result) {
|
} else if (result) {
|
||||||
ocf_log(context, log_err, "Stopping cache %s "
|
ocf_log(ctx, log_err, "Stopping cache %s failed\n",
|
||||||
"failed\n", cache_name);
|
cache_name);
|
||||||
} else {
|
} else {
|
||||||
ocf_log(context, log_info, "Cache %s successfully "
|
ocf_log(ctx, log_info, "Cache %s successfully stopped\n",
|
||||||
"stopped\n", cache_name);
|
cache_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -434,15 +434,3 @@ int ocf_mngt_cache_visit_reverse(ocf_ctx_t ocf_ctx,
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_mngt_wait_for_io_finish(ocf_cache_t cache)
|
|
||||||
{
|
|
||||||
uint32_t req_active = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
req_active = ocf_req_get_allocated(cache);
|
|
||||||
if (req_active)
|
|
||||||
env_msleep(500);
|
|
||||||
} while (req_active);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@ int cache_mng_thread_io_requests(void *data);
|
|||||||
|
|
||||||
bool ocf_mngt_cache_is_dirty(ocf_cache_t cache);
|
bool ocf_mngt_cache_is_dirty(ocf_cache_t cache);
|
||||||
|
|
||||||
void ocf_mngt_wait_for_io_finish(ocf_cache_t cache);
|
|
||||||
|
|
||||||
int ocf_mngt_add_partition_to_cache(struct ocf_cache *cache,
|
int ocf_mngt_add_partition_to_cache(struct ocf_cache *cache,
|
||||||
ocf_part_id_t part_id, const char *name, uint32_t min_size,
|
ocf_part_id_t part_id, const char *name, uint32_t min_size,
|
||||||
uint32_t max_size, uint8_t priority, bool valid);
|
uint32_t max_size, uint8_t priority, bool valid);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "metadata/metadata.h"
|
#include "metadata/metadata.h"
|
||||||
#include "engine/cache_engine.h"
|
#include "engine/cache_engine.h"
|
||||||
#include "utils/utils_cache_line.h"
|
#include "utils/utils_cache_line.h"
|
||||||
|
#include "utils/utils_req.h"
|
||||||
#include "ocf_priv.h"
|
#include "ocf_priv.h"
|
||||||
#include "ocf_cache_priv.h"
|
#include "ocf_cache_priv.h"
|
||||||
|
|
||||||
@ -51,6 +52,17 @@ bool ocf_cache_is_device_attached(ocf_cache_t cache)
|
|||||||
return env_atomic_read(&(cache)->attached);
|
return env_atomic_read(&(cache)->attached);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ocf_cache_wait_for_io_finish(ocf_cache_t cache)
|
||||||
|
{
|
||||||
|
uint32_t req_active = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
req_active = ocf_req_get_allocated(cache);
|
||||||
|
if (req_active)
|
||||||
|
env_msleep(500);
|
||||||
|
} while (req_active);
|
||||||
|
}
|
||||||
|
|
||||||
ocf_cache_mode_t ocf_cache_get_mode(ocf_cache_t cache)
|
ocf_cache_mode_t ocf_cache_get_mode(ocf_cache_t cache)
|
||||||
{
|
{
|
||||||
OCF_CHECK_NULL(cache);
|
OCF_CHECK_NULL(cache);
|
||||||
|
@ -39,7 +39,7 @@ static void ocf_init_queue(struct ocf_queue *q)
|
|||||||
INIT_LIST_HEAD(&q->io_list);
|
INIT_LIST_HEAD(&q->io_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ocf_start_queues(struct ocf_cache *cache)
|
int ocf_start_queues(ocf_cache_t cache)
|
||||||
{
|
{
|
||||||
int id, result = 0;
|
int id, result = 0;
|
||||||
struct ocf_queue *q;
|
struct ocf_queue *q;
|
||||||
@ -63,17 +63,17 @@ int ocf_start_queues(struct ocf_cache *cache)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_stop_queues(struct ocf_cache *dev)
|
void ocf_stop_queues(ocf_cache_t cache)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct ocf_queue *curr;
|
struct ocf_queue *curr;
|
||||||
|
|
||||||
ocf_mngt_wait_for_io_finish(dev);
|
ocf_cache_wait_for_io_finish(cache);
|
||||||
|
|
||||||
/* Stop IO threads. */
|
/* Stop IO threads. */
|
||||||
for (i = 0 ; i < dev->io_queues_no; i++) {
|
for (i = 0 ; i < cache->io_queues_no; i++) {
|
||||||
curr = &dev->io_queues[i];
|
curr = &cache->io_queues[i];
|
||||||
ctx_queue_stop(dev->owner, curr);
|
ctx_queue_stop(cache->owner, curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user