/* Find the available free space for EAs. This also returns the total number of bytes used by EA entries.  */
static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last, size_t *min_offs, void *base, int *total)
/* Find the available free space for EAs. This also returns the total number of bytes used by EA entries.  */
static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last, size_t *min_offs, void *base, int *total)
{
	for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
		*total += EXT4_XATTR_LEN(last->e_name_len);
		if (!last->e_value_block && last->e_value_size) {
			size_t offs = le16_to_cpu(last->e_value_offs);
			if (offs < *min_offs)
				*min_offs = offs;
		}
	}
	return (*min_offs - ((void *)last - base) - sizeof(__u32));
}