Lines Matching refs:entry
267 struct zswap_entry *entry; in zswap_entry_cache_alloc() local
268 entry = kmem_cache_alloc(zswap_entry_cache, gfp); in zswap_entry_cache_alloc()
269 if (!entry) in zswap_entry_cache_alloc()
271 entry->refcount = 1; in zswap_entry_cache_alloc()
272 RB_CLEAR_NODE(&entry->rbnode); in zswap_entry_cache_alloc()
273 return entry; in zswap_entry_cache_alloc()
276 static void zswap_entry_cache_free(struct zswap_entry *entry) in zswap_entry_cache_free() argument
278 kmem_cache_free(zswap_entry_cache, entry); in zswap_entry_cache_free()
287 struct zswap_entry *entry; in zswap_rb_search() local
290 entry = rb_entry(node, struct zswap_entry, rbnode); in zswap_rb_search()
291 if (entry->offset > offset) in zswap_rb_search()
293 else if (entry->offset < offset) in zswap_rb_search()
296 return entry; in zswap_rb_search()
305 static int zswap_rb_insert(struct rb_root *root, struct zswap_entry *entry, in zswap_rb_insert() argument
314 if (myentry->offset > entry->offset) in zswap_rb_insert()
316 else if (myentry->offset < entry->offset) in zswap_rb_insert()
323 rb_link_node(&entry->rbnode, parent, link); in zswap_rb_insert()
324 rb_insert_color(&entry->rbnode, root); in zswap_rb_insert()
328 static void zswap_rb_erase(struct rb_root *root, struct zswap_entry *entry) in zswap_rb_erase() argument
330 if (!RB_EMPTY_NODE(&entry->rbnode)) { in zswap_rb_erase()
331 rb_erase(&entry->rbnode, root); in zswap_rb_erase()
332 RB_CLEAR_NODE(&entry->rbnode); in zswap_rb_erase()
340 static void zswap_free_entry(struct zswap_entry *entry) in zswap_free_entry() argument
342 if (!entry->length) in zswap_free_entry()
345 zpool_free(entry->pool->zpool, entry->handle); in zswap_free_entry()
346 zswap_pool_put(entry->pool); in zswap_free_entry()
348 zswap_entry_cache_free(entry); in zswap_free_entry()
354 static void zswap_entry_get(struct zswap_entry *entry) in zswap_entry_get() argument
356 entry->refcount++; in zswap_entry_get()
363 struct zswap_entry *entry) in zswap_entry_put() argument
365 int refcount = --entry->refcount; in zswap_entry_put()
369 zswap_rb_erase(&tree->rbroot, entry); in zswap_entry_put()
370 zswap_free_entry(entry); in zswap_entry_put()
378 struct zswap_entry *entry; in zswap_entry_find_get() local
380 entry = zswap_rb_search(root, offset); in zswap_entry_find_get()
381 if (entry) in zswap_entry_find_get()
382 zswap_entry_get(entry); in zswap_entry_find_get()
384 return entry; in zswap_entry_find_get()
845 static int zswap_get_swap_cache_page(swp_entry_t entry, in zswap_get_swap_cache_page() argument
850 *retpage = __read_swap_cache_async(entry, GFP_KERNEL, in zswap_get_swap_cache_page()
877 struct zswap_entry *entry; in zswap_writeback_entry() local
895 entry = zswap_entry_find_get(&tree->rbroot, offset); in zswap_writeback_entry()
896 if (!entry) { in zswap_writeback_entry()
903 BUG_ON(offset != entry->offset); in zswap_writeback_entry()
922 tfm = *get_cpu_ptr(entry->pool->tfm); in zswap_writeback_entry()
923 ret = crypto_comp_decompress(tfm, src, entry->length, in zswap_writeback_entry()
925 put_cpu_ptr(entry->pool->tfm); in zswap_writeback_entry()
944 zswap_entry_put(tree, entry); in zswap_writeback_entry()
953 if (entry == zswap_rb_search(&tree->rbroot, offset)) in zswap_writeback_entry()
954 zswap_entry_put(tree, entry); in zswap_writeback_entry()
968 zswap_entry_put(tree, entry); in zswap_writeback_entry()
1006 struct zswap_entry *entry, *dupentry; in zswap_frontswap_store() local
1049 entry = zswap_entry_cache_alloc(GFP_KERNEL); in zswap_frontswap_store()
1050 if (!entry) { in zswap_frontswap_store()
1060 entry->offset = offset; in zswap_frontswap_store()
1061 entry->length = 0; in zswap_frontswap_store()
1062 entry->value = value; in zswap_frontswap_store()
1070 entry->pool = zswap_pool_current_get(); in zswap_frontswap_store()
1071 if (!entry->pool) { in zswap_frontswap_store()
1078 tfm = *get_cpu_ptr(entry->pool->tfm); in zswap_frontswap_store()
1082 put_cpu_ptr(entry->pool->tfm); in zswap_frontswap_store()
1089 hlen = zpool_evictable(entry->pool->zpool) ? sizeof(zhdr) : 0; in zswap_frontswap_store()
1091 if (zpool_malloc_support_movable(entry->pool->zpool)) in zswap_frontswap_store()
1093 ret = zpool_malloc(entry->pool->zpool, hlen + dlen, gfp, &handle); in zswap_frontswap_store()
1102 buf = zpool_map_handle(entry->pool->zpool, handle, ZPOOL_MM_RW); in zswap_frontswap_store()
1105 zpool_unmap_handle(entry->pool->zpool, handle); in zswap_frontswap_store()
1109 entry->offset = offset; in zswap_frontswap_store()
1110 entry->handle = handle; in zswap_frontswap_store()
1111 entry->length = dlen; in zswap_frontswap_store()
1117 ret = zswap_rb_insert(&tree->rbroot, entry, &dupentry); in zswap_frontswap_store()
1135 zswap_pool_put(entry->pool); in zswap_frontswap_store()
1137 zswap_entry_cache_free(entry); in zswap_frontswap_store()
1150 struct zswap_entry *entry; in zswap_frontswap_load() local
1158 entry = zswap_entry_find_get(&tree->rbroot, offset); in zswap_frontswap_load()
1159 if (!entry) { in zswap_frontswap_load()
1166 if (!entry->length) { in zswap_frontswap_load()
1168 zswap_fill_page(dst, entry->value); in zswap_frontswap_load()
1175 src = zpool_map_handle(entry->pool->zpool, entry->handle, ZPOOL_MM_RO); in zswap_frontswap_load()
1176 if (zpool_evictable(entry->pool->zpool)) in zswap_frontswap_load()
1179 tfm = *get_cpu_ptr(entry->pool->tfm); in zswap_frontswap_load()
1180 ret = crypto_comp_decompress(tfm, src, entry->length, dst, &dlen); in zswap_frontswap_load()
1181 put_cpu_ptr(entry->pool->tfm); in zswap_frontswap_load()
1183 zpool_unmap_handle(entry->pool->zpool, entry->handle); in zswap_frontswap_load()
1188 zswap_entry_put(tree, entry); in zswap_frontswap_load()
1198 struct zswap_entry *entry; in zswap_frontswap_invalidate_page() local
1202 entry = zswap_rb_search(&tree->rbroot, offset); in zswap_frontswap_invalidate_page()
1203 if (!entry) { in zswap_frontswap_invalidate_page()
1210 zswap_rb_erase(&tree->rbroot, entry); in zswap_frontswap_invalidate_page()
1213 zswap_entry_put(tree, entry); in zswap_frontswap_invalidate_page()
1222 struct zswap_entry *entry, *n; in zswap_frontswap_invalidate_area() local
1229 rbtree_postorder_for_each_entry_safe(entry, n, &tree->rbroot, rbnode) in zswap_frontswap_invalidate_area()
1230 zswap_free_entry(entry); in zswap_frontswap_invalidate_area()