/* If this ocfs2_xattr_header covers more than one hash value, find a place where the hash value changes. Try to find the most even split. The most common case is that all entries have different hash values, and the first check we make will find a place to split.  */
static int ocfs2_xattr_find_divide_pos(struct ocfs2_xattr_header *xh)
/* If this ocfs2_xattr_header covers more than one hash value, find a place where the hash value changes. Try to find the most even split. The most common case is that all entries have different hash values, and the first check we make will find a place to split.  */
static int ocfs2_xattr_find_divide_pos(struct ocfs2_xattr_header *xh)
{
	struct ocfs2_xattr_entry *entries = xh->xh_entries;
	int count = le16_to_cpu(xh->xh_count);
	int delta, middle = count / 2;
	for (delta = 0; delta < middle; delta++) {
		if (cmp_xe(&entries[middle - delta - 1],
			   &entries[middle - delta]))
			return middle - delta;
		if ((middle + delta + 1) == count)
			continue;
		if (cmp_xe(&entries[middle + delta],
			   &entries[middle + delta + 1]))
			return middle + delta + 1;
	}
	return count;
}