Commit 6b1ba797 authored by Andrew Morton's avatar Andrew Morton Committed by David S. Miller

[PATCH] remove radix_tree_reserve()

From Hugh Dickins.

radix_tree_reserve() exists solely for the tmpfs move_to_swap_cache()
and move_from_swap_cache() functions, and yet they don't need it: there
is no problem in the one page being simultaneously listed in two radix
trees (while both locks are held).  Use radix_tree_insert(), and remove
radix_tree_reserve(); also removed a few blank lines.
parent 60c6d43b
......@@ -21,8 +21,6 @@
struct radix_tree_node;
#define RADIX_TREE_SLOT_RESERVED ((void *)~0UL)
struct radix_tree_root {
unsigned int height;
int gfp_mask;
......@@ -41,7 +39,6 @@ do { \
(root)->rnode = NULL; \
} while (0)
extern int radix_tree_reserve(struct radix_tree_root *, unsigned long, void ***);
extern int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
extern void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
extern int radix_tree_delete(struct radix_tree_root *, unsigned long);
......
......@@ -77,7 +77,6 @@ static inline unsigned long radix_tree_maxindex(unsigned int height)
return index;
}
/*
* Extend a radix tree so it can store key @index.
*/
......@@ -109,16 +108,15 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
return 0;
}
/**
* radix_tree_reserve - reserve space in a radix tree
* radix_tree_insert - insert into a radix tree
* @root: radix tree root
* @index: index key
* @pslot: pointer to reserved slot
* @item: item to insert
*
* Reserve a slot in a radix tree for the key @index.
* Insert an item into the radix tree at position @index.
*/
int radix_tree_reserve(struct radix_tree_root *root, unsigned long index, void ***pslot)
int radix_tree_insert(struct radix_tree_root *root, unsigned long index, void *item)
{
struct radix_tree_node *node = NULL, *tmp, **slot;
unsigned int height, shift;
......@@ -158,36 +156,11 @@ int radix_tree_reserve(struct radix_tree_root *root, unsigned long index, void *
if (node)
node->count++;
*pslot = (void **)slot;
**pslot = RADIX_TREE_SLOT_RESERVED;
*slot = item;
return 0;
}
EXPORT_SYMBOL(radix_tree_reserve);
/**
* radix_tree_insert - insert into a radix tree
* @root: radix tree root
* @index: index key
* @item: item to insert
*
* Insert an item into the radix tree at position @index.
*/
int radix_tree_insert(struct radix_tree_root *root, unsigned long index, void *item)
{
void **slot;
int error;
error = radix_tree_reserve(root, index, &slot);
if (!error)
*slot = item;
return error;
}
EXPORT_SYMBOL(radix_tree_insert);
/**
* radix_tree_lookup - perform lookup operation on a radix tree
* @root: radix tree root
......@@ -267,8 +240,8 @@ __lookup(struct radix_tree_root *root, void **results, unsigned long index,
out:
*next_index = index;
return nr_found;
}
/**
* radix_tree_gang_lookup - perform multiple lookup on a radix tree
* @root: radix tree root
......@@ -371,7 +344,6 @@ int radix_tree_delete(struct radix_tree_root *root, unsigned long index)
return 0;
}
EXPORT_SYMBOL(radix_tree_delete);
static void radix_tree_node_ctor(void *node, kmem_cache_t *cachep, unsigned long flags)
......
......@@ -199,16 +199,14 @@ void delete_from_swap_cache(struct page *page)
int move_to_swap_cache(struct page *page, swp_entry_t entry)
{
struct address_space *mapping = page->mapping;
void **pslot;
int err;
write_lock(&swapper_space.page_lock);
write_lock(&mapping->page_lock);
err = radix_tree_reserve(&swapper_space.page_tree, entry.val, &pslot);
err = radix_tree_insert(&swapper_space.page_tree, entry.val, page);
if (!err) {
__remove_from_page_cache(page);
*pslot = page;
___add_to_page_cache(page, &swapper_space, entry.val);
}
......@@ -231,7 +229,6 @@ int move_from_swap_cache(struct page *page, unsigned long index,
struct address_space *mapping)
{
swp_entry_t entry;
void **pslot;
int err;
BUG_ON(!PageLocked(page));
......@@ -243,10 +240,9 @@ int move_from_swap_cache(struct page *page, unsigned long index,
write_lock(&swapper_space.page_lock);
write_lock(&mapping->page_lock);
err = radix_tree_reserve(&mapping->page_tree, index, &pslot);
err = radix_tree_insert(&mapping->page_tree, index, page);
if (!err) {
__delete_from_swap_cache(page);
*pslot = page;
___add_to_page_cache(page, mapping, index);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment