Lines Matching refs:leaf
3078 struct extent_buffer *leaf; in btrfs_search_slot_for_read() local
3091 leaf = p->nodes[0]; in btrfs_search_slot_for_read()
3094 if (p->slots[0] >= btrfs_header_nritems(leaf)) { in btrfs_search_slot_for_read()
3115 leaf = p->nodes[0]; in btrfs_search_slot_for_read()
3116 if (p->slots[0] == btrfs_header_nritems(leaf)) in btrfs_search_slot_for_read()
3654 noinline int btrfs_leaf_free_space(struct extent_buffer *leaf) in btrfs_leaf_free_space() argument
3656 struct btrfs_fs_info *fs_info = leaf->fs_info; in btrfs_leaf_free_space()
3657 int nritems = btrfs_header_nritems(leaf); in btrfs_leaf_free_space()
3660 ret = BTRFS_LEAF_DATA_SIZE(fs_info) - leaf_space_used(leaf, 0, nritems); in btrfs_leaf_free_space()
3666 leaf_space_used(leaf, 0, nritems), nritems); in btrfs_leaf_free_space()
4442 struct extent_buffer *leaf; in setup_leaf_for_split() local
4448 leaf = path->nodes[0]; in setup_leaf_for_split()
4449 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); in setup_leaf_for_split()
4454 if (btrfs_leaf_free_space(leaf) >= ins_len) in setup_leaf_for_split()
4457 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in setup_leaf_for_split()
4459 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
4461 extent_len = btrfs_file_extent_num_bytes(leaf, fi); in setup_leaf_for_split()
4475 leaf = path->nodes[0]; in setup_leaf_for_split()
4477 if (item_size != btrfs_item_size_nr(leaf, path->slots[0])) in setup_leaf_for_split()
4485 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
4487 if (extent_len != btrfs_file_extent_num_bytes(leaf, fi)) in setup_leaf_for_split()
4508 struct extent_buffer *leaf; in split_item() local
4518 leaf = path->nodes[0]; in split_item()
4519 BUG_ON(btrfs_leaf_free_space(leaf) < sizeof(struct btrfs_item)); in split_item()
4524 orig_offset = btrfs_item_offset(leaf, item); in split_item()
4525 item_size = btrfs_item_size(leaf, item); in split_item()
4531 read_extent_buffer(leaf, buf, btrfs_item_ptr_offset(leaf, in split_item()
4535 nritems = btrfs_header_nritems(leaf); in split_item()
4538 memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + 1), in split_item()
4544 btrfs_set_item_key(leaf, &disk_key, slot); in split_item()
4548 btrfs_set_item_offset(leaf, new_item, orig_offset); in split_item()
4549 btrfs_set_item_size(leaf, new_item, item_size - split_offset); in split_item()
4551 btrfs_set_item_offset(leaf, item, in split_item()
4553 btrfs_set_item_size(leaf, item, split_offset); in split_item()
4555 btrfs_set_header_nritems(leaf, nritems + 1); in split_item()
4558 write_extent_buffer(leaf, buf, in split_item()
4559 btrfs_item_ptr_offset(leaf, path->slots[0]), in split_item()
4563 write_extent_buffer(leaf, buf + split_offset, in split_item()
4564 btrfs_item_ptr_offset(leaf, slot), in split_item()
4566 btrfs_mark_buffer_dirty(leaf); in split_item()
4568 BUG_ON(btrfs_leaf_free_space(leaf) < 0); in split_item()
4617 struct extent_buffer *leaf; in btrfs_duplicate_item() local
4621 leaf = path->nodes[0]; in btrfs_duplicate_item()
4622 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in btrfs_duplicate_item()
4630 leaf = path->nodes[0]; in btrfs_duplicate_item()
4631 memcpy_extent_buffer(leaf, in btrfs_duplicate_item()
4632 btrfs_item_ptr_offset(leaf, path->slots[0]), in btrfs_duplicate_item()
4633 btrfs_item_ptr_offset(leaf, path->slots[0] - 1), in btrfs_duplicate_item()
4647 struct extent_buffer *leaf; in btrfs_truncate_item() local
4657 leaf = path->nodes[0]; in btrfs_truncate_item()
4660 old_size = btrfs_item_size_nr(leaf, slot); in btrfs_truncate_item()
4664 nritems = btrfs_header_nritems(leaf); in btrfs_truncate_item()
4665 data_end = leaf_data_end(leaf); in btrfs_truncate_item()
4667 old_data_start = btrfs_item_offset_nr(leaf, slot); in btrfs_truncate_item()
4678 btrfs_init_map_token(&token, leaf); in btrfs_truncate_item()
4689 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_truncate_item()
4696 btrfs_item_key(leaf, &disk_key, slot); in btrfs_truncate_item()
4702 fi = btrfs_item_ptr(leaf, slot, in btrfs_truncate_item()
4707 if (btrfs_file_extent_type(leaf, fi) == in btrfs_truncate_item()
4709 ptr = btrfs_item_ptr_offset(leaf, slot); in btrfs_truncate_item()
4710 memmove_extent_buffer(leaf, ptr, in btrfs_truncate_item()
4716 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_truncate_item()
4722 btrfs_set_item_key(leaf, &disk_key, slot); in btrfs_truncate_item()
4728 btrfs_set_item_size(leaf, item, new_size); in btrfs_truncate_item()
4729 btrfs_mark_buffer_dirty(leaf); in btrfs_truncate_item()
4731 if (btrfs_leaf_free_space(leaf) < 0) { in btrfs_truncate_item()
4732 btrfs_print_leaf(leaf); in btrfs_truncate_item()
4743 struct extent_buffer *leaf; in btrfs_extend_item() local
4752 leaf = path->nodes[0]; in btrfs_extend_item()
4754 nritems = btrfs_header_nritems(leaf); in btrfs_extend_item()
4755 data_end = leaf_data_end(leaf); in btrfs_extend_item()
4757 if (btrfs_leaf_free_space(leaf) < data_size) { in btrfs_extend_item()
4758 btrfs_print_leaf(leaf); in btrfs_extend_item()
4762 old_data = btrfs_item_end_nr(leaf, slot); in btrfs_extend_item()
4766 btrfs_print_leaf(leaf); in btrfs_extend_item()
4767 btrfs_crit(leaf->fs_info, "slot %d too large, nritems %d", in btrfs_extend_item()
4776 btrfs_init_map_token(&token, leaf); in btrfs_extend_item()
4786 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_extend_item()
4791 old_size = btrfs_item_size_nr(leaf, slot); in btrfs_extend_item()
4793 btrfs_set_item_size(leaf, item, old_size + data_size); in btrfs_extend_item()
4794 btrfs_mark_buffer_dirty(leaf); in btrfs_extend_item()
4796 if (btrfs_leaf_free_space(leaf) < 0) { in btrfs_extend_item()
4797 btrfs_print_leaf(leaf); in btrfs_extend_item()
4823 struct extent_buffer *leaf; in setup_items_for_insert() local
4839 leaf = path->nodes[0]; in setup_items_for_insert()
4842 nritems = btrfs_header_nritems(leaf); in setup_items_for_insert()
4843 data_end = leaf_data_end(leaf); in setup_items_for_insert()
4845 if (btrfs_leaf_free_space(leaf) < total_size) { in setup_items_for_insert()
4846 btrfs_print_leaf(leaf); in setup_items_for_insert()
4848 total_size, btrfs_leaf_free_space(leaf)); in setup_items_for_insert()
4852 btrfs_init_map_token(&token, leaf); in setup_items_for_insert()
4854 unsigned int old_data = btrfs_item_end_nr(leaf, slot); in setup_items_for_insert()
4857 btrfs_print_leaf(leaf); in setup_items_for_insert()
4876 memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + nr), in setup_items_for_insert()
4881 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in setup_items_for_insert()
4890 btrfs_set_item_key(leaf, &disk_key, slot + i); in setup_items_for_insert()
4897 btrfs_set_header_nritems(leaf, nritems + nr); in setup_items_for_insert()
4898 btrfs_mark_buffer_dirty(leaf); in setup_items_for_insert()
4900 if (btrfs_leaf_free_space(leaf) < 0) { in setup_items_for_insert()
4901 btrfs_print_leaf(leaf); in setup_items_for_insert()
4949 struct extent_buffer *leaf; in btrfs_insert_item() local
4957 leaf = path->nodes[0]; in btrfs_insert_item()
4958 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); in btrfs_insert_item()
4959 write_extent_buffer(leaf, data, ptr, data_size); in btrfs_insert_item()
4960 btrfs_mark_buffer_dirty(leaf); in btrfs_insert_item()
5025 struct extent_buffer *leaf) in btrfs_del_leaf() argument
5027 WARN_ON(btrfs_header_generation(leaf) != trans->transid); in btrfs_del_leaf()
5036 root_sub_used(root, leaf->len); in btrfs_del_leaf()
5038 atomic_inc(&leaf->refs); in btrfs_del_leaf()
5039 btrfs_free_tree_block(trans, root, leaf, 0, 1); in btrfs_del_leaf()
5040 free_extent_buffer_stale(leaf); in btrfs_del_leaf()
5050 struct extent_buffer *leaf; in btrfs_del_items() local
5059 leaf = path->nodes[0]; in btrfs_del_items()
5060 last_off = btrfs_item_offset_nr(leaf, slot + nr - 1); in btrfs_del_items()
5063 dsize += btrfs_item_size_nr(leaf, slot + i); in btrfs_del_items()
5065 nritems = btrfs_header_nritems(leaf); in btrfs_del_items()
5068 int data_end = leaf_data_end(leaf); in btrfs_del_items()
5071 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_del_items()
5076 btrfs_init_map_token(&token, leaf); in btrfs_del_items()
5085 memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot), in btrfs_del_items()
5090 btrfs_set_header_nritems(leaf, nritems - nr); in btrfs_del_items()
5095 if (leaf == root->node) { in btrfs_del_items()
5096 btrfs_set_header_level(leaf, 0); in btrfs_del_items()
5099 btrfs_clean_tree_block(leaf); in btrfs_del_items()
5100 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
5103 int used = leaf_space_used(leaf, 0, nritems); in btrfs_del_items()
5107 btrfs_item_key(leaf, &disk_key, 0); in btrfs_del_items()
5118 atomic_inc(&leaf->refs); in btrfs_del_items()
5126 if (path->nodes[0] == leaf && in btrfs_del_items()
5127 btrfs_header_nritems(leaf)) { in btrfs_del_items()
5134 if (btrfs_header_nritems(leaf) == 0) { in btrfs_del_items()
5136 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
5137 free_extent_buffer(leaf); in btrfs_del_items()
5145 if (path->nodes[0] == leaf) in btrfs_del_items()
5146 btrfs_mark_buffer_dirty(leaf); in btrfs_del_items()
5147 free_extent_buffer(leaf); in btrfs_del_items()
5150 btrfs_mark_buffer_dirty(leaf); in btrfs_del_items()
5631 struct extent_buffer *leaf; in btrfs_previous_item() local
5644 leaf = path->nodes[0]; in btrfs_previous_item()
5645 nritems = btrfs_header_nritems(leaf); in btrfs_previous_item()
5651 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_item()
5673 struct extent_buffer *leaf; in btrfs_previous_extent_item() local
5686 leaf = path->nodes[0]; in btrfs_previous_extent_item()
5687 nritems = btrfs_header_nritems(leaf); in btrfs_previous_extent_item()
5693 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_extent_item()