diff options
author | Josef Bacik <josef@toxicpanda.com> | 2024-04-12 23:16:40 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-05-07 21:31:04 +0200 |
commit | d3fbb00f5e21c6dfaa6e820a21df0c9a3455a028 (patch) | |
tree | 553731f24970610a3f170c4ee6637c7ddea59ed3 /fs/btrfs/delayed-ref.h | |
parent | btrfs: add a helper to get the delayed ref node from the data/tree ref (diff) | |
download | linux-d3fbb00f5e21c6dfaa6e820a21df0c9a3455a028.tar.xz linux-d3fbb00f5e21c6dfaa6e820a21df0c9a3455a028.zip |
btrfs: embed data_ref and tree_ref in btrfs_delayed_ref_node
We have been embedding btrfs_delayed_ref_node in the
btrfs_delayed_data_ref and btrfs_delayed_tree_ref, and then we have two
sets of cachep's and a variety of handling that is awkward because of
this separation.
Instead union these two members inside of btrfs_delayed_ref_node and
make that the first class object. This allows us to go down to one
cachep for our delayed ref nodes instead of two.
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/btrfs/delayed-ref.h')
-rw-r--r-- | fs/btrfs/delayed-ref.h | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index b3a78bf7b072..2de447d9aaba 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -30,6 +30,19 @@ enum btrfs_delayed_ref_action { BTRFS_UPDATE_DELAYED_HEAD, } __packed; +struct btrfs_delayed_tree_ref { + u64 root; + u64 parent; + int level; +}; + +struct btrfs_delayed_data_ref { + u64 root; + u64 parent; + u64 objectid; + u64 offset; +}; + struct btrfs_delayed_ref_node { struct rb_node ref_node; /* @@ -64,6 +77,11 @@ struct btrfs_delayed_ref_node { unsigned int action:8; unsigned int type:8; + + union { + struct btrfs_delayed_tree_ref tree_ref; + struct btrfs_delayed_data_ref data_ref; + }; }; struct btrfs_delayed_extent_op { @@ -151,21 +169,6 @@ struct btrfs_delayed_ref_head { bool processing; }; -struct btrfs_delayed_tree_ref { - struct btrfs_delayed_ref_node node; - u64 root; - u64 parent; - int level; -}; - -struct btrfs_delayed_data_ref { - struct btrfs_delayed_ref_node node; - u64 root; - u64 parent; - u64 objectid; - u64 offset; -}; - enum btrfs_delayed_ref_flags { /* Indicate that we are flushing delayed refs for the commit */ BTRFS_DELAYED_REFS_FLUSHING, @@ -279,8 +282,7 @@ struct btrfs_ref { }; extern struct kmem_cache *btrfs_delayed_ref_head_cachep; -extern struct kmem_cache *btrfs_delayed_tree_ref_cachep; -extern struct kmem_cache *btrfs_delayed_data_ref_cachep; +extern struct kmem_cache *btrfs_delayed_ref_node_cachep; extern struct kmem_cache *btrfs_delayed_extent_op_cachep; int __init btrfs_delayed_ref_init(void); @@ -404,25 +406,25 @@ bool btrfs_check_space_for_delayed_refs(struct btrfs_fs_info *fs_info); static inline struct btrfs_delayed_tree_ref * btrfs_delayed_node_to_tree_ref(struct btrfs_delayed_ref_node *node) { - return container_of(node, struct btrfs_delayed_tree_ref, node); + return &node->tree_ref; } static inline struct btrfs_delayed_data_ref * btrfs_delayed_node_to_data_ref(struct btrfs_delayed_ref_node *node) { - return container_of(node, struct btrfs_delayed_data_ref, node); + return &node->data_ref; } static inline struct btrfs_delayed_ref_node * btrfs_delayed_tree_ref_to_node(struct btrfs_delayed_tree_ref *ref) { - return &ref->node; + return container_of(ref, struct btrfs_delayed_ref_node, tree_ref); } static inline struct btrfs_delayed_ref_node * btrfs_delayed_data_ref_to_node(struct btrfs_delayed_data_ref *ref) { - return &ref->node; + return container_of(ref, struct btrfs_delayed_ref_node, data_ref); } #endif |