btrfs: move ref_mod modification into the if (ref) logic
authorJosef Bacik <josef@toxicpanda.com>
Fri, 29 Sep 2017 19:43:55 +0000 (15:43 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 30 Oct 2017 11:28:00 +0000 (12:28 +0100)
We only use this logic if our ref isn't a ref_head, so move it up into
the if (ref) case since we know that this is a normal ref and not a
delayed ref head.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index 5e61e9287b0ea223546331df8152258ad0c6bac6..0dcbbeacaadc7d91e7fd9dd3cc1dfb4617db82b0 100644 (file)
@@ -2744,10 +2744,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
                        list_del(&ref->list);
                        if (!list_empty(&ref->add_list))
                                list_del(&ref->add_list);
-               }
-               atomic_dec(&delayed_refs->num_entries);
-
-               if (!btrfs_delayed_ref_is_head(ref)) {
                        /*
                         * when we play the delayed ref, also correct the
                         * ref_mod on head
@@ -2764,6 +2760,8 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
                                WARN_ON(1);
                        }
                }
+               atomic_dec(&delayed_refs->num_entries);
+
                /*
                 * Record the must-insert_reserved flag before we drop the spin
                 * lock.