btrfs: Use init_delayed_ref_common in add_delayed_data_ref
authorNikolay Borisov <nborisov@suse.com>
Tue, 24 Apr 2018 14:18:19 +0000 (17:18 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 28 May 2018 16:07:31 +0000 (18:07 +0200)
Use the newly introduced helper and remove the duplicate code.  No
functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-ref.c

index 1c27d3322198d369b17b6de1e0bb0e167bbadc7d..c891e88d546e73cdfe66deb1aa0566981d563f94 100644 (file)
@@ -750,41 +750,26 @@ add_delayed_data_ref(struct btrfs_trans_handle *trans,
 {
        struct btrfs_delayed_data_ref *full_ref;
        struct btrfs_delayed_ref_root *delayed_refs;
 {
        struct btrfs_delayed_data_ref *full_ref;
        struct btrfs_delayed_ref_root *delayed_refs;
-       u64 seq = 0;
+       u8 ref_type;
        int ret;
 
        int ret;
 
-       if (action == BTRFS_ADD_DELAYED_EXTENT)
-               action = BTRFS_ADD_DELAYED_REF;
-
        delayed_refs = &trans->transaction->delayed_refs;
        delayed_refs = &trans->transaction->delayed_refs;
-
-       if (is_fstree(ref_root))
-               seq = atomic64_read(&trans->fs_info->tree_mod_seq);
-
-       /* first set the basic ref node struct up */
-       refcount_set(&ref->refs, 1);
-       ref->bytenr = bytenr;
-       ref->num_bytes = num_bytes;
-       ref->ref_mod = 1;
-       ref->action = action;
-       ref->is_head = 0;
-       ref->in_tree = 1;
-       ref->seq = seq;
-       RB_CLEAR_NODE(&ref->ref_node);
-       INIT_LIST_HEAD(&ref->add_list);
-
        full_ref = btrfs_delayed_node_to_data_ref(ref);
        full_ref = btrfs_delayed_node_to_data_ref(ref);
-       full_ref->parent = parent;
-       full_ref->root = ref_root;
        if (parent)
        if (parent)
-               ref->type = BTRFS_SHARED_DATA_REF_KEY;
+               ref_type = BTRFS_SHARED_DATA_REF_KEY;
        else
        else
-               ref->type = BTRFS_EXTENT_DATA_REF_KEY;
+               ref_type = BTRFS_EXTENT_DATA_REF_KEY;
 
 
+       init_delayed_ref_common(trans->fs_info, ref, bytenr, num_bytes,
+                               ref_root, action, ref_type);
+       full_ref->root = ref_root;
+       full_ref->parent = parent;
        full_ref->objectid = owner;
        full_ref->offset = offset;
 
        full_ref->objectid = owner;
        full_ref->offset = offset;
 
-       trace_add_delayed_data_ref(trans->fs_info, ref, full_ref, action);
+       trace_add_delayed_data_ref(trans->fs_info, ref, full_ref,
+                                  action == BTRFS_ADD_DELAYED_EXTENT ?
+                                  BTRFS_ADD_DELAYED_REF : action);
 
        ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
        if (ret > 0)
 
        ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
        if (ret > 0)