Lines Matching defs:tree
161 * The only case where lru_lock is not acquired while holding tree.lock is
163 * needs to be verified that it's still valid in the tree.
184 * rbnode - links the entry into red-black tree for the appropriate swap type
185 * swpentry - associated swap entry, the offset indexes into the red-black tree
216 * The tree lock in the zswap_tree struct protects a few things:
218 * - the refcount field of each entry in the tree
257 struct zswap_tree *tree);
407 /* caller must hold the tree lock */
413 /* caller must hold the tree lock
414 * remove from the tree and free it, if nobody reference the entry
416 static void zswap_entry_put(struct zswap_tree *tree,
428 /* caller must hold the tree lock */
621 * If the entry is still valid in the tree, drop the initial ref and remove it
622 * from the tree. This function must be called with an additional ref held,
625 static void zswap_invalidate_entry(struct zswap_tree *tree,
628 if (zswap_rb_erase(&tree->rbroot, entry))
629 zswap_entry_put(tree, entry);
635 struct zswap_tree *tree;
650 * until the entry is verified to still be alive in the tree.
653 tree = zswap_trees[swp_type(entry->swpentry)];
657 spin_lock(&tree->lock);
658 if (entry != zswap_rb_search(&tree->rbroot, swpoffset)) {
664 spin_unlock(&tree->lock);
666 ret = zswap_writeback_entry(entry, tree);
668 spin_lock(&tree->lock);
680 * took it out while we had the tree->lock released for IO.
682 zswap_invalidate_entry(tree, entry);
686 zswap_entry_put(tree, entry);
688 spin_unlock(&tree->lock);
1056 struct zswap_tree *tree)
1099 spin_lock(&tree->lock);
1100 if (zswap_rb_search(&tree->rbroot, swp_offset(entry->swpentry)) != entry) {
1101 spin_unlock(&tree->lock);
1108 spin_unlock(&tree->lock);
1199 struct zswap_tree *tree = zswap_trees[type];
1220 if (!tree)
1226 * the tree, and it might be written back overriding the new data.
1228 spin_lock(&tree->lock);
1229 dupentry = zswap_rb_search(&tree->rbroot, offset);
1232 zswap_invalidate_entry(tree, dupentry);
1234 spin_unlock(&tree->lock);
1348 /* Account before objcg ref is moved to tree */
1353 spin_lock(&tree->lock);
1360 while (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) {
1363 zswap_invalidate_entry(tree, dupentry);
1370 spin_unlock(&tree->lock);
1402 struct zswap_tree *tree = zswap_trees[type];
1414 spin_lock(&tree->lock);
1415 entry = zswap_entry_find_get(&tree->rbroot, offset);
1417 spin_unlock(&tree->lock);
1420 spin_unlock(&tree->lock);
1470 spin_lock(&tree->lock);
1472 zswap_invalidate_entry(tree, entry);
1479 zswap_entry_put(tree, entry);
1480 spin_unlock(&tree->lock);
1487 struct zswap_tree *tree = zswap_trees[type];
1491 spin_lock(&tree->lock);
1492 entry = zswap_rb_search(&tree->rbroot, offset);
1495 spin_unlock(&tree->lock);
1498 zswap_invalidate_entry(tree, entry);
1499 spin_unlock(&tree->lock);
1504 struct zswap_tree *tree;
1506 tree = kzalloc(sizeof(*tree), GFP_KERNEL);
1507 if (!tree) {
1512 tree->rbroot = RB_ROOT;
1513 spin_lock_init(&tree->lock);
1514 zswap_trees[type] = tree;
1519 struct zswap_tree *tree = zswap_trees[type];
1522 if (!tree)
1525 /* walk the tree and free everything */
1526 spin_lock(&tree->lock);
1527 rbtree_postorder_for_each_entry_safe(entry, n, &tree->rbroot, rbnode)
1529 tree->rbroot = RB_ROOT;
1530 spin_unlock(&tree->lock);
1531 kfree(tree);