/* how many bytes are required to store the items in a leaf. start and nr indicate which items in the leaf to check. This totals up the space used both by the item structs and the item data  */
static int leaf_space_used(struct extent_buffer *l, int start, int nr)
/* how many bytes are required to store the items in a leaf. start and nr indicate which items in the leaf to check. This totals up the space used both by the item structs and the item data  */
static int leaf_space_used(struct extent_buffer *l, int start, int nr)
{
	int data_len;
	int nritems = btrfs_header_nritems(l);
	int end = min(nritems, start + nr) - 1;
	if (!nr)
		return 0;
	data_len = btrfs_item_end_nr(l, start);
	data_len = data_len - btrfs_item_offset_nr(l, end);
	data_len += sizeof(struct btrfs_item) * nr;
	WARN_ON(data_len < 0);
	return data_len;
}