Commit 4cbf37f5 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: remove unused logic when looking up delayed items

All callers pass NULL to the 'prev' and 'next' arguments of the function
__btrfs_lookup_delayed_item(), so remove these arguments. Also, remove
the unnecessary wrapper __btrfs_lookup_delayed_insertion_item(), making
btrfs_delete_delayed_insertion_item() directly call
__btrfs_lookup_delayed_item().
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 96d89923
......@@ -322,28 +322,20 @@ static struct btrfs_delayed_item *btrfs_alloc_delayed_item(u32 data_len,
* __btrfs_lookup_delayed_item - look up the delayed item by key
* @delayed_node: pointer to the delayed node
* @index: the dir index value to lookup (offset of a dir index key)
* @prev: used to store the prev item if the right item isn't found
* @next: used to store the next item if the right item isn't found
*
* Note: if we don't find the right item, we will return the prev item and
* the next item.
*/
static struct btrfs_delayed_item *__btrfs_lookup_delayed_item(
struct rb_root *root,
u64 index,
struct btrfs_delayed_item **prev,
struct btrfs_delayed_item **next)
u64 index)
{
struct rb_node *node, *prev_node = NULL;
struct rb_node *node = root->rb_node;
struct btrfs_delayed_item *delayed_item = NULL;
int ret = 0;
node = root->rb_node;
while (node) {
delayed_item = rb_entry(node, struct btrfs_delayed_item,
rb_node);
prev_node = node;
if (delayed_item->index < index)
node = node->rb_right;
else if (delayed_item->index > index)
......@@ -352,40 +344,9 @@ static struct btrfs_delayed_item *__btrfs_lookup_delayed_item(
return delayed_item;
}
if (prev) {
if (!prev_node)
*prev = NULL;
else if (ret < 0)
*prev = delayed_item;
else if ((node = rb_prev(prev_node)) != NULL) {
*prev = rb_entry(node, struct btrfs_delayed_item,
rb_node);
} else
*prev = NULL;
}
if (next) {
if (!prev_node)
*next = NULL;
else if (ret > 0)
*next = delayed_item;
else if ((node = rb_next(prev_node)) != NULL) {
*next = rb_entry(node, struct btrfs_delayed_item,
rb_node);
} else
*next = NULL;
}
return NULL;
}
static struct btrfs_delayed_item *__btrfs_lookup_delayed_insertion_item(
struct btrfs_delayed_node *delayed_node,
u64 index)
{
return __btrfs_lookup_delayed_item(&delayed_node->ins_root.rb_root, index,
NULL, NULL);
}
static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node,
struct btrfs_delayed_item *ins)
{
......@@ -1549,7 +1510,7 @@ static int btrfs_delete_delayed_insertion_item(struct btrfs_fs_info *fs_info,
struct btrfs_delayed_item *item;
mutex_lock(&node->mutex);
item = __btrfs_lookup_delayed_insertion_item(node, index);
item = __btrfs_lookup_delayed_item(&node->ins_root.rb_root, index);
if (!item) {
mutex_unlock(&node->mutex);
return 1;
......
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