]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: remove unused logic when looking up delayed items
authorFilipe Manana <fdmanana@suse.com>
Wed, 17 Aug 2022 11:22:41 +0000 (12:22 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Sep 2022 10:27:56 +0000 (12:27 +0200)
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>
fs/btrfs/delayed-inode.c

index cd2f3a8c4dfd32e96ac3c634fdbbb2c815b33533..a8947ac0068167adc134e71dcf15decf71adba05 100644 (file)
@@ -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;