Skip to content

Commit 4cbf37f

Browse files
fdmananakdave
authored andcommitted
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: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 96d8992 commit 4cbf37f

File tree

1 file changed

+3
-42
lines changed

1 file changed

+3
-42
lines changed

fs/btrfs/delayed-inode.c

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -322,28 +322,20 @@ static struct btrfs_delayed_item *btrfs_alloc_delayed_item(u32 data_len,
322322
* __btrfs_lookup_delayed_item - look up the delayed item by key
323323
* @delayed_node: pointer to the delayed node
324324
* @index: the dir index value to lookup (offset of a dir index key)
325-
* @prev: used to store the prev item if the right item isn't found
326-
* @next: used to store the next item if the right item isn't found
327325
*
328326
* Note: if we don't find the right item, we will return the prev item and
329327
* the next item.
330328
*/
331329
static struct btrfs_delayed_item *__btrfs_lookup_delayed_item(
332330
struct rb_root *root,
333-
u64 index,
334-
struct btrfs_delayed_item **prev,
335-
struct btrfs_delayed_item **next)
331+
u64 index)
336332
{
337-
struct rb_node *node, *prev_node = NULL;
333+
struct rb_node *node = root->rb_node;
338334
struct btrfs_delayed_item *delayed_item = NULL;
339-
int ret = 0;
340-
341-
node = root->rb_node;
342335

343336
while (node) {
344337
delayed_item = rb_entry(node, struct btrfs_delayed_item,
345338
rb_node);
346-
prev_node = node;
347339
if (delayed_item->index < index)
348340
node = node->rb_right;
349341
else if (delayed_item->index > index)
@@ -352,40 +344,9 @@ static struct btrfs_delayed_item *__btrfs_lookup_delayed_item(
352344
return delayed_item;
353345
}
354346

355-
if (prev) {
356-
if (!prev_node)
357-
*prev = NULL;
358-
else if (ret < 0)
359-
*prev = delayed_item;
360-
else if ((node = rb_prev(prev_node)) != NULL) {
361-
*prev = rb_entry(node, struct btrfs_delayed_item,
362-
rb_node);
363-
} else
364-
*prev = NULL;
365-
}
366-
367-
if (next) {
368-
if (!prev_node)
369-
*next = NULL;
370-
else if (ret > 0)
371-
*next = delayed_item;
372-
else if ((node = rb_next(prev_node)) != NULL) {
373-
*next = rb_entry(node, struct btrfs_delayed_item,
374-
rb_node);
375-
} else
376-
*next = NULL;
377-
}
378347
return NULL;
379348
}
380349

381-
static struct btrfs_delayed_item *__btrfs_lookup_delayed_insertion_item(
382-
struct btrfs_delayed_node *delayed_node,
383-
u64 index)
384-
{
385-
return __btrfs_lookup_delayed_item(&delayed_node->ins_root.rb_root, index,
386-
NULL, NULL);
387-
}
388-
389350
static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node,
390351
struct btrfs_delayed_item *ins)
391352
{
@@ -1549,7 +1510,7 @@ static int btrfs_delete_delayed_insertion_item(struct btrfs_fs_info *fs_info,
15491510
struct btrfs_delayed_item *item;
15501511

15511512
mutex_lock(&node->mutex);
1552-
item = __btrfs_lookup_delayed_insertion_item(node, index);
1513+
item = __btrfs_lookup_delayed_item(&node->ins_root.rb_root, index);
15531514
if (!item) {
15541515
mutex_unlock(&node->mutex);
15551516
return 1;

0 commit comments

Comments
 (0)