10
10
/*
11
11
* Mbcache is a simple key-value store. Keys need not be unique, however
12
12
* key-value pairs are expected to be unique (we use this fact in
13
- * mb_cache_entry_delete_block ()).
13
+ * mb_cache_entry_delete ()).
14
14
*
15
15
* Ext2 and ext4 use this cache for deduplication of extended attribute blocks.
16
16
* They use hash of a block contents as a key and block number as a value.
@@ -62,15 +62,15 @@ static inline struct hlist_bl_head *mb_cache_entry_head(struct mb_cache *cache,
62
62
* @cache - cache where the entry should be created
63
63
* @mask - gfp mask with which the entry should be allocated
64
64
* @key - key of the entry
65
- * @block - block that contains data
66
- * @reusable - is the block reusable by other inodes ?
65
+ * @value - value of the entry
66
+ * @reusable - is the entry reusable by others ?
67
67
*
68
- * Creates entry in @cache with key @key and records that data is stored in
69
- * block @block. The function returns -EBUSY if entry with the same key
70
- * and for the same block already exists in cache. Otherwise 0 is returned.
68
+ * Creates entry in @cache with key @key and value @value. The function returns
69
+ * -EBUSY if entry with the same key and value already exists in cache.
70
+ * Otherwise 0 is returned.
71
71
*/
72
72
int mb_cache_entry_create (struct mb_cache * cache , gfp_t mask , u32 key ,
73
- sector_t block , bool reusable )
73
+ u64 value , bool reusable )
74
74
{
75
75
struct mb_cache_entry * entry , * dup ;
76
76
struct hlist_bl_node * dup_node ;
@@ -91,12 +91,12 @@ int mb_cache_entry_create(struct mb_cache *cache, gfp_t mask, u32 key,
91
91
/* One ref for hash, one ref returned */
92
92
atomic_set (& entry -> e_refcnt , 1 );
93
93
entry -> e_key = key ;
94
- entry -> e_block = block ;
94
+ entry -> e_value = value ;
95
95
entry -> e_reusable = reusable ;
96
96
head = mb_cache_entry_head (cache , key );
97
97
hlist_bl_lock (head );
98
98
hlist_bl_for_each_entry (dup , dup_node , head , e_hash_list ) {
99
- if (dup -> e_key == key && dup -> e_block == block ) {
99
+ if (dup -> e_key == key && dup -> e_value == value ) {
100
100
hlist_bl_unlock (head );
101
101
kmem_cache_free (mb_entry_cache , entry );
102
102
return - EBUSY ;
@@ -187,13 +187,13 @@ struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache *cache,
187
187
EXPORT_SYMBOL (mb_cache_entry_find_next );
188
188
189
189
/*
190
- * mb_cache_entry_get - get a cache entry by block number (and key)
190
+ * mb_cache_entry_get - get a cache entry by value (and key)
191
191
* @cache - cache we work with
192
- * @key - key of block number @block
193
- * @block - block number
192
+ * @key - key
193
+ * @value - value
194
194
*/
195
195
struct mb_cache_entry * mb_cache_entry_get (struct mb_cache * cache , u32 key ,
196
- sector_t block )
196
+ u64 value )
197
197
{
198
198
struct hlist_bl_node * node ;
199
199
struct hlist_bl_head * head ;
@@ -202,7 +202,7 @@ struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *cache, u32 key,
202
202
head = mb_cache_entry_head (cache , key );
203
203
hlist_bl_lock (head );
204
204
hlist_bl_for_each_entry (entry , node , head , e_hash_list ) {
205
- if (entry -> e_key == key && entry -> e_block == block ) {
205
+ if (entry -> e_key == key && entry -> e_value == value ) {
206
206
atomic_inc (& entry -> e_refcnt );
207
207
goto out ;
208
208
}
@@ -214,15 +214,14 @@ struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *cache, u32 key,
214
214
}
215
215
EXPORT_SYMBOL (mb_cache_entry_get );
216
216
217
- /* mb_cache_entry_delete_block - remove information about block from cache
217
+ /* mb_cache_entry_delete - remove a cache entry
218
218
* @cache - cache we work with
219
- * @key - key of block @block
220
- * @block - block number
219
+ * @key - key
220
+ * @value - value
221
221
*
222
- * Remove entry from cache @cache with key @key with data stored in @block .
222
+ * Remove entry from cache @cache with key @key and value @value .
223
223
*/
224
- void mb_cache_entry_delete_block (struct mb_cache * cache , u32 key ,
225
- sector_t block )
224
+ void mb_cache_entry_delete (struct mb_cache * cache , u32 key , u64 value )
226
225
{
227
226
struct hlist_bl_node * node ;
228
227
struct hlist_bl_head * head ;
@@ -231,7 +230,7 @@ void mb_cache_entry_delete_block(struct mb_cache *cache, u32 key,
231
230
head = mb_cache_entry_head (cache , key );
232
231
hlist_bl_lock (head );
233
232
hlist_bl_for_each_entry (entry , node , head , e_hash_list ) {
234
- if (entry -> e_key == key && entry -> e_block == block ) {
233
+ if (entry -> e_key == key && entry -> e_value == value ) {
235
234
/* We keep hash list reference to keep entry alive */
236
235
hlist_bl_del_init (& entry -> e_hash_list );
237
236
hlist_bl_unlock (head );
@@ -248,7 +247,7 @@ void mb_cache_entry_delete_block(struct mb_cache *cache, u32 key,
248
247
}
249
248
hlist_bl_unlock (head );
250
249
}
251
- EXPORT_SYMBOL (mb_cache_entry_delete_block );
250
+ EXPORT_SYMBOL (mb_cache_entry_delete );
252
251
253
252
/* mb_cache_entry_touch - cache entry got used
254
253
* @cache - cache the entry belongs to
0 commit comments