diff mbox series

[v11,05/40] btrfs: release path before calling into btrfs_load_block_group_zone_info

Message ID 8fa3073375cf26759f9c5d3ce083c64d573ad9a6.1608608848.git.naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: zoned block device support | expand

Commit Message

Naohiro Aota Dec. 22, 2020, 3:48 a.m. UTC
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Since we have no write pointer in conventional zones, we cannot determine
allocation offset from it. Instead, we set the allocation offset after the
highest addressed extent. This is done by reading the extent tree in
btrfs_load_block_group_zone_info(). However, this function is called from
btrfs_read_block_groups(), so the read lock for the tree node can
recursively taken.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/block-group.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Josef Bacik Jan. 11, 2021, 8:01 p.m. UTC | #1
On 12/21/20 10:48 PM, Naohiro Aota wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> Since we have no write pointer in conventional zones, we cannot determine
> allocation offset from it. Instead, we set the allocation offset after the
> highest addressed extent. This is done by reading the extent tree in
> btrfs_load_block_group_zone_info(). However, this function is called from
> btrfs_read_block_groups(), so the read lock for the tree node can
> recursively taken.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>   fs/btrfs/block-group.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index b8bbdd95743e..69e1b24bbbad 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1839,6 +1839,7 @@ static int read_one_block_group(struct btrfs_fs_info *info,
>   		return -ENOMEM;
>   
>   	read_block_group_item(cache, path, key);
> +	btrfs_release_path(path);
>   
>   	set_free_space_tree_thresholds(cache);
>   
> @@ -2009,7 +2010,6 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
>   			goto error;
>   		key.objectid += key.offset;
>   		key.offset = 0;
> -		btrfs_release_path(path);
>   	}
>   	btrfs_release_path(path);
>   
> 

Instead why don't we just read in the bgi into the stack, and pass the pointer 
into read_one_block_group(), drop the path before calling read_one_block_group? 
  We don't use the path in read_one_block_group, there's no reason to pass it 
in.  It'll fix your problem and make it a little cleaner.  Thanks,

Josef
Johannes Thumshirn Jan. 12, 2021, 8:05 a.m. UTC | #2
On 11/01/2021 21:01, Josef Bacik wrote:
> Instead why don't we just read in the bgi into the stack, and pass the pointer 
> into read_one_block_group(), drop the path before calling read_one_block_group? 
>   We don't use the path in read_one_block_group, there's no reason to pass it 
> in.  It'll fix your problem and make it a little cleaner.

Good point, I'll fix it up.
diff mbox series

Patch

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index b8bbdd95743e..69e1b24bbbad 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1839,6 +1839,7 @@  static int read_one_block_group(struct btrfs_fs_info *info,
 		return -ENOMEM;
 
 	read_block_group_item(cache, path, key);
+	btrfs_release_path(path);
 
 	set_free_space_tree_thresholds(cache);
 
@@ -2009,7 +2010,6 @@  int btrfs_read_block_groups(struct btrfs_fs_info *info)
 			goto error;
 		key.objectid += key.offset;
 		key.offset = 0;
-		btrfs_release_path(path);
 	}
 	btrfs_release_path(path);