lru: Use common flush_data abstraction for cleaning
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com>
This commit is contained in:
parent
43cc487c40
commit
dd4add45e1
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright(c) 2012-2022 Intel Corporation
|
* Copyright(c) 2012-2022 Intel Corporation
|
||||||
|
* Copyright(c) 2023-2024 Huawei Technologies Co., Ltd.
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -570,30 +571,20 @@ static inline ocf_cache_line_t lru_iter_cleaning_next(struct ocf_lru_iter *iter)
|
|||||||
static void ocf_lru_clean_end(void *private_data, int error)
|
static void ocf_lru_clean_end(void *private_data, int error)
|
||||||
{
|
{
|
||||||
struct ocf_part_cleaning_ctx *ctx = private_data;
|
struct ocf_part_cleaning_ctx *ctx = private_data;
|
||||||
|
struct flush_data *entries = ctx->entries;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < OCF_EVICTION_CLEAN_SIZE; i++) {
|
for (i = 0; i < OCF_EVICTION_CLEAN_SIZE; i++) {
|
||||||
if (ctx->cline[i] != end_marker)
|
if (entries[i].cache_line == end_marker)
|
||||||
ocf_cache_line_unlock_rd(ctx->cache->device->concurrency
|
break;
|
||||||
.cache_line, ctx->cline[i]);
|
ocf_cache_line_unlock_rd(
|
||||||
|
ctx->cache->device->concurrency.cache_line,
|
||||||
|
entries[i].cache_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_refcnt_dec(&ctx->counter);
|
ocf_refcnt_dec(&ctx->counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ocf_lru_clean_get(ocf_cache_t cache, void *getter_context,
|
|
||||||
uint32_t idx, ocf_cache_line_t *line)
|
|
||||||
{
|
|
||||||
struct ocf_part_cleaning_ctx *ctx = getter_context;
|
|
||||||
|
|
||||||
if (ctx->cline[idx] == end_marker)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
*line = ctx->cline[idx];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ocf_lru_clean(ocf_cache_t cache, struct ocf_user_part *user_part,
|
void ocf_lru_clean(ocf_cache_t cache, struct ocf_user_part *user_part,
|
||||||
ocf_queue_t io_queue, uint32_t count)
|
ocf_queue_t io_queue, uint32_t count)
|
||||||
{
|
{
|
||||||
@ -606,14 +597,9 @@ void ocf_lru_clean(ocf_cache_t cache, struct ocf_user_part *user_part,
|
|||||||
.cmpl_context = ctx,
|
.cmpl_context = ctx,
|
||||||
.cmpl_fn = ocf_lru_clean_end,
|
.cmpl_fn = ocf_lru_clean_end,
|
||||||
|
|
||||||
.getter = ocf_lru_clean_get,
|
|
||||||
.getter_context = ctx,
|
|
||||||
|
|
||||||
.count = min(count, OCF_EVICTION_CLEAN_SIZE),
|
|
||||||
|
|
||||||
.io_queue = io_queue
|
.io_queue = io_queue
|
||||||
};
|
};
|
||||||
ocf_cache_line_t *cline = ctx->cline;
|
struct flush_data *entries = ctx->entries;
|
||||||
struct ocf_lru_iter iter;
|
struct ocf_lru_iter iter;
|
||||||
unsigned lru_idx;
|
unsigned lru_idx;
|
||||||
int cnt;
|
int cnt;
|
||||||
@ -643,21 +629,25 @@ void ocf_lru_clean(ocf_cache_t cache, struct ocf_user_part *user_part,
|
|||||||
OCF_METADATA_LRU_WR_LOCK_ALL();
|
OCF_METADATA_LRU_WR_LOCK_ALL();
|
||||||
|
|
||||||
lru_iter_cleaning_init(&iter, cache, &user_part->part, lru_idx);
|
lru_iter_cleaning_init(&iter, cache, &user_part->part, lru_idx);
|
||||||
i = 0;
|
count = min(count, OCF_EVICTION_CLEAN_SIZE);
|
||||||
while (i < OCF_EVICTION_CLEAN_SIZE) {
|
for (i = 0; i < count; i++) {
|
||||||
cline[i] = lru_iter_cleaning_next(&iter);
|
entries[i].cache_line = lru_iter_cleaning_next(&iter);
|
||||||
if (cline[i] == end_marker)
|
if (entries[i].cache_line == end_marker)
|
||||||
break;
|
break;
|
||||||
i++;
|
ocf_metadata_get_core_info(cache, entries[i].cache_line,
|
||||||
|
&entries[i].core_id, &entries[i].core_line);
|
||||||
}
|
}
|
||||||
while (i < OCF_EVICTION_CLEAN_SIZE)
|
|
||||||
cline[i++] = end_marker;
|
|
||||||
|
|
||||||
OCF_METADATA_LRU_WR_UNLOCK_ALL();
|
OCF_METADATA_LRU_WR_UNLOCK_ALL();
|
||||||
|
|
||||||
ocf_metadata_end_shared_access(&cache->metadata.lock, lock_idx);
|
ocf_metadata_end_shared_access(&cache->metadata.lock, lock_idx);
|
||||||
|
|
||||||
ocf_cleaner_fire(cache, &attribs);
|
if (i == 0) {
|
||||||
|
ocf_refcnt_dec(&ctx->counter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ocf_cleaner_do_flush_data_async(cache, entries, i, &attribs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ocf_lru_invalidate(ocf_cache_t cache, ocf_cache_line_t cline,
|
static void ocf_lru_invalidate(ocf_cache_t cache, ocf_cache_line_t cline,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#define __METADATA_PARTITION_STRUCTS_H__
|
#define __METADATA_PARTITION_STRUCTS_H__
|
||||||
|
|
||||||
#include "utils/utils_list.h"
|
#include "utils/utils_list.h"
|
||||||
|
#include "utils/utils_cleaner.h"
|
||||||
#include "cleaning/cleaning.h"
|
#include "cleaning/cleaning.h"
|
||||||
#include "ocf_space.h"
|
#include "ocf_space.h"
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ struct ocf_lru_iter
|
|||||||
struct ocf_part_cleaning_ctx {
|
struct ocf_part_cleaning_ctx {
|
||||||
ocf_cache_t cache;
|
ocf_cache_t cache;
|
||||||
struct ocf_refcnt counter;
|
struct ocf_refcnt counter;
|
||||||
ocf_cache_line_t cline[OCF_EVICTION_CLEAN_SIZE];
|
struct flush_data entries[OCF_EVICTION_CLEAN_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* common partition data for both user-deined partitions as
|
/* common partition data for both user-deined partitions as
|
||||||
|
Loading…
Reference in New Issue
Block a user