Lines Matching defs:tree

147  * rbnode - links the entry into red-black tree for the appropriate swap type
148 * offset - the swap offset for the entry. Index into the red-black tree.
178 * The tree lock in the zswap_tree struct protects a few things:
180 * - the refcount field of each entry in the tree
353 /* caller must hold the tree lock */
359 /* caller must hold the tree lock
360 * remove from the tree and free it, if nobody reference the entry
362 static void zswap_entry_put(struct zswap_tree *tree,
369 zswap_rb_erase(&tree->rbroot, entry);
374 /* caller must hold the tree lock */
875 struct zswap_tree *tree;
896 tree = zswap_trees[swp_type(swpentry)];
900 spin_lock(&tree->lock);
901 entry = zswap_entry_find_get(&tree->rbroot, offset);
904 spin_unlock(&tree->lock);
909 spin_unlock(&tree->lock);
955 spin_lock(&tree->lock);
957 zswap_entry_put(tree, entry);
961 * (1) refcount is 1(normal case), entry is valid and on the tree
962 * (2) refcount is 0, entry is freed and not on the tree
964 * search the tree and free the entry if find entry
966 if (entry == zswap_rb_search(&tree->rbroot, offset))
967 zswap_entry_put(tree, entry);
968 spin_unlock(&tree->lock);
980 spin_lock(&tree->lock);
981 zswap_entry_put(tree, entry);
982 spin_unlock(&tree->lock);
1022 struct zswap_tree *tree = zswap_trees[type];
1039 if (!zswap_enabled || !tree) {
1132 spin_lock(&tree->lock);
1134 ret = zswap_rb_insert(&tree->rbroot, entry, &dupentry);
1138 zswap_rb_erase(&tree->rbroot, dupentry);
1139 zswap_entry_put(tree, dupentry);
1142 spin_unlock(&tree->lock);
1166 struct zswap_tree *tree = zswap_trees[type];
1174 spin_lock(&tree->lock);
1175 entry = zswap_entry_find_get(&tree->rbroot, offset);
1178 spin_unlock(&tree->lock);
1181 spin_unlock(&tree->lock);
1225 spin_lock(&tree->lock);
1226 zswap_entry_put(tree, entry);
1227 spin_unlock(&tree->lock);
1235 struct zswap_tree *tree = zswap_trees[type];
1239 spin_lock(&tree->lock);
1240 entry = zswap_rb_search(&tree->rbroot, offset);
1243 spin_unlock(&tree->lock);
1248 zswap_rb_erase(&tree->rbroot, entry);
1251 zswap_entry_put(tree, entry);
1253 spin_unlock(&tree->lock);
1259 struct zswap_tree *tree = zswap_trees[type];
1262 if (!tree)
1265 /* walk the tree and free everything */
1266 spin_lock(&tree->lock);
1267 rbtree_postorder_for_each_entry_safe(entry, n, &tree->rbroot, rbnode)
1269 tree->rbroot = RB_ROOT;
1270 spin_unlock(&tree->lock);
1271 kfree(tree);
1277 struct zswap_tree *tree;
1279 tree = kzalloc(sizeof(*tree), GFP_KERNEL);
1280 if (!tree) {
1285 tree->rbroot = RB_ROOT;
1286 spin_lock_init(&tree->lock);
1287 zswap_trees[type] = tree;