btrfs: make btrfs_destroy_delayed_refs use btrfs_delayed_ref_lock
authorJosef Bacik <josef@toxicpanda.com>
Wed, 21 Nov 2018 19:05:39 +0000 (14:05 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Feb 2019 13:13:25 +0000 (14:13 +0100)
We have this open coded in btrfs_destroy_delayed_refs, use the helper
instead.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c

index 888d72dda79467290e6387152b8d8bb711aa690d..b723ad9bd1e620949584a5ed59bc59a0185c0e06 100644 (file)
@@ -4246,16 +4246,9 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
 
                head = rb_entry(node, struct btrfs_delayed_ref_head,
                                href_node);
-               if (!mutex_trylock(&head->mutex)) {
-                       refcount_inc(&head->refs);
-                       spin_unlock(&delayed_refs->lock);
-
-                       mutex_lock(&head->mutex);
-                       mutex_unlock(&head->mutex);
-                       btrfs_put_delayed_ref_head(head);
-                       spin_lock(&delayed_refs->lock);
+               if (btrfs_delayed_ref_lock(delayed_refs, head))
                        continue;
-               }
+
                spin_lock(&head->lock);
                while ((n = rb_first_cached(&head->ref_tree)) != NULL) {
                        ref = rb_entry(n, struct btrfs_delayed_ref_node,