xfs: handle duplicate entries in xfs_mru_cache_insert
The radix tree code can detect and reject duplicate keys at insert time. Make xfs_mru_cache_insert handle this case so that future changes to the filestream allocator can take advantage of this. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
parent
c977eb1065
commit
ce695c6551
|
@ -443,6 +443,7 @@ xfs_mru_cache_insert(
|
||||||
void *value)
|
void *value)
|
||||||
{
|
{
|
||||||
xfs_mru_cache_elem_t *elem;
|
xfs_mru_cache_elem_t *elem;
|
||||||
|
int error;
|
||||||
|
|
||||||
ASSERT(mru && mru->lists);
|
ASSERT(mru && mru->lists);
|
||||||
if (!mru || !mru->lists)
|
if (!mru || !mru->lists)
|
||||||
|
@ -453,8 +454,8 @@ xfs_mru_cache_insert(
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
if (radix_tree_preload(GFP_KERNEL)) {
|
if (radix_tree_preload(GFP_KERNEL)) {
|
||||||
kmem_zone_free(xfs_mru_elem_zone, elem);
|
error = ENOMEM;
|
||||||
return ENOMEM;
|
goto out_free_item;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_LIST_HEAD(&elem->list_node);
|
INIT_LIST_HEAD(&elem->list_node);
|
||||||
|
@ -463,13 +464,20 @@ xfs_mru_cache_insert(
|
||||||
|
|
||||||
spin_lock(&mru->lock);
|
spin_lock(&mru->lock);
|
||||||
|
|
||||||
radix_tree_insert(&mru->store, key, elem);
|
error = -radix_tree_insert(&mru->store, key, elem);
|
||||||
radix_tree_preload_end();
|
radix_tree_preload_end();
|
||||||
|
if (error) {
|
||||||
|
spin_unlock(&mru->lock);
|
||||||
|
goto out_free_item;
|
||||||
|
}
|
||||||
_xfs_mru_cache_list_insert(mru, elem);
|
_xfs_mru_cache_list_insert(mru, elem);
|
||||||
|
|
||||||
spin_unlock(&mru->lock);
|
spin_unlock(&mru->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
out_free_item:
|
||||||
|
kmem_zone_free(xfs_mru_elem_zone, elem);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue