diff mbox series

[06/14] btrfs: use btrfs_read_node_slot in replace_path

Message ID 026ed684d026b3d792f1bab60bd3d63be28acd65.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/relocation.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

Comments

Filipe Manana Nov. 6, 2020, 11:53 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/relocation.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 4d5cb593b674..465f5b4d3233 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -1218,8 +1218,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
>
>         parent = eb;
>         while (1) {
> -               struct btrfs_key first_key;
> -
>                 level = btrfs_header_level(parent);
>                 BUG_ON(level < lowest_level);
>
> @@ -1235,7 +1233,6 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
>                 old_bytenr = btrfs_node_blockptr(parent, slot);
>                 blocksize = fs_info->nodesize;
>                 old_ptr_gen = btrfs_node_ptr_generation(parent, slot);
> -               btrfs_node_key_to_cpu(parent, &first_key, slot);
>
>                 if (level <= max_level) {
>                         eb = path->nodes[level];
> @@ -1260,15 +1257,10 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
>                                 break;
>                         }
>
> -                       eb = read_tree_block(fs_info, old_bytenr, old_ptr_gen,
> -                                            level - 1, &first_key);
> +                       eb = btrfs_read_node_slot(parent, slot);
>                         if (IS_ERR(eb)) {
>                                 ret = PTR_ERR(eb);
>                                 break;
> -                       } else if (!extent_buffer_uptodate(eb)) {
> -                               ret = -EIO;
> -                               free_extent_buffer(eb);
> -                               break;
>                         }
>                         btrfs_tree_lock(eb);
>                         if (cow) {
> --
> 2.26.2
>
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 4d5cb593b674..465f5b4d3233 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1218,8 +1218,6 @@  int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
 
 	parent = eb;
 	while (1) {
-		struct btrfs_key first_key;
-
 		level = btrfs_header_level(parent);
 		BUG_ON(level < lowest_level);
 
@@ -1235,7 +1233,6 @@  int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
 		old_bytenr = btrfs_node_blockptr(parent, slot);
 		blocksize = fs_info->nodesize;
 		old_ptr_gen = btrfs_node_ptr_generation(parent, slot);
-		btrfs_node_key_to_cpu(parent, &first_key, slot);
 
 		if (level <= max_level) {
 			eb = path->nodes[level];
@@ -1260,15 +1257,10 @@  int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
 				break;
 			}
 
-			eb = read_tree_block(fs_info, old_bytenr, old_ptr_gen,
-					     level - 1, &first_key);
+			eb = btrfs_read_node_slot(parent, slot);
 			if (IS_ERR(eb)) {
 				ret = PTR_ERR(eb);
 				break;
-			} else if (!extent_buffer_uptodate(eb)) {
-				ret = -EIO;
-				free_extent_buffer(eb);
-				break;
 			}
 			btrfs_tree_lock(eb);
 			if (cow) {