/* helper to find a free sequence number in a given directory. This current code is very simple, later versions will do smarter things in the btree  */
int btrfs_set_inode_index(struct inode *dir, u64 *index)
/* helper to find a free sequence number in a given directory. This current code is very simple, later versions will do smarter things in the btree  */
int btrfs_set_inode_index(struct inode *dir, u64 *index)
{
	int ret = 0;
	if (BTRFS_I(dir)->index_cnt == (u64)-1) {
		ret = btrfs_set_inode_index_count(dir);
		if (ret)
			return ret;
	}
	*index = BTRFS_I(dir)->index_cnt;
	BTRFS_I(dir)->index_cnt++;
	return ret;
}