Message ID | ad30ad3095fe61d755fc6233e5334f953a68f495.1713052088.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: delayed refs cleanups | expand |
On Sun, Apr 14, 2024 at 12:55 AM Josef Bacik <josef@toxicpanda.com> wrote: > > We only ever need to use this to get the level of the tree block ref, so > use the btrfs_delayed_ref_owner() helper, which returns the level for > the given reference. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Looks good, thanks. > --- > fs/btrfs/backref.c | 21 +++++++++++---------- > fs/btrfs/extent-tree.c | 10 +++++----- > include/trace/events/btrfs.h | 1 - > 3 files changed, 16 insertions(+), 16 deletions(-) > > diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c > index eb9f2f078a26..574fb1d515b3 100644 > --- a/fs/btrfs/backref.c > +++ b/fs/btrfs/backref.c > @@ -919,28 +919,29 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, > switch (node->type) { > case BTRFS_TREE_BLOCK_REF_KEY: { > /* NORMAL INDIRECT METADATA backref */ > - struct btrfs_delayed_tree_ref *ref; > struct btrfs_key *key_ptr = NULL; > + /* The owner of a tree block ref is the level. */ > + int level = btrfs_delayed_ref_owner(node); > > if (head->extent_op && head->extent_op->update_key) { > btrfs_disk_key_to_cpu(&key, &head->extent_op->key); > key_ptr = &key; > } > > - ref = btrfs_delayed_node_to_tree_ref(node); > ret = add_indirect_ref(fs_info, preftrees, node->ref_root, > - key_ptr, ref->level + 1, > - node->bytenr, count, sc, > - GFP_ATOMIC); > + key_ptr, level + 1, node->bytenr, > + count, sc, GFP_ATOMIC); > break; > } > case BTRFS_SHARED_BLOCK_REF_KEY: { > - /* SHARED DIRECT METADATA backref */ > - struct btrfs_delayed_tree_ref *ref; > + /* > + * SHARED DIRECT METADATA backref > + * > + * The owner of a tree block ref is the level. > + */ > + int level = btrfs_delayed_ref_owner(node); > > - ref = btrfs_delayed_node_to_tree_ref(node); > - > - ret = add_direct_ref(fs_info, preftrees, ref->level + 1, > + ret = add_direct_ref(fs_info, preftrees, level + 1, > node->parent, node->bytenr, count, > sc, GFP_ATOMIC); > break; > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c > index 839c64d5a12d..4fb3c466bbfc 100644 > --- a/fs/btrfs/extent-tree.c > +++ b/fs/btrfs/extent-tree.c > @@ -4865,16 +4865,16 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, > struct btrfs_extent_inline_ref *iref; > struct btrfs_path *path; > struct extent_buffer *leaf; > - struct btrfs_delayed_tree_ref *ref; > u32 size = sizeof(*extent_item) + sizeof(*iref); > u64 flags = extent_op->flags_to_set; > + /* The owner of a tree block is the level. */ > + int level = btrfs_delayed_ref_owner(node); > bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA); > > - ref = btrfs_delayed_node_to_tree_ref(node); > - > extent_key.objectid = node->bytenr; > if (skinny_metadata) { > - extent_key.offset = ref->level; > + /* The owner of a tree block is the level. */ > + extent_key.offset = level; > extent_key.type = BTRFS_METADATA_ITEM_KEY; > } else { > extent_key.offset = node->num_bytes; > @@ -4907,7 +4907,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, > } else { > block_info = (struct btrfs_tree_block_info *)(extent_item + 1); > btrfs_set_tree_block_key(leaf, block_info, &extent_op->key); > - btrfs_set_tree_block_level(leaf, block_info, ref->level); > + btrfs_set_tree_block_level(leaf, block_info, level); > iref = (struct btrfs_extent_inline_ref *)(block_info + 1); > } > > diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h > index 89fa96fd95b4..8f2497603cb5 100644 > --- a/include/trace/events/btrfs.h > +++ b/include/trace/events/btrfs.h > @@ -16,7 +16,6 @@ struct extent_map; > struct btrfs_file_extent_item; > struct btrfs_ordered_extent; > struct btrfs_delayed_ref_node; > -struct btrfs_delayed_tree_ref; > struct btrfs_delayed_ref_head; > struct btrfs_block_group; > struct btrfs_free_cluster; > -- > 2.43.0 > >
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index eb9f2f078a26..574fb1d515b3 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -919,28 +919,29 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, switch (node->type) { case BTRFS_TREE_BLOCK_REF_KEY: { /* NORMAL INDIRECT METADATA backref */ - struct btrfs_delayed_tree_ref *ref; struct btrfs_key *key_ptr = NULL; + /* The owner of a tree block ref is the level. */ + int level = btrfs_delayed_ref_owner(node); if (head->extent_op && head->extent_op->update_key) { btrfs_disk_key_to_cpu(&key, &head->extent_op->key); key_ptr = &key; } - ref = btrfs_delayed_node_to_tree_ref(node); ret = add_indirect_ref(fs_info, preftrees, node->ref_root, - key_ptr, ref->level + 1, - node->bytenr, count, sc, - GFP_ATOMIC); + key_ptr, level + 1, node->bytenr, + count, sc, GFP_ATOMIC); break; } case BTRFS_SHARED_BLOCK_REF_KEY: { - /* SHARED DIRECT METADATA backref */ - struct btrfs_delayed_tree_ref *ref; + /* + * SHARED DIRECT METADATA backref + * + * The owner of a tree block ref is the level. + */ + int level = btrfs_delayed_ref_owner(node); - ref = btrfs_delayed_node_to_tree_ref(node); - - ret = add_direct_ref(fs_info, preftrees, ref->level + 1, + ret = add_direct_ref(fs_info, preftrees, level + 1, node->parent, node->bytenr, count, sc, GFP_ATOMIC); break; diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 839c64d5a12d..4fb3c466bbfc 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4865,16 +4865,16 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, struct btrfs_extent_inline_ref *iref; struct btrfs_path *path; struct extent_buffer *leaf; - struct btrfs_delayed_tree_ref *ref; u32 size = sizeof(*extent_item) + sizeof(*iref); u64 flags = extent_op->flags_to_set; + /* The owner of a tree block is the level. */ + int level = btrfs_delayed_ref_owner(node); bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA); - ref = btrfs_delayed_node_to_tree_ref(node); - extent_key.objectid = node->bytenr; if (skinny_metadata) { - extent_key.offset = ref->level; + /* The owner of a tree block is the level. */ + extent_key.offset = level; extent_key.type = BTRFS_METADATA_ITEM_KEY; } else { extent_key.offset = node->num_bytes; @@ -4907,7 +4907,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, } else { block_info = (struct btrfs_tree_block_info *)(extent_item + 1); btrfs_set_tree_block_key(leaf, block_info, &extent_op->key); - btrfs_set_tree_block_level(leaf, block_info, ref->level); + btrfs_set_tree_block_level(leaf, block_info, level); iref = (struct btrfs_extent_inline_ref *)(block_info + 1); } diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index 89fa96fd95b4..8f2497603cb5 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -16,7 +16,6 @@ struct extent_map; struct btrfs_file_extent_item; struct btrfs_ordered_extent; struct btrfs_delayed_ref_node; -struct btrfs_delayed_tree_ref; struct btrfs_delayed_ref_head; struct btrfs_block_group; struct btrfs_free_cluster;
We only ever need to use this to get the level of the tree block ref, so use the btrfs_delayed_ref_owner() helper, which returns the level for the given reference. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/backref.c | 21 +++++++++++---------- fs/btrfs/extent-tree.c | 10 +++++----- include/trace/events/btrfs.h | 1 - 3 files changed, 16 insertions(+), 16 deletions(-)