diff mbox series

[10/14] btrfs: use btrfs_read_node_slot in btrfs_qgroup_trace_subtree

Message ID 4e8c871927bd508d2226eefc65c977b252377aa0.1604591048.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Set the lockdep class on eb's at allocation time | expand

Commit Message

Josef Bacik Nov. 5, 2020, 3:45 p.m. UTC
We're open-coding btrfs_read_node_slot() here, replace with the helper.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/qgroup.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Comments

Filipe Manana Nov. 6, 2020, 11:55 a.m. UTC | #1
On Thu, Nov 5, 2020 at 3:47 PM Josef Bacik <josef@toxicpanda.com> wrote:
>
> We're open-coding btrfs_read_node_slot() here, replace with the helper.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

I couldn't get anymore the lockdep splat I reported before (after
applying the whole patchset of course), it used to happen very often
with btrfs/033.

Looks good, thanks.

> ---
>  fs/btrfs/qgroup.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 8d112ff7b5ae..25e3b7105e8a 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -2182,30 +2182,21 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
>         level = root_level;
>         while (level >= 0) {
>                 if (path->nodes[level] == NULL) {
> -                       struct btrfs_key first_key;
>                         int parent_slot;
> -                       u64 child_gen;
>                         u64 child_bytenr;
>
>                         /*
> -                        * We need to get child blockptr/gen from parent before
> -                        * we can read it.
> +                        * We need to get child blockptr from parent before we
> +                        * can read it.
>                           */
>                         eb = path->nodes[level + 1];
>                         parent_slot = path->slots[level + 1];
>                         child_bytenr = btrfs_node_blockptr(eb, parent_slot);
> -                       child_gen = btrfs_node_ptr_generation(eb, parent_slot);
> -                       btrfs_node_key_to_cpu(eb, &first_key, parent_slot);
>
> -                       eb = read_tree_block(fs_info, child_bytenr, child_gen,
> -                                            level, &first_key);
> +                       eb = btrfs_read_node_slot(eb, parent_slot);
>                         if (IS_ERR(eb)) {
>                                 ret = PTR_ERR(eb);
>                                 goto out;
> -                       } else if (!extent_buffer_uptodate(eb)) {
> -                               free_extent_buffer(eb);
> -                               ret = -EIO;
> -                               goto out;
>                         }
>
>                         path->nodes[level] = eb;
> --
> 2.26.2
>
diff mbox series

Patch

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 8d112ff7b5ae..25e3b7105e8a 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2182,30 +2182,21 @@  int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
 	level = root_level;
 	while (level >= 0) {
 		if (path->nodes[level] == NULL) {
-			struct btrfs_key first_key;
 			int parent_slot;
-			u64 child_gen;
 			u64 child_bytenr;
 
 			/*
-			 * We need to get child blockptr/gen from parent before
-			 * we can read it.
+			 * We need to get child blockptr from parent before we
+			 * can read it.
 			  */
 			eb = path->nodes[level + 1];
 			parent_slot = path->slots[level + 1];
 			child_bytenr = btrfs_node_blockptr(eb, parent_slot);
-			child_gen = btrfs_node_ptr_generation(eb, parent_slot);
-			btrfs_node_key_to_cpu(eb, &first_key, parent_slot);
 
-			eb = read_tree_block(fs_info, child_bytenr, child_gen,
-					     level, &first_key);
+			eb = btrfs_read_node_slot(eb, parent_slot);
 			if (IS_ERR(eb)) {
 				ret = PTR_ERR(eb);
 				goto out;
-			} else if (!extent_buffer_uptodate(eb)) {
-				free_extent_buffer(eb);
-				ret = -EIO;
-				goto out;
 			}
 
 			path->nodes[level] = eb;