diff mbox series

btrfs: zoned: clear data relocation bg on zone finish

Message ID 50bfb0a3d3bedc7038f2e1926c95aa71a3260e75.1638434808.git.johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: zoned: clear data relocation bg on zone finish | expand

Commit Message

Johannes Thumshirn Dec. 2, 2021, 8:47 a.m. UTC
When finishing a zone that is used by a dedicated data relocation
block_group, also remove its reference from fs_info, so we're not trying
to use a full block_group for allocations during data relocation, which
will always fail.

The result is we're not making any forward progress and end up in a
deadlock situation.

Cc: Naohiro Aota <Naohiro.Aota@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/zoned.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Naohiro Aota Dec. 2, 2021, 12:55 p.m. UTC | #1
On Thu, Dec 02, 2021 at 12:47:14AM -0800, Johannes Thumshirn wrote:
> When finishing a zone that is used by a dedicated data relocation
> block_group, also remove its reference from fs_info, so we're not trying
> to use a full block_group for allocations during data relocation, which
> will always fail.
> 
> The result is we're not making any forward progress and end up in a
> deadlock situation.
> 
> Cc: Naohiro Aota <Naohiro.Aota@wdc.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Looks good.
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>

> ---
>  fs/btrfs/zoned.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index c917867a4261..9cdef5e8f6b7 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -1915,6 +1915,7 @@ int btrfs_zone_finish(struct btrfs_block_group *block_group)
>  	block_group->alloc_offset = block_group->zone_capacity;
>  	block_group->free_space_ctl->free_space = 0;
>  	btrfs_clear_treelog_bg(block_group);
> +	btrfs_clear_data_reloc_bg(block_group);
>  	spin_unlock(&block_group->lock);
>  
>  	ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH,
> @@ -1997,6 +1998,7 @@ void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 len
>  	ASSERT(block_group->alloc_offset == block_group->zone_capacity);
>  	ASSERT(block_group->free_space_ctl->free_space == 0);
>  	btrfs_clear_treelog_bg(block_group);
> +	btrfs_clear_data_reloc_bg(block_group);
>  	spin_unlock(&block_group->lock);
>  
>  	map = block_group->physical_map;
> -- 
> 2.31.1
>
David Sterba Dec. 6, 2021, 5:59 p.m. UTC | #2
On Thu, Dec 02, 2021 at 12:47:14AM -0800, Johannes Thumshirn wrote:
> When finishing a zone that is used by a dedicated data relocation
> block_group, also remove its reference from fs_info, so we're not trying
> to use a full block_group for allocations during data relocation, which
> will always fail.
> 
> The result is we're not making any forward progress and end up in a
> deadlock situation.
> 
> Cc: Naohiro Aota <Naohiro.Aota@wdc.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index c917867a4261..9cdef5e8f6b7 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1915,6 +1915,7 @@  int btrfs_zone_finish(struct btrfs_block_group *block_group)
 	block_group->alloc_offset = block_group->zone_capacity;
 	block_group->free_space_ctl->free_space = 0;
 	btrfs_clear_treelog_bg(block_group);
+	btrfs_clear_data_reloc_bg(block_group);
 	spin_unlock(&block_group->lock);
 
 	ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH,
@@ -1997,6 +1998,7 @@  void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 len
 	ASSERT(block_group->alloc_offset == block_group->zone_capacity);
 	ASSERT(block_group->free_space_ctl->free_space == 0);
 	btrfs_clear_treelog_bg(block_group);
+	btrfs_clear_data_reloc_bg(block_group);
 	spin_unlock(&block_group->lock);
 
 	map = block_group->physical_map;