]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/ocf/src/eviction/eviction.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / ocf / src / eviction / eviction.h
1 /*
2 * Copyright(c) 2012-2018 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause-Clear
4 */
5
6 #ifndef __LAYER_EVICTION_POLICY_H__
7 #define __LAYER_EVICTION_POLICY_H__
8
9 #include "ocf/ocf.h"
10 #include "lru.h"
11 #include "lru_structs.h"
12 #include "../ocf_request.h"
13
14 #define OCF_TO_EVICTION_MIN 128UL
15 #define OCF_PENDING_EVICTION_LIMIT 512UL
16
17 struct eviction_policy {
18 union {
19 struct lru_eviction_policy lru;
20 } policy;
21 };
22
23 /* Eviction policy metadata per cache line */
24 union eviction_policy_meta {
25 struct lru_eviction_policy_meta lru;
26 } __attribute__((packed));
27
28 /* the caller must hold the metadata lock for all operations
29 *
30 * For range operations the caller can:
31 * set core_id to -1 to purge the whole cache device
32 * set core_id to -2 to purge the whole cache partition
33 */
34 struct eviction_policy_ops {
35 void (*init_cline)(ocf_cache_t cache,
36 ocf_cache_line_t cline);
37 void (*rm_cline)(ocf_cache_t cache,
38 ocf_cache_line_t cline);
39 bool (*can_evict)(ocf_cache_t cache);
40 uint32_t (*req_clines)(ocf_cache_t cache,
41 ocf_queue_t io_queue, ocf_part_id_t part_id,
42 uint32_t cline_no, ocf_core_id_t core_id);
43 void (*hot_cline)(ocf_cache_t cache,
44 ocf_cache_line_t cline);
45 void (*init_evp)(ocf_cache_t cache,
46 ocf_part_id_t part_id);
47 void (*dirty_cline)(ocf_cache_t cache,
48 ocf_part_id_t part_id,
49 uint32_t cline_no);
50 void (*clean_cline)(ocf_cache_t cache,
51 ocf_part_id_t part_id,
52 uint32_t cline_no);
53 const char *name;
54 };
55
56 extern struct eviction_policy_ops evict_policy_ops[ocf_eviction_max];
57
58 /*
59 * Deallocates space from low priority partitions.
60 *
61 * Returns -1 on error
62 * or the destination partition ID for the free buffers
63 * (it matches label and is part of the object (#core_id) IO group)
64 */
65 int space_managment_evict_do(ocf_cache_t cache,
66 struct ocf_request *req, uint32_t evict_cline_no);
67
68 int space_management_free(ocf_cache_t cache, uint32_t count);
69
70 #endif