Lines Matching refs:entry
250 struct zswap_entry *entry; in zswap_entry_cache_alloc() local
251 entry = kmem_cache_alloc(zswap_entry_cache, gfp); in zswap_entry_cache_alloc()
252 if (!entry) in zswap_entry_cache_alloc()
254 entry->refcount = 1; in zswap_entry_cache_alloc()
255 RB_CLEAR_NODE(&entry->rbnode); in zswap_entry_cache_alloc()
256 return entry; in zswap_entry_cache_alloc()
259 static void zswap_entry_cache_free(struct zswap_entry *entry) in zswap_entry_cache_free() argument
261 kmem_cache_free(zswap_entry_cache, entry); in zswap_entry_cache_free()
270 struct zswap_entry *entry; in zswap_rb_search() local
273 entry = rb_entry(node, struct zswap_entry, rbnode); in zswap_rb_search()
274 if (entry->offset > offset) in zswap_rb_search()
276 else if (entry->offset < offset) in zswap_rb_search()
279 return entry; in zswap_rb_search()
288 static int zswap_rb_insert(struct rb_root *root, struct zswap_entry *entry, in zswap_rb_insert() argument
297 if (myentry->offset > entry->offset) in zswap_rb_insert()
299 else if (myentry->offset < entry->offset) in zswap_rb_insert()
306 rb_link_node(&entry->rbnode, parent, link); in zswap_rb_insert()
307 rb_insert_color(&entry->rbnode, root); in zswap_rb_insert()
311 static void zswap_rb_erase(struct rb_root *root, struct zswap_entry *entry) in zswap_rb_erase() argument
313 if (!RB_EMPTY_NODE(&entry->rbnode)) { in zswap_rb_erase()
314 rb_erase(&entry->rbnode, root); in zswap_rb_erase()
315 RB_CLEAR_NODE(&entry->rbnode); in zswap_rb_erase()
323 static void zswap_free_entry(struct zswap_entry *entry) in zswap_free_entry() argument
325 if (!entry->length) in zswap_free_entry()
328 zpool_free(entry->pool->zpool, entry->handle); in zswap_free_entry()
329 zswap_pool_put(entry->pool); in zswap_free_entry()
331 zswap_entry_cache_free(entry); in zswap_free_entry()
337 static void zswap_entry_get(struct zswap_entry *entry) in zswap_entry_get() argument
339 entry->refcount++; in zswap_entry_get()
346 struct zswap_entry *entry) in zswap_entry_put() argument
348 int refcount = --entry->refcount; in zswap_entry_put()
352 zswap_rb_erase(&tree->rbroot, entry); in zswap_entry_put()
353 zswap_free_entry(entry); in zswap_entry_put()
361 struct zswap_entry *entry; in zswap_entry_find_get() local
363 entry = zswap_rb_search(root, offset); in zswap_entry_find_get()
364 if (entry) in zswap_entry_find_get()
365 zswap_entry_get(entry); in zswap_entry_find_get()
367 return entry; in zswap_entry_find_get()
814 static int zswap_get_swap_cache_page(swp_entry_t entry, in zswap_get_swap_cache_page() argument
819 *retpage = __read_swap_cache_async(entry, GFP_KERNEL, in zswap_get_swap_cache_page()
846 struct zswap_entry *entry; in zswap_writeback_entry() local
864 entry = zswap_entry_find_get(&tree->rbroot, offset); in zswap_writeback_entry()
865 if (!entry) { in zswap_writeback_entry()
872 BUG_ON(offset != entry->offset); in zswap_writeback_entry()
891 tfm = *get_cpu_ptr(entry->pool->tfm); in zswap_writeback_entry()
892 ret = crypto_comp_decompress(tfm, src, entry->length, in zswap_writeback_entry()
894 put_cpu_ptr(entry->pool->tfm); in zswap_writeback_entry()
913 zswap_entry_put(tree, entry); in zswap_writeback_entry()
922 if (entry == zswap_rb_search(&tree->rbroot, offset)) in zswap_writeback_entry()
923 zswap_entry_put(tree, entry); in zswap_writeback_entry()
937 zswap_entry_put(tree, entry); in zswap_writeback_entry()
991 struct zswap_entry *entry, *dupentry; in zswap_frontswap_store() local
1032 entry = zswap_entry_cache_alloc(GFP_KERNEL); in zswap_frontswap_store()
1033 if (!entry) { in zswap_frontswap_store()
1043 entry->offset = offset; in zswap_frontswap_store()
1044 entry->length = 0; in zswap_frontswap_store()
1045 entry->value = value; in zswap_frontswap_store()
1053 entry->pool = zswap_pool_current_get(); in zswap_frontswap_store()
1054 if (!entry->pool) { in zswap_frontswap_store()
1061 tfm = *get_cpu_ptr(entry->pool->tfm); in zswap_frontswap_store()
1065 put_cpu_ptr(entry->pool->tfm); in zswap_frontswap_store()
1072 hlen = zpool_evictable(entry->pool->zpool) ? sizeof(zhdr) : 0; in zswap_frontswap_store()
1074 if (zpool_malloc_support_movable(entry->pool->zpool)) in zswap_frontswap_store()
1076 ret = zpool_malloc(entry->pool->zpool, hlen + dlen, gfp, &handle); in zswap_frontswap_store()
1085 buf = zpool_map_handle(entry->pool->zpool, handle, ZPOOL_MM_RW); in zswap_frontswap_store()
1088 zpool_unmap_handle(entry->pool->zpool, handle); in zswap_frontswap_store()
1092 entry->offset = offset; in zswap_frontswap_store()
1093 entry->handle = handle; in zswap_frontswap_store()
1094 entry->length = dlen; in zswap_frontswap_store()
1100 ret = zswap_rb_insert(&tree->rbroot, entry, &dupentry); in zswap_frontswap_store()
1118 zswap_pool_put(entry->pool); in zswap_frontswap_store()
1120 zswap_entry_cache_free(entry); in zswap_frontswap_store()
1133 struct zswap_entry *entry; in zswap_frontswap_load() local
1141 entry = zswap_entry_find_get(&tree->rbroot, offset); in zswap_frontswap_load()
1142 if (!entry) { in zswap_frontswap_load()
1149 if (!entry->length) { in zswap_frontswap_load()
1151 zswap_fill_page(dst, entry->value); in zswap_frontswap_load()
1158 src = zpool_map_handle(entry->pool->zpool, entry->handle, ZPOOL_MM_RO); in zswap_frontswap_load()
1159 if (zpool_evictable(entry->pool->zpool)) in zswap_frontswap_load()
1162 tfm = *get_cpu_ptr(entry->pool->tfm); in zswap_frontswap_load()
1163 ret = crypto_comp_decompress(tfm, src, entry->length, dst, &dlen); in zswap_frontswap_load()
1164 put_cpu_ptr(entry->pool->tfm); in zswap_frontswap_load()
1166 zpool_unmap_handle(entry->pool->zpool, entry->handle); in zswap_frontswap_load()
1171 zswap_entry_put(tree, entry); in zswap_frontswap_load()
1181 struct zswap_entry *entry; in zswap_frontswap_invalidate_page() local
1185 entry = zswap_rb_search(&tree->rbroot, offset); in zswap_frontswap_invalidate_page()
1186 if (!entry) { in zswap_frontswap_invalidate_page()
1193 zswap_rb_erase(&tree->rbroot, entry); in zswap_frontswap_invalidate_page()
1196 zswap_entry_put(tree, entry); in zswap_frontswap_invalidate_page()
1205 struct zswap_entry *entry, *n; in zswap_frontswap_invalidate_area() local
1212 rbtree_postorder_for_each_entry_safe(entry, n, &tree->rbroot, rbnode) in zswap_frontswap_invalidate_area()
1213 zswap_free_entry(entry); in zswap_frontswap_invalidate_area()