/* check whether the xattr bucket is filled up with the same hash value. If we want to insert the xattr with the same hash, return -ENOSPC. If we want to insert a xattr with different hash value, go ahead and ocfs2_divide_xattr_bucket will handle this.  */
static int ocfs2_check_xattr_bucket_collision(struct inode *inode, struct ocfs2_xattr_bucket *bucket, const char *name)
/* check whether the xattr bucket is filled up with the same hash value. If we want to insert the xattr with the same hash, return -ENOSPC. If we want to insert a xattr with different hash value, go ahead and ocfs2_divide_xattr_bucket will handle this.  */
static int ocfs2_check_xattr_bucket_collision(struct inode *inode, struct ocfs2_xattr_bucket *bucket, const char *name)
{
	struct ocfs2_xattr_header *xh = bucket_xh(bucket);
	u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
	if (name_hash != le32_to_cpu(xh->xh_entries[0].xe_name_hash))
		return 0;
	if (xh->xh_entries[le16_to_cpu(xh->xh_count) - 1].xe_name_hash ==
	    xh->xh_entries[0].xe_name_hash) {
		mlog(ML_ERROR, "Too much hash collision in xattr bucket %llu, "
		     "hash = %u\n",
		     (unsigned long long)bucket_blkno(bucket),
		     le32_to_cpu(xh->xh_entries[0].xe_name_hash));
		return -ENOSPC;
	}
	return 0;
}