From 21d5da83d975a1bdbf6e4f7312dfe0b5d52767d7 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Mon, 26 Sep 2022 14:03:08 +0200 Subject: [PATCH] A utility for counting queues Signed-off-by: Michal Mielewczyk --- src/ocf_cache.c | 13 ++++++++++++- src/ocf_cache_priv.h | 5 ++++- src/utils/utils_parallelize.c | 3 +-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ocf_cache.c b/src/ocf_cache.c index be11244..f0665ac 100644 --- a/src/ocf_cache.c +++ b/src/ocf_cache.c @@ -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; diff --git a/src/ocf_cache_priv.h b/src/ocf_cache_priv.h index 041bc6f..807483a 100644 --- a/src/ocf_cache_priv.h +++ b/src/ocf_cache_priv.h @@ -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); diff --git a/src/utils/utils_parallelize.c b/src/utils/utils_parallelize.c index 8265aa5..fc0ce6e 100644 --- a/src/utils/utils_parallelize.c +++ b/src/utils/utils_parallelize.c @@ -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;