public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Johannes Thumshirn <jth@kernel.org>, linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: Re: [PATCH] btrfs: zoned: use filesystem size not disk size for reclaim decision
Date: Tue, 20 May 2025 11:31:46 +0200	[thread overview]
Message-ID: <be9fb855-29f1-41b9-a6ec-7e458ea38608@kernel.org> (raw)
In-Reply-To: <ce29d9ec1af7412e3e3e481e2fc3fb23842dca23.1747725440.git.johannes.thumshirn@wdc.com>

On 2025/05/20 9:20, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> When deciding if a zoned filesystem is reaching the threshold to reclaim
> data block-groups, look at the size of the filesystem not to potentially
> total available size  of all drives in the filesystem.
> 
> Especially if a filesystem was create with mkfs' -b option, constraining
> it to only a portion of the block device, the numbers won't match and
> potentially garbage collection is kicking in too late.
> 
> Fixes: 3687fcb0752a ("btrfs: zoned: make auto-reclaim less aggressive")
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Tested-by: Damien Le Moal <dlemoal@kernel.org>


> ---
>  fs/btrfs/zoned.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index b5b0156d5b95..19710634d63f 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -2465,8 +2465,8 @@ bool btrfs_zoned_should_reclaim(const struct btrfs_fs_info *fs_info)
>  {
>  	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
>  	struct btrfs_device *device;
> +	u64 total = btrfs_super_total_bytes(fs_info->super_copy);
>  	u64 used = 0;
> -	u64 total = 0;
>  	u64 factor;
>  
>  	ASSERT(btrfs_is_zoned(fs_info));
> @@ -2479,7 +2479,6 @@ bool btrfs_zoned_should_reclaim(const struct btrfs_fs_info *fs_info)
>  		if (!device->bdev)
>  			continue;
>  
> -		total += device->disk_total_bytes;
>  		used += device->bytes_used;
>  	}
>  	mutex_unlock(&fs_devices->device_list_mutex);


-- 
Damien Le Moal
Western Digital Research

      reply	other threads:[~2025-05-20  9:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20  7:20 [PATCH] btrfs: zoned: use filesystem size not disk size for reclaim decision Johannes Thumshirn
2025-05-20  9:31 ` Damien Le Moal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be9fb855-29f1-41b9-a6ec-7e458ea38608@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=dsterba@suse.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=jth@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox