diff mbox series

[2/2] btrfs: reserve new relocation zone after successful relocation

Message ID 20240514-zoned-gc-v1-2-109f1a6c7447@kernel.org (mailing list archive)
State New, archived
Headers show
Series btrfs: zoned: always set aside a zone for relocation | expand

Commit Message

Johannes Thumshirn May 14, 2024, 9:13 p.m. UTC
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

After we've committed a relocation transaction, we know we have just freed
up space. Set it as hint for the next relocation.

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

Comments

Naohiro Aota May 15, 2024, 6:01 p.m. UTC | #1
On Tue, May 14, 2024 at 11:13:22PM +0200, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> After we've committed a relocation transaction, we know we have just freed
> up space. Set it as hint for the next relocation.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/relocation.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 8b24bb5a0aa1..d943abf5cb33 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -3808,9 +3808,13 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
>  		err = PTR_ERR(trans);
>  		goto out_free;
>  	}
> +
>  	ret = btrfs_commit_transaction(trans);
>  	if (ret && !err)
>  		err = ret;
> +
> +	/* We know we have just freed space, set it as hint for the next relocation */
> +	btrfs_reserve_relocation_zone(fs_info);

With "if (!err)"? We definitely bail out fast in an error case.

>  out_free:
>  	ret = clean_dirty_subvols(rc);
>  	if (ret < 0 && !err)
> 
> -- 
> 2.35.3
>
Johannes Thumshirn May 15, 2024, 6:21 p.m. UTC | #2
On 15.05.24 12:01, Naohiro Aota wrote:
>> +
>> +	/* We know we have just freed space, set it as hint for the next relocation */
>> +	btrfs_reserve_relocation_zone(fs_info);
> 
> With "if (!err)"? We definitely bail out fast in an error case.
> 

Right, I'll fix it in the next version.
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 8b24bb5a0aa1..d943abf5cb33 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3808,9 +3808,13 @@  static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
 		err = PTR_ERR(trans);
 		goto out_free;
 	}
+
 	ret = btrfs_commit_transaction(trans);
 	if (ret && !err)
 		err = ret;
+
+	/* We know we have just freed space, set it as hint for the next relocation */
+	btrfs_reserve_relocation_zone(fs_info);
 out_free:
 	ret = clean_dirty_subvols(rc);
 	if (ret < 0 && !err)