/* To insert an element, call xfs_mru_cache_insert() with the data store, the element's key and the client data pointer. This function returns 0 on success or ENOMEM if memory for the data element couldn't be allocated.  */
int xfs_mru_cache_insert(xfs_mru_cache_t *mru, unsigned long key, void *value)
/* To insert an element, call xfs_mru_cache_insert() with the data store, the element's key and the client data pointer. This function returns 0 on success or ENOMEM if memory for the data element couldn't be allocated.  */
int xfs_mru_cache_insert(xfs_mru_cache_t *mru, unsigned long key, void *value)
{
	xfs_mru_cache_elem_t *elem;
	ASSERT(mru && mru->lists);
	if (!mru || !mru->lists)
		return EINVAL;
	elem = kmem_zone_zalloc(xfs_mru_elem_zone, KM_SLEEP);
	if (!elem)
		return ENOMEM;
	if (radix_tree_preload(GFP_KERNEL)) {
		kmem_zone_free(xfs_mru_elem_zone, elem);
		return ENOMEM;
	}
	INIT_LIST_HEAD(&elem->list_node);
	elem->key = key;
	elem->value = value;
	spin_lock(&mru->lock);
	radix_tree_insert(&mru->store, key, elem);
	radix_tree_preload_end();
	_xfs_mru_cache_list_insert(mru, elem);
	spin_unlock(&mru->lock);
	return 0;
}