summaryrefslogtreecommitdiffstats
path: root/recipes-extended/ceph/ceph/0004-kv-rocksdb_cache-implement-methods-required-by-rocks.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-extended/ceph/ceph/0004-kv-rocksdb_cache-implement-methods-required-by-rocks.patch')
-rw-r--r--recipes-extended/ceph/ceph/0004-kv-rocksdb_cache-implement-methods-required-by-rocks.patch207
1 files changed, 0 insertions, 207 deletions
diff --git a/recipes-extended/ceph/ceph/0004-kv-rocksdb_cache-implement-methods-required-by-rocks.patch b/recipes-extended/ceph/ceph/0004-kv-rocksdb_cache-implement-methods-required-by-rocks.patch
deleted file mode 100644
index ee1e1416..00000000
--- a/recipes-extended/ceph/ceph/0004-kv-rocksdb_cache-implement-methods-required-by-rocks.patch
+++ /dev/null
@@ -1,207 +0,0 @@
1From 90696cb3652eb307c6aadde4af7d9198dc00c15f Mon Sep 17 00:00:00 2001
2From: Kefu Chai <kchai@redhat.com>
3Date: Tue, 17 Aug 2021 16:27:47 +0800
4Subject: [PATCH 4/6] kv/rocksdb_cache: implement methods required by rocksdb
5 v6.22.1
6
7rocksdb v6.22.1 added couple pure methods, so let's implement them.
8
9Signed-off-by: Kefu Chai <kchai@redhat.com>
10
11Upstream-Status: Backport [2c445598ce5280e85feb1f0e94d1940a444ee421]
12
13Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
14---
15 src/kv/rocksdb_cache/BinnedLRUCache.cc | 26 +++++++++++++++++++++++---
16 src/kv/rocksdb_cache/BinnedLRUCache.h | 14 +++++++++++---
17 src/kv/rocksdb_cache/ShardedCache.cc | 25 ++++++++++++++++++++++++-
18 src/kv/rocksdb_cache/ShardedCache.h | 20 ++++++++++++++++++--
19 4 files changed, 76 insertions(+), 9 deletions(-)
20
21diff --git a/src/kv/rocksdb_cache/BinnedLRUCache.cc b/src/kv/rocksdb_cache/BinnedLRUCache.cc
22index 4e5f4dd4..1e6ba7af 100644
23--- a/src/kv/rocksdb_cache/BinnedLRUCache.cc
24+++ b/src/kv/rocksdb_cache/BinnedLRUCache.cc
25@@ -150,13 +150,20 @@ void BinnedLRUCacheShard::EraseUnRefEntries() {
26 }
27 }
28
29-void BinnedLRUCacheShard::ApplyToAllCacheEntries(void (*callback)(void*, size_t),
30- bool thread_safe) {
31+void BinnedLRUCacheShard::ApplyToAllCacheEntries(
32+ const std::function<void(const rocksdb::Slice& key,
33+ void* value,
34+ size_t charge,
35+ DeleterFn)>& callback,
36+ bool thread_safe)
37+{
38 if (thread_safe) {
39 mutex_.lock();
40 }
41 table_.ApplyToAllCacheEntries(
42- [callback](BinnedLRUHandle* h) { callback(h->value, h->charge); });
43+ [callback](BinnedLRUHandle* h) {
44+ callback(h->key(), h->value, h->charge, h->deleter);
45+ });
46 if (thread_safe) {
47 mutex_.unlock();
48 }
49@@ -463,6 +470,12 @@ std::string BinnedLRUCacheShard::GetPrintableOptions() const {
50 return std::string(buffer);
51 }
52
53+DeleterFn BinnedLRUCacheShard::GetDeleter(rocksdb::Cache::Handle* h) const
54+{
55+ auto* handle = reinterpret_cast<BinnedLRUHandle*>(h);
56+ return handle->deleter;
57+}
58+
59 BinnedLRUCache::BinnedLRUCache(CephContext *c,
60 size_t capacity,
61 int num_shard_bits,
62@@ -518,6 +531,13 @@ void BinnedLRUCache::DisownData() {
63 #endif // !__SANITIZE_ADDRESS__
64 }
65
66+#if (ROCKSDB_MAJOR >= 6 && ROCKSDB_MINOR >= 22)
67+DeleterFn BinnedLRUCache::GetDeleter(Handle* handle) const
68+{
69+ return reinterpret_cast<const BinnedLRUHandle*>(handle)->deleter;
70+}
71+#endif
72+
73 size_t BinnedLRUCache::TEST_GetLRUSize() {
74 size_t lru_size_of_all_shards = 0;
75 for (int i = 0; i < num_shards_; i++) {
76diff --git a/src/kv/rocksdb_cache/BinnedLRUCache.h b/src/kv/rocksdb_cache/BinnedLRUCache.h
77index b0fb7148..ba0c2720 100644
78--- a/src/kv/rocksdb_cache/BinnedLRUCache.h
79+++ b/src/kv/rocksdb_cache/BinnedLRUCache.h
80@@ -205,13 +205,19 @@ class alignas(CACHE_LINE_SIZE) BinnedLRUCacheShard : public CacheShard {
81 virtual size_t GetUsage() const override;
82 virtual size_t GetPinnedUsage() const override;
83
84- virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
85- bool thread_safe) override;
86+ virtual void ApplyToAllCacheEntries(
87+ const std::function<void(const rocksdb::Slice& key,
88+ void* value,
89+ size_t charge,
90+ DeleterFn)>& callback,
91+ bool thread_safe) override;
92
93 virtual void EraseUnRefEntries() override;
94
95 virtual std::string GetPrintableOptions() const override;
96
97+ virtual DeleterFn GetDeleter(rocksdb::Cache::Handle* handle) const override;
98+
99 void TEST_GetLRUList(BinnedLRUHandle** lru, BinnedLRUHandle** lru_low_pri);
100
101 // Retrieves number of elements in LRU, for unit test purpose only
102@@ -303,7 +309,9 @@ class BinnedLRUCache : public ShardedCache {
103 virtual size_t GetCharge(Handle* handle) const override;
104 virtual uint32_t GetHash(Handle* handle) const override;
105 virtual void DisownData() override;
106-
107+#if (ROCKSDB_MAJOR >= 6 && ROCKSDB_MINOR >= 22)
108+ virtual DeleterFn GetDeleter(Handle* handle) const override;
109+#endif
110 // Retrieves number of elements in LRU, for unit test purpose only
111 size_t TEST_GetLRUSize();
112 // Sets the high pri pool ratio
113diff --git a/src/kv/rocksdb_cache/ShardedCache.cc b/src/kv/rocksdb_cache/ShardedCache.cc
114index ef3b3b98..6cbd89ad 100644
115--- a/src/kv/rocksdb_cache/ShardedCache.cc
116+++ b/src/kv/rocksdb_cache/ShardedCache.cc
117@@ -109,13 +109,36 @@ size_t ShardedCache::GetPinnedUsage() const {
118 return usage;
119 }
120
121+#if (ROCKSDB_MAJOR >= 6 && ROCKSDB_MINOR >= 22)
122+DeleterFn ShardedCache::GetDeleter(Handle* handle) const
123+{
124+ uint32_t hash = GetHash(handle);
125+ return GetShard(Shard(hash))->GetDeleter(handle);
126+}
127+
128+void ShardedCache::ApplyToAllEntries(
129+ const std::function<void(const rocksdb::Slice& key, void* value, size_t charge,
130+ DeleterFn deleter)>& callback,
131+ const ApplyToAllEntriesOptions& opts)
132+{
133+ int num_shards = 1 << num_shard_bits_;
134+ for (int s = 0; s < num_shards; s++) {
135+ GetShard(s)->ApplyToAllCacheEntries(callback, true /* thread_safe */);
136+ }
137+}
138+#else
139 void ShardedCache::ApplyToAllCacheEntries(void (*callback)(void*, size_t),
140 bool thread_safe) {
141 int num_shards = 1 << num_shard_bits_;
142 for (int s = 0; s < num_shards; s++) {
143- GetShard(s)->ApplyToAllCacheEntries(callback, thread_safe);
144+ GetShard(s)->ApplyToAllCacheEntries(
145+ [callback](const rocksdb::Slice&, void* value, size_t charge, DeleterFn) {
146+ callback(value, charge);
147+ },
148+ thread_safe);
149 }
150 }
151+#endif
152
153 void ShardedCache::EraseUnRefEntries() {
154 int num_shards = 1 << num_shard_bits_;
155diff --git a/src/kv/rocksdb_cache/ShardedCache.h b/src/kv/rocksdb_cache/ShardedCache.h
156index 674e5322..4d3ca302 100644
157--- a/src/kv/rocksdb_cache/ShardedCache.h
158+++ b/src/kv/rocksdb_cache/ShardedCache.h
159@@ -14,6 +14,7 @@
160 #include <string>
161 #include <mutex>
162
163+#include "rocksdb/version.h"
164 #include "rocksdb/cache.h"
165 #include "include/ceph_hash.h"
166 #include "common/PriorityCache.h"
167@@ -45,10 +46,15 @@ class CacheShard {
168 virtual void SetStrictCapacityLimit(bool strict_capacity_limit) = 0;
169 virtual size_t GetUsage() const = 0;
170 virtual size_t GetPinnedUsage() const = 0;
171- virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
172- bool thread_safe) = 0;
173+ virtual void ApplyToAllCacheEntries(
174+ const std::function<void(const rocksdb::Slice& key,
175+ void* value,
176+ size_t charge,
177+ DeleterFn)>& callback,
178+ bool thread_safe) = 0;
179 virtual void EraseUnRefEntries() = 0;
180 virtual std::string GetPrintableOptions() const { return ""; }
181+ virtual DeleterFn GetDeleter(rocksdb::Cache::Handle* handle) const = 0;
182 };
183
184 // Generic cache interface which shards cache by hash of keys. 2^num_shard_bits
185@@ -77,9 +83,19 @@ class ShardedCache : public rocksdb::Cache, public PriorityCache::PriCache {
186 virtual size_t GetUsage(rocksdb::Cache::Handle* handle) const override;
187 virtual size_t GetPinnedUsage() const override;
188 virtual size_t GetCharge(Handle* handle) const = 0;
189+#if (ROCKSDB_MAJOR >= 6 && ROCKSDB_MINOR >= 22)
190+ virtual DeleterFn GetDeleter(Handle* handle) const override;
191+#endif
192 virtual void DisownData() override = 0;
193+#if (ROCKSDB_MAJOR >= 6 && ROCKSDB_MINOR >= 22)
194+ virtual void ApplyToAllEntries(
195+ const std::function<void(const rocksdb::Slice& key, void* value, size_t charge,
196+ DeleterFn deleter)>& callback,
197+ const ApplyToAllEntriesOptions& opts) override;
198+#else
199 virtual void ApplyToAllCacheEntries(void (*callback)(void*, size_t),
200 bool thread_safe) override;
201+#endif
202 virtual void EraseUnRefEntries() override;
203 virtual std::string GetPrintableOptions() const override;
204 virtual CacheShard* GetShard(int shard) = 0;
205--
2062.33.0
207