Btrfs: cleanup delayed-ref.c:find_ref_head()
authorFilipe Manana <fdmanana@gmail.com>
Wed, 12 Feb 2014 15:07:53 +0000 (15:07 +0000)
committerJosef Bacik <jbacik@fb.com>
Mon, 10 Mar 2014 19:16:46 +0000 (15:16 -0400)
The argument last wasn't used, all callers supplied a NULL value
for it. Also removed unnecessary intermediate storage of the result
of key comparisons.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
fs/btrfs/delayed-ref.c

index 56cdfe988d69e82b0b5942a5169713c918c98a50..2502ba5a3ac0b71155dc7db6501ba3124ecce979 100644 (file)
@@ -199,42 +199,30 @@ static struct btrfs_delayed_ref_head *htree_insert(struct rb_root *root,
  */
 static struct btrfs_delayed_ref_head *
 find_ref_head(struct rb_root *root, u64 bytenr,
-             struct btrfs_delayed_ref_head **last, int return_bigger)
+             int return_bigger)
 {
        struct rb_node *n;
        struct btrfs_delayed_ref_head *entry;
-       int cmp = 0;
 
        n = root->rb_node;
        entry = NULL;
        while (n) {
                entry = rb_entry(n, struct btrfs_delayed_ref_head, href_node);
-               if (last)
-                       *last = entry;
 
                if (bytenr < entry->node.bytenr)
-                       cmp = -1;
-               else if (bytenr > entry->node.bytenr)
-                       cmp = 1;
-               else
-                       cmp = 0;
-
-               if (cmp < 0)
                        n = n->rb_left;
-               else if (cmp > 0)
+               else if (bytenr > entry->node.bytenr)
                        n = n->rb_right;
                else
                        return entry;
        }
        if (entry && return_bigger) {
-               if (cmp > 0) {
+               if (bytenr > entry->node.bytenr) {
                        n = rb_next(&entry->href_node);
                        if (!n)
                                n = rb_first(root);
                        entry = rb_entry(n, struct btrfs_delayed_ref_head,
                                         href_node);
-                       if (last)
-                               *last = entry;
                        return entry;
                }
                return entry;
@@ -414,12 +402,12 @@ btrfs_select_ref_head(struct btrfs_trans_handle *trans)
 
 again:
        start = delayed_refs->run_delayed_start;
-       head = find_ref_head(&delayed_refs->href_root, start, NULL, 1);
+       head = find_ref_head(&delayed_refs->href_root, start, 1);
        if (!head && !loop) {
                delayed_refs->run_delayed_start = 0;
                start = 0;
                loop = true;
-               head = find_ref_head(&delayed_refs->href_root, start, NULL, 1);
+               head = find_ref_head(&delayed_refs->href_root, start, 1);
                if (!head)
                        return NULL;
        } else if (!head && loop) {
@@ -897,7 +885,7 @@ btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr)
        struct btrfs_delayed_ref_root *delayed_refs;
 
        delayed_refs = &trans->transaction->delayed_refs;
-       return find_ref_head(&delayed_refs->href_root, bytenr, NULL, 0);
+       return find_ref_head(&delayed_refs->href_root, bytenr, 0);
 }
 
 void btrfs_delayed_ref_exit(void)