Message ID | 930cd415c44b9b034fa8a23a887275d12fad4e87.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 2:51 AM Josef Bacik <josef@toxicpanda.com> wrote: > > Now that most of our elements are inside of btrfs_delayed_ref_node > directly and we have helpers for the delayed_data_ref bits, go ahead and > remove all direct usage of btrfs_delayed_data_ref and use the helpers > where needed. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Looks good, thanks. > --- > fs/btrfs/backref.c | 7 ++----- > fs/btrfs/extent-tree.c | 20 +++++++++++--------- > include/trace/events/btrfs.h | 1 - > 3 files changed, 13 insertions(+), 15 deletions(-) > > diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c > index 98a0cf68d198..eb9f2f078a26 100644 > --- a/fs/btrfs/backref.c > +++ b/fs/btrfs/backref.c > @@ -947,12 +947,9 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, > } > case BTRFS_EXTENT_DATA_REF_KEY: { > /* NORMAL INDIRECT DATA backref */ > - struct btrfs_delayed_data_ref *ref; > - ref = btrfs_delayed_node_to_data_ref(node); > - > - key.objectid = ref->objectid; > + key.objectid = btrfs_delayed_ref_owner(node); > key.type = BTRFS_EXTENT_DATA_KEY; > - key.offset = ref->offset; > + key.offset = btrfs_delayed_ref_offset(node); > > /* > * If we have a share check context and a reference for > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c > index d85bc31f2e57..839c64d5a12d 100644 > --- a/fs/btrfs/extent-tree.c > +++ b/fs/btrfs/extent-tree.c > @@ -1543,11 +1543,9 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans, > bool insert_reserved) > { > int ret = 0; > - struct btrfs_delayed_data_ref *ref; > u64 parent = 0; > u64 flags = 0; > > - ref = btrfs_delayed_node_to_data_ref(node); > trace_run_delayed_data_ref(trans->fs_info, node); > > if (node->type == BTRFS_SHARED_DATA_REF_KEY) > @@ -1562,6 +1560,8 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans, > .is_inc = true, > .generation = trans->transid, > }; > + u64 owner = btrfs_delayed_ref_owner(node); > + u64 offset = btrfs_delayed_ref_offset(node); > > if (extent_op) > flags |= extent_op->flags_to_set; > @@ -1571,9 +1571,9 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans, > key.offset = node->num_bytes; > > ret = alloc_reserved_file_extent(trans, parent, node->ref_root, > - flags, ref->objectid, > - ref->offset, &key, > - node->ref_mod, href->owning_root); > + flags, owner, offset, &key, > + node->ref_mod, > + href->owning_root); > free_head_ref_squota_rsv(trans->fs_info, href); > if (!ret) > ret = btrfs_record_squota_delta(trans->fs_info, &delta); > @@ -2258,7 +2258,6 @@ static noinline int check_delayed_ref(struct btrfs_root *root, > { > struct btrfs_delayed_ref_head *head; > struct btrfs_delayed_ref_node *ref; > - struct btrfs_delayed_data_ref *data_ref; > struct btrfs_delayed_ref_root *delayed_refs; > struct btrfs_transaction *cur_trans; > struct rb_node *node; > @@ -2312,6 +2311,9 @@ static noinline int check_delayed_ref(struct btrfs_root *root, > */ > for (node = rb_first_cached(&head->ref_tree); node; > node = rb_next(node)) { > + u64 ref_owner; > + u64 ref_offset; > + > ref = rb_entry(node, struct btrfs_delayed_ref_node, ref_node); > /* If it's a shared ref we know a cross reference exists */ > if (ref->type != BTRFS_EXTENT_DATA_REF_KEY) { > @@ -2319,15 +2321,15 @@ static noinline int check_delayed_ref(struct btrfs_root *root, > break; > } > > - data_ref = btrfs_delayed_node_to_data_ref(ref); > + ref_owner = btrfs_delayed_ref_owner(ref); > + ref_offset = btrfs_delayed_ref_offset(ref); > > /* > * If our ref doesn't match the one we're currently looking at > * then we have a cross reference. > */ > if (ref->ref_root != root->root_key.objectid || > - data_ref->objectid != objectid || > - data_ref->offset != offset) { > + ref_owner != objectid || ref_offset != offset) { > ret = 1; > break; > } > diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h > index e6cee75c384c..89fa96fd95b4 100644 > --- a/include/trace/events/btrfs.h > +++ b/include/trace/events/btrfs.h > @@ -17,7 +17,6 @@ struct btrfs_file_extent_item; > struct btrfs_ordered_extent; > struct btrfs_delayed_ref_node; > struct btrfs_delayed_tree_ref; > -struct btrfs_delayed_data_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 98a0cf68d198..eb9f2f078a26 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -947,12 +947,9 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, } case BTRFS_EXTENT_DATA_REF_KEY: { /* NORMAL INDIRECT DATA backref */ - struct btrfs_delayed_data_ref *ref; - ref = btrfs_delayed_node_to_data_ref(node); - - key.objectid = ref->objectid; + key.objectid = btrfs_delayed_ref_owner(node); key.type = BTRFS_EXTENT_DATA_KEY; - key.offset = ref->offset; + key.offset = btrfs_delayed_ref_offset(node); /* * If we have a share check context and a reference for diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index d85bc31f2e57..839c64d5a12d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1543,11 +1543,9 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans, bool insert_reserved) { int ret = 0; - struct btrfs_delayed_data_ref *ref; u64 parent = 0; u64 flags = 0; - ref = btrfs_delayed_node_to_data_ref(node); trace_run_delayed_data_ref(trans->fs_info, node); if (node->type == BTRFS_SHARED_DATA_REF_KEY) @@ -1562,6 +1560,8 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans, .is_inc = true, .generation = trans->transid, }; + u64 owner = btrfs_delayed_ref_owner(node); + u64 offset = btrfs_delayed_ref_offset(node); if (extent_op) flags |= extent_op->flags_to_set; @@ -1571,9 +1571,9 @@ static int run_delayed_data_ref(struct btrfs_trans_handle *trans, key.offset = node->num_bytes; ret = alloc_reserved_file_extent(trans, parent, node->ref_root, - flags, ref->objectid, - ref->offset, &key, - node->ref_mod, href->owning_root); + flags, owner, offset, &key, + node->ref_mod, + href->owning_root); free_head_ref_squota_rsv(trans->fs_info, href); if (!ret) ret = btrfs_record_squota_delta(trans->fs_info, &delta); @@ -2258,7 +2258,6 @@ static noinline int check_delayed_ref(struct btrfs_root *root, { struct btrfs_delayed_ref_head *head; struct btrfs_delayed_ref_node *ref; - struct btrfs_delayed_data_ref *data_ref; struct btrfs_delayed_ref_root *delayed_refs; struct btrfs_transaction *cur_trans; struct rb_node *node; @@ -2312,6 +2311,9 @@ static noinline int check_delayed_ref(struct btrfs_root *root, */ for (node = rb_first_cached(&head->ref_tree); node; node = rb_next(node)) { + u64 ref_owner; + u64 ref_offset; + ref = rb_entry(node, struct btrfs_delayed_ref_node, ref_node); /* If it's a shared ref we know a cross reference exists */ if (ref->type != BTRFS_EXTENT_DATA_REF_KEY) { @@ -2319,15 +2321,15 @@ static noinline int check_delayed_ref(struct btrfs_root *root, break; } - data_ref = btrfs_delayed_node_to_data_ref(ref); + ref_owner = btrfs_delayed_ref_owner(ref); + ref_offset = btrfs_delayed_ref_offset(ref); /* * If our ref doesn't match the one we're currently looking at * then we have a cross reference. */ if (ref->ref_root != root->root_key.objectid || - data_ref->objectid != objectid || - data_ref->offset != offset) { + ref_owner != objectid || ref_offset != offset) { ret = 1; break; } diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index e6cee75c384c..89fa96fd95b4 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -17,7 +17,6 @@ struct btrfs_file_extent_item; struct btrfs_ordered_extent; struct btrfs_delayed_ref_node; struct btrfs_delayed_tree_ref; -struct btrfs_delayed_data_ref; struct btrfs_delayed_ref_head; struct btrfs_block_group; struct btrfs_free_cluster;
Now that most of our elements are inside of btrfs_delayed_ref_node directly and we have helpers for the delayed_data_ref bits, go ahead and remove all direct usage of btrfs_delayed_data_ref and use the helpers where needed. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/backref.c | 7 ++----- fs/btrfs/extent-tree.c | 20 +++++++++++--------- include/trace/events/btrfs.h | 1 - 3 files changed, 13 insertions(+), 15 deletions(-)