Lines Matching defs:btree

48 static void btree_node_to_freedlist(struct btree_cache *bc, struct btree *b)
56 static void btree_node_data_free(struct bch_fs *c, struct btree *b)
81 const struct btree *b = obj;
88 .head_offset = offsetof(struct btree, hash),
89 .key_offset = offsetof(struct btree, hash_val),
94 static int btree_node_data_alloc(struct bch_fs *c, struct btree *b, gfp_t gfp)
119 static struct btree *__btree_node_mem_alloc(struct bch_fs *c, gfp_t gfp)
121 struct btree *b;
123 b = kzalloc(sizeof(struct btree), gfp);
134 struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c)
137 struct btree *b;
157 void bch2_btree_node_hash_remove(struct btree_cache *bc, struct btree *b)
167 int __bch2_btree_node_hash_insert(struct btree_cache *bc, struct btree *b)
176 int bch2_btree_node_hash_insert(struct btree_cache *bc, struct btree *b,
194 static inline struct btree *btree_cache_find(struct btree_cache *bc,
203 * this version is for btree nodes that have already been freed (we're not
204 * reaping a real btree node)
206 static int __btree_node_reclaim(struct bch_fs *c, struct btree *b, bool flush)
231 /* XXX: waiting on IO with btree cache lock held */
263 * - unless btree verify mode is enabled, since it runs out of
289 static int btree_node_reclaim(struct bch_fs *c, struct btree *b)
294 static int btree_node_write_and_reclaim(struct bch_fs *c, struct btree *b)
304 struct btree *b, *t;
321 * It's _really_ critical that we don't free too many btree nodes - we
323 * guarantee that allocating memory for a new btree node can always
324 * succeed, so that inserting keys into the btree can always succeed and
333 * Leave a few nodes on the freeable list, so that a btree split
412 struct btree *b;
436 b = list_first_entry(&bc->live, struct btree, list);
450 b = list_first_entry(&bc->freed_nonpcpu, struct btree, list);
511 * We can only have one thread cannibalizing other cached btree nodes at a time,
514 * the btree, we need to release this lock if we have it held.
561 static struct btree *btree_node_cannibalize(struct bch_fs *c)
564 struct btree *b;
579 WARN_ONCE(1, "btree cache cannibalize failed\n");
584 struct btree *bch2_btree_node_mem_alloc(struct btree_trans *trans, bool pcpu_read_locks)
591 struct btree *b, *b2;
599 * We never free struct btree itself, just the memory that holds the on
672 /* Try to cannibalize another cached btree node: */
701 static noinline struct btree *bch2_btree_node_fill(struct btree_trans *trans,
711 struct btree *b;
714 int ret = bch2_fs_topology_error(c, "attempting to get btree node at level %u, >= max depth %u",
723 int ret = bch2_fs_topology_error(c, "attempting to get btree node with non-btree key %s", buf.buf);
732 int ret = bch2_fs_topology_error(c, "attempting to get btree node with too big key %s", buf.buf);
738 * Parent node must be locked, else we could read in a btree node that's
802 static noinline void btree_bad_header(struct bch_fs *c, struct btree *b)
810 "btree node header doesn't match ptr\n"
811 "btree %s level %u\n"
816 prt_printf(&buf, "\nheader: btree %s level %llu\n"
830 static inline void btree_check_header(struct bch_fs *c, struct btree *b)
841 static struct btree *__bch2_btree_node_get(struct btree_trans *trans, struct btree_path *path,
848 struct btree *b;
859 * else we could read in a btree node from disk that's been
866 /* We raced and found the btree node in the cache */
947 * bch2_btree_node_get - find a btree node in the cache and lock it, reading it
950 * @trans: btree transaction object
952 * @k: pointer to btree node (generally KEY_TYPE_btree_ptr_v2)
953 * @level: level of btree node being looked up (0 == leaf node)
955 * @trace_ip: ip of caller of btree iterator code (i.e. caller of bch2_btree_iter_peek())
957 * The btree node will have either a read or a write lock held, depending on
960 * Returns: btree node or ERR_PTR()
962 struct btree *bch2_btree_node_get(struct btree_trans *trans, struct btree_path *path,
968 struct btree *b;
1037 struct btree *bch2_btree_node_get_noiter(struct btree_trans *trans,
1045 struct btree *b;
1065 /* We raced and found the btree node in the cache */
1091 /* XXX: waiting on IO with btree locks held: */
1133 struct btree *b = btree_cache_find(bc, k);
1148 struct btree *b;
1156 /* not allowed to wait on io with btree locks held: */
1158 /* XXX we're called from btree_gc which will be holding other btree
1187 const char *bch2_btree_id_str(enum btree_id btree)
1189 return btree < BTREE_ID_NR ? __bch2_btree_ids[btree] : "(unknown)";
1192 void bch2_btree_pos_to_text(struct printbuf *out, struct bch_fs *c, const struct btree *b)
1201 void bch2_btree_node_to_text(struct printbuf *out, struct bch_fs *c, const struct btree *b)