diff options
author | Josef Bacik | 2024-04-12 20:09:45 -0400 |
---|---|---|
committer | David Sterba | 2024-05-07 21:31:04 +0200 |
commit | 0ea4703cc27e4e0f4fd8a9403ecae21a8879e7e0 (patch) | |
tree | 5e2adfc26909c5c933de7e98dc2e7a1160a8dae5 /fs | |
parent | 0509cc56619d63e946f1212d0f40767728e18fbc (diff) |
btrfs: move ref specific initialization into init_delayed_ref_common
Now that the btrfs_delayed_ref_node contains a union of the data and
metadata specific information we can move the initialization into
init_delayed_ref_common and just use the btrfs_ref to initialize the
correct fields of the reference.
Reviewed-by: Filipe Manana <fdmanana@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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/delayed-ref.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 5ff6c109e5bf..743cc52c30af 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -1007,6 +1007,17 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info, ref->type = btrfs_ref_type(generic_ref); RB_CLEAR_NODE(&ref->ref_node); INIT_LIST_HEAD(&ref->add_list); + + if (generic_ref->type == BTRFS_REF_DATA) { + ref->data_ref.root = generic_ref->ref_root; + ref->data_ref.parent = generic_ref->parent; + ref->data_ref.objectid = generic_ref->data_ref.ino; + ref->data_ref.offset = generic_ref->data_ref.offset; + } else { + ref->tree_ref.root = generic_ref->ref_root; + ref->tree_ref.parent = generic_ref->parent; + ref->tree_ref.level = generic_ref->tree_ref.level; + } } void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root, @@ -1061,8 +1072,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, bool qrecord_inserted; bool merged; int action = generic_ref->action; - int level = generic_ref->tree_ref.level; - u64 parent = generic_ref->parent; ASSERT(generic_ref->type == BTRFS_REF_METADATA && generic_ref->action); node = kmem_cache_alloc(btrfs_delayed_ref_node_cachep, GFP_NOFS); @@ -1087,9 +1096,6 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, ref = btrfs_delayed_node_to_tree_ref(node); init_delayed_ref_common(fs_info, node, generic_ref); - ref->root = generic_ref->ref_root; - ref->parent = parent; - ref->level = level; init_delayed_ref_head(head_ref, generic_ref, record, 0); head_ref->extent_op = extent_op; @@ -1141,10 +1147,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, bool qrecord_inserted; int action = generic_ref->action; bool merged; - u64 parent = generic_ref->parent; - u64 ref_root = generic_ref->ref_root; - u64 owner = generic_ref->data_ref.ino; - u64 offset = generic_ref->data_ref.offset; ASSERT(generic_ref->type == BTRFS_REF_DATA && action); node = kmem_cache_alloc(btrfs_delayed_ref_node_cachep, GFP_NOFS); @@ -1154,11 +1156,6 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, ref = btrfs_delayed_node_to_data_ref(node); init_delayed_ref_common(fs_info, node, generic_ref); - ref->root = ref_root; - ref->parent = parent; - ref->objectid = owner; - ref->offset = offset; - head_ref = kmem_cache_alloc(btrfs_delayed_ref_head_cachep, GFP_NOFS); if (!head_ref) { |