Lines Matching refs:leaf
2047 struct extent_buffer *leaf; in btrfs_search_slot_for_read() local
2060 leaf = p->nodes[0]; in btrfs_search_slot_for_read()
2063 if (p->slots[0] >= btrfs_header_nritems(leaf)) { in btrfs_search_slot_for_read()
2084 leaf = p->nodes[0]; in btrfs_search_slot_for_read()
2085 if (p->slots[0] == btrfs_header_nritems(leaf)) in btrfs_search_slot_for_read()
2642 noinline int btrfs_leaf_free_space(struct extent_buffer *leaf) in btrfs_leaf_free_space() argument
2644 struct btrfs_fs_info *fs_info = leaf->fs_info; in btrfs_leaf_free_space()
2645 int nritems = btrfs_header_nritems(leaf); in btrfs_leaf_free_space()
2648 ret = BTRFS_LEAF_DATA_SIZE(fs_info) - leaf_space_used(leaf, 0, nritems); in btrfs_leaf_free_space()
2654 leaf_space_used(leaf, 0, nritems), nritems); in btrfs_leaf_free_space()
3426 struct extent_buffer *leaf; in setup_leaf_for_split() local
3432 leaf = path->nodes[0]; in setup_leaf_for_split()
3433 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); in setup_leaf_for_split()
3438 if (btrfs_leaf_free_space(leaf) >= ins_len) in setup_leaf_for_split()
3441 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in setup_leaf_for_split()
3443 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3445 extent_len = btrfs_file_extent_num_bytes(leaf, fi); in setup_leaf_for_split()
3459 leaf = path->nodes[0]; in setup_leaf_for_split()
3461 if (item_size != btrfs_item_size_nr(leaf, path->slots[0])) in setup_leaf_for_split()
3469 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3471 if (extent_len != btrfs_file_extent_num_bytes(leaf, fi)) in setup_leaf_for_split()
3491 struct extent_buffer *leaf; in split_item() local
3501 leaf = path->nodes[0]; in split_item()
3502 BUG_ON(btrfs_leaf_free_space(leaf) < sizeof(struct btrfs_item)); in split_item()
3505 orig_offset = btrfs_item_offset(leaf, item); in split_item()
3506 item_size = btrfs_item_size(leaf, item); in split_item()
3512 read_extent_buffer(leaf, buf, btrfs_item_ptr_offset(leaf, in split_item()
3516 nritems = btrfs_header_nritems(leaf); in split_item()
3519 memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + 1), in split_item()
3525 btrfs_set_item_key(leaf, &disk_key, slot); in split_item()
3529 btrfs_set_item_offset(leaf, new_item, orig_offset); in split_item()
3530 btrfs_set_item_size(leaf, new_item, item_size - split_offset); in split_item()
3532 btrfs_set_item_offset(leaf, item, in split_item()
3534 btrfs_set_item_size(leaf, item, split_offset); in split_item()
3536 btrfs_set_header_nritems(leaf, nritems + 1); in split_item()
3539 write_extent_buffer(leaf, buf, in split_item()
3540 btrfs_item_ptr_offset(leaf, path->slots[0]), in split_item()
3544 write_extent_buffer(leaf, buf + split_offset, in split_item()
3545 btrfs_item_ptr_offset(leaf, slot), in split_item()
3547 btrfs_mark_buffer_dirty(leaf); in split_item()
3549 BUG_ON(btrfs_leaf_free_space(leaf) < 0); in split_item()
3594 struct extent_buffer *leaf; in btrfs_truncate_item() local
3604 leaf = path->nodes[0]; in btrfs_truncate_item()
3607 old_size = btrfs_item_size_nr(leaf, slot); in btrfs_truncate_item()
3611 nritems = btrfs_header_nritems(leaf); in btrfs_truncate_item()
3612 data_end = leaf_data_end(leaf); in btrfs_truncate_item()
3614 old_data_start = btrfs_item_offset_nr(leaf, slot); in btrfs_truncate_item()
3625 btrfs_init_map_token(&token, leaf); in btrfs_truncate_item()
3636 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_truncate_item()
3643 btrfs_item_key(leaf, &disk_key, slot); in btrfs_truncate_item()
3649 fi = btrfs_item_ptr(leaf, slot, in btrfs_truncate_item()
3654 if (btrfs_file_extent_type(leaf, fi) == in btrfs_truncate_item()
3656 ptr = btrfs_item_ptr_offset(leaf, slot); in btrfs_truncate_item()
3657 memmove_extent_buffer(leaf, ptr, in btrfs_truncate_item()
3663 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_truncate_item()
3669 btrfs_set_item_key(leaf, &disk_key, slot); in btrfs_truncate_item()
3675 btrfs_set_item_size(leaf, item, new_size); in btrfs_truncate_item()
3676 btrfs_mark_buffer_dirty(leaf); in btrfs_truncate_item()
3678 if (btrfs_leaf_free_space(leaf) < 0) { in btrfs_truncate_item()
3679 btrfs_print_leaf(leaf); in btrfs_truncate_item()
3690 struct extent_buffer *leaf; in btrfs_extend_item() local
3699 leaf = path->nodes[0]; in btrfs_extend_item()
3701 nritems = btrfs_header_nritems(leaf); in btrfs_extend_item()
3702 data_end = leaf_data_end(leaf); in btrfs_extend_item()
3704 if (btrfs_leaf_free_space(leaf) < data_size) { in btrfs_extend_item()
3705 btrfs_print_leaf(leaf); in btrfs_extend_item()
3709 old_data = btrfs_item_end_nr(leaf, slot); in btrfs_extend_item()
3713 btrfs_print_leaf(leaf); in btrfs_extend_item()
3714 btrfs_crit(leaf->fs_info, "slot %d too large, nritems %d", in btrfs_extend_item()
3723 btrfs_init_map_token(&token, leaf); in btrfs_extend_item()
3733 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_extend_item()
3738 old_size = btrfs_item_size_nr(leaf, slot); in btrfs_extend_item()
3740 btrfs_set_item_size(leaf, item, old_size + data_size); in btrfs_extend_item()
3741 btrfs_mark_buffer_dirty(leaf); in btrfs_extend_item()
3743 if (btrfs_leaf_free_space(leaf) < 0) { in btrfs_extend_item()
3744 btrfs_print_leaf(leaf); in btrfs_extend_item()
3767 struct extent_buffer *leaf; in setup_items_for_insert() local
3783 leaf = path->nodes[0]; in setup_items_for_insert()
3786 nritems = btrfs_header_nritems(leaf); in setup_items_for_insert()
3787 data_end = leaf_data_end(leaf); in setup_items_for_insert()
3790 if (btrfs_leaf_free_space(leaf) < total_size) { in setup_items_for_insert()
3791 btrfs_print_leaf(leaf); in setup_items_for_insert()
3793 total_size, btrfs_leaf_free_space(leaf)); in setup_items_for_insert()
3797 btrfs_init_map_token(&token, leaf); in setup_items_for_insert()
3799 unsigned int old_data = btrfs_item_end_nr(leaf, slot); in setup_items_for_insert()
3802 btrfs_print_leaf(leaf); in setup_items_for_insert()
3821 memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + batch->nr), in setup_items_for_insert()
3826 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in setup_items_for_insert()
3836 btrfs_set_item_key(leaf, &disk_key, slot + i); in setup_items_for_insert()
3843 btrfs_set_header_nritems(leaf, nritems + batch->nr); in setup_items_for_insert()
3844 btrfs_mark_buffer_dirty(leaf); in setup_items_for_insert()
3846 if (btrfs_leaf_free_space(leaf) < 0) { in setup_items_for_insert()
3847 btrfs_print_leaf(leaf); in setup_items_for_insert()
3912 struct extent_buffer *leaf; in btrfs_insert_item() local
3920 leaf = path->nodes[0]; in btrfs_insert_item()
3921 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); in btrfs_insert_item()
3922 write_extent_buffer(leaf, data, ptr, data_size); in btrfs_insert_item()
3923 btrfs_mark_buffer_dirty(leaf); in btrfs_insert_item()
3942 struct extent_buffer *leaf; in btrfs_duplicate_item() local
3946 leaf = path->nodes[0]; in btrfs_duplicate_item()
3947 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in btrfs_duplicate_item()
3955 leaf = path->nodes[0]; in btrfs_duplicate_item()
3956 memcpy_extent_buffer(leaf, in btrfs_duplicate_item()
3957 btrfs_item_ptr_offset(leaf, path->slots[0]), in btrfs_duplicate_item()
3958 btrfs_item_ptr_offset(leaf, path->slots[0] - 1), in btrfs_duplicate_item()
4022 struct extent_buffer *leaf) in btrfs_del_leaf() argument
4024 WARN_ON(btrfs_header_generation(leaf) != trans->transid); in btrfs_del_leaf()
4033 root_sub_used(root, leaf->len); in btrfs_del_leaf()
4035 atomic_inc(&leaf->refs); in btrfs_del_leaf()
4036 btrfs_free_tree_block(trans, btrfs_root_id(root), leaf, 0, 1); in btrfs_del_leaf()
4037 free_extent_buffer_stale(leaf); in btrfs_del_leaf()
4047 struct extent_buffer *leaf; in btrfs_del_items() local
4056 leaf = path->nodes[0]; in btrfs_del_items()
4057 last_off = btrfs_item_offset_nr(leaf, slot + nr - 1); in btrfs_del_items()
4060 dsize += btrfs_item_size_nr(leaf, slot + i); in btrfs_del_items()
4062 nritems = btrfs_header_nritems(leaf); in btrfs_del_items()
4065 int data_end = leaf_data_end(leaf); in btrfs_del_items()
4068 memmove_extent_buffer(leaf, BTRFS_LEAF_DATA_OFFSET + in btrfs_del_items()
4073 btrfs_init_map_token(&token, leaf); in btrfs_del_items()
4082 memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot), in btrfs_del_items()
4087 btrfs_set_header_nritems(leaf, nritems - nr); in btrfs_del_items()
4092 if (leaf == root->node) { in btrfs_del_items()
4093 btrfs_set_header_level(leaf, 0); in btrfs_del_items()
4095 btrfs_clean_tree_block(leaf); in btrfs_del_items()
4096 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4099 int used = leaf_space_used(leaf, 0, nritems); in btrfs_del_items()
4103 btrfs_item_key(leaf, &disk_key, 0); in btrfs_del_items()
4114 atomic_inc(&leaf->refs); in btrfs_del_items()
4121 if (path->nodes[0] == leaf && in btrfs_del_items()
4122 btrfs_header_nritems(leaf)) { in btrfs_del_items()
4129 if (btrfs_header_nritems(leaf) == 0) { in btrfs_del_items()
4131 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4132 free_extent_buffer(leaf); in btrfs_del_items()
4140 if (path->nodes[0] == leaf) in btrfs_del_items()
4141 btrfs_mark_buffer_dirty(leaf); in btrfs_del_items()
4142 free_extent_buffer(leaf); in btrfs_del_items()
4145 btrfs_mark_buffer_dirty(leaf); in btrfs_del_items()
4568 struct extent_buffer *leaf; in btrfs_previous_item() local
4580 leaf = path->nodes[0]; in btrfs_previous_item()
4581 nritems = btrfs_header_nritems(leaf); in btrfs_previous_item()
4587 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_item()
4609 struct extent_buffer *leaf; in btrfs_previous_extent_item() local
4621 leaf = path->nodes[0]; in btrfs_previous_extent_item()
4622 nritems = btrfs_header_nritems(leaf); in btrfs_previous_extent_item()
4628 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_extent_item()