Lines Matching refs:entry
77 struct mb_cache_entry *entry, *dup; in mb_cache_entry_create() local
88 entry = kmem_cache_alloc(mb_entry_cache, mask); in mb_cache_entry_create()
89 if (!entry) in mb_cache_entry_create()
92 INIT_LIST_HEAD(&entry->e_list); in mb_cache_entry_create()
100 atomic_set(&entry->e_refcnt, 2); in mb_cache_entry_create()
101 entry->e_key = key; in mb_cache_entry_create()
102 entry->e_value = value; in mb_cache_entry_create()
103 entry->e_flags = 0; in mb_cache_entry_create()
105 set_bit(MBE_REUSABLE_B, &entry->e_flags); in mb_cache_entry_create()
111 kmem_cache_free(mb_entry_cache, entry); in mb_cache_entry_create()
115 hlist_bl_add_head(&entry->e_hash_list, head); in mb_cache_entry_create()
118 list_add_tail(&entry->e_list, &cache->c_list); in mb_cache_entry_create()
121 mb_cache_entry_put(cache, entry); in mb_cache_entry_create()
127 void __mb_cache_entry_free(struct mb_cache *cache, struct mb_cache_entry *entry) in __mb_cache_entry_free() argument
131 head = mb_cache_entry_head(cache, entry->e_key); in __mb_cache_entry_free()
133 hlist_bl_del(&entry->e_hash_list); in __mb_cache_entry_free()
135 kmem_cache_free(mb_entry_cache, entry); in __mb_cache_entry_free()
146 void mb_cache_entry_wait_unused(struct mb_cache_entry *entry) in mb_cache_entry_wait_unused() argument
148 wait_var_event(&entry->e_refcnt, atomic_read(&entry->e_refcnt) <= 2); in mb_cache_entry_wait_unused()
153 struct mb_cache_entry *entry, in __entry_find() argument
156 struct mb_cache_entry *old_entry = entry; in __entry_find()
162 if (entry && !hlist_bl_unhashed(&entry->e_hash_list)) in __entry_find()
163 node = entry->e_hash_list.next; in __entry_find()
167 entry = hlist_bl_entry(node, struct mb_cache_entry, in __entry_find()
169 if (entry->e_key == key && in __entry_find()
170 test_bit(MBE_REUSABLE_B, &entry->e_flags) && in __entry_find()
171 atomic_inc_not_zero(&entry->e_refcnt)) in __entry_find()
175 entry = NULL; in __entry_find()
181 return entry; in __entry_find()
210 struct mb_cache_entry *entry) in mb_cache_entry_find_next() argument
212 return __entry_find(cache, entry, entry->e_key); in mb_cache_entry_find_next()
227 struct mb_cache_entry *entry; in mb_cache_entry_get() local
231 hlist_bl_for_each_entry(entry, node, head, e_hash_list) { in mb_cache_entry_get()
232 if (entry->e_key == key && entry->e_value == value && in mb_cache_entry_get()
233 atomic_inc_not_zero(&entry->e_refcnt)) in mb_cache_entry_get()
236 entry = NULL; in mb_cache_entry_get()
239 return entry; in mb_cache_entry_get()
257 struct mb_cache_entry *entry; in mb_cache_entry_delete_or_get() local
259 entry = mb_cache_entry_get(cache, key, value); in mb_cache_entry_delete_or_get()
260 if (!entry) in mb_cache_entry_delete_or_get()
267 if (atomic_cmpxchg(&entry->e_refcnt, 2, 0) != 2) in mb_cache_entry_delete_or_get()
268 return entry; in mb_cache_entry_delete_or_get()
271 if (!list_empty(&entry->e_list)) in mb_cache_entry_delete_or_get()
272 list_del_init(&entry->e_list); in mb_cache_entry_delete_or_get()
275 __mb_cache_entry_free(cache, entry); in mb_cache_entry_delete_or_get()
287 struct mb_cache_entry *entry) in mb_cache_entry_touch() argument
289 set_bit(MBE_REFERENCED_B, &entry->e_flags); in mb_cache_entry_touch()
306 struct mb_cache_entry *entry; in mb_cache_shrink() local
311 entry = list_first_entry(&cache->c_list, in mb_cache_shrink()
314 if (test_bit(MBE_REFERENCED_B, &entry->e_flags) || in mb_cache_shrink()
315 atomic_cmpxchg(&entry->e_refcnt, 1, 0) != 1) { in mb_cache_shrink()
316 clear_bit(MBE_REFERENCED_B, &entry->e_flags); in mb_cache_shrink()
317 list_move_tail(&entry->e_list, &cache->c_list); in mb_cache_shrink()
320 list_del_init(&entry->e_list); in mb_cache_shrink()
323 __mb_cache_entry_free(cache, entry); in mb_cache_shrink()
407 struct mb_cache_entry *entry, *next; in mb_cache_destroy() local
415 list_for_each_entry_safe(entry, next, &cache->c_list, e_list) { in mb_cache_destroy()
416 list_del(&entry->e_list); in mb_cache_destroy()
417 WARN_ON(atomic_read(&entry->e_refcnt) != 1); in mb_cache_destroy()
418 mb_cache_entry_put(cache, entry); in mb_cache_destroy()