A utility for counting queues

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk 2022-09-26 14:03:08 +02:00
parent ef997b47fa
commit 21d5da83d9
3 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -25,6 +25,17 @@ ocf_volume_t ocf_cache_get_front_volume(ocf_cache_t cache)
return cache->device ? &cache->device->front_volume : NULL;
}
uint32_t ocf_cache_get_queue_count(ocf_cache_t cache)
{
ocf_queue_t queue = NULL;
uint32_t cnt = 0;
list_for_each_entry(queue, &cache->io_queues, list)
cnt++;
return cnt;
}
int ocf_cache_set_name(ocf_cache_t cache, const char *src, size_t src_size)
{
int result;

View File

@ -1,5 +1,5 @@
/*
* Copyright(c) 2012-2021 Intel Corporation
* Copyright(c) 2012-2022 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -19,6 +19,7 @@
#include "ocf_stats_priv.h"
#include "cleaning/cleaning.h"
#include "ocf_logger_priv.h"
#include "ocf_queue_priv.h"
#include "promotion/promotion.h"
#define DIRTY_FLUSHED 1
@ -175,6 +176,8 @@ static inline uint64_t ocf_get_cache_occupancy(ocf_cache_t cache)
return result;
}
uint32_t ocf_cache_get_queue_count(ocf_cache_t cache);
int ocf_cache_set_name(ocf_cache_t cache, const char *src, size_t src_size);
int ocf_cache_volume_type_init(ocf_ctx_t ctx);

View File

@ -57,8 +57,7 @@ int ocf_parallelize_create(ocf_parallelize_t *parallelize,
unsigned queue_count = 0;
int result, i;
list_for_each_entry(queue, &cache->io_queues, list)
queue_count++;
queue_count = ocf_cache_get_queue_count(cache);
if (shards_cnt == 0)
shards_cnt = queue_count;