All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Naohiro Aota" <Naohiro.Aota@wdc.com>
To: "Johannes Thumshirn" <johannes.thumshirn@wdc.com>,
	<linux-btrfs@vger.kernel.org>
Cc: "Hans Holmberg" <Hans.Holmberg@wdc.com>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Damien Le Moal" <dlemoal@kernel.org>,
	"Christoph Hellwig" <hch@lst.de>
Subject: Re: [PATCH 02/13] btrfs: zoned: don't count in-flight data as available in statfs
Date: Fri, 16 Oct 2026 16:01:43 +0900	[thread overview]
Message-ID: <DM62IP78U8F2.SBLRTEQNLPQ6@wdc.com> (raw)
In-Reply-To: <20261014120353.757931-3-johannes.thumshirn@wdc.com>

On Wed Oct 14, 2026 at 9:03 PM JST, Johannes Thumshirn wrote:
> On a zoned filesystem GC makes freed space usable again only at zone
> granularity and after the in-flight writes landed.
>
> Don't promise space that is already reserved by delalloc or for extents
> being written to the user in statfs.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/super.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 7fabb775d4e3..cbc1662abbff 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1727,6 +1727,20 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
>  	return 0;
>  }
>  
> +static u64 btrfs_zoned_calc_inflight(struct btrfs_space_info *space_info)
> +{
> +	u64 profile = btrfs_data_alloc_profile(space_info->fs_info);
> +	u64 inflight;
> +
> +	spin_lock(&space_info->lock);
> +	inflight = space_info->bytes_may_use + space_info->bytes_reserved;
> +	spin_unlock(&space_info->lock);
> +
> +	inflight *= btrfs_bg_type_to_factor(profile);
> +
> +	return inflight;
> +}
> +

I'm not really sure of this. The bytes_may_use can take a lot bytes for
the worst case tree update scenario. And, that is not really an inflight
amount...


>  /*
>   * Calculate numbers for 'df', pessimistic in case of mixed raid profiles.
>   *
> @@ -1766,6 +1780,12 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
>  			total_free_data -=
>  				btrfs_account_ro_block_groups_free_space(found);
>  
> +			if (btrfs_is_zoned(fs_info)) {
> +				u64 inflight = btrfs_zoned_calc_inflight(found);
> +
> +				total_free_data -= min(total_free_data, inflight);
> +			}
> +
>  			for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) {
>  				if (!list_empty(&found->block_groups[i]))
>  					factor = btrfs_bg_type_to_factor(


  reply	other threads:[~2026-10-16  7:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 12:03 [PATCH 00/13] btrfs: zoned: rework zoned garbage collection Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 01/13] btrfs: zoned: wait for a running block group reclaim in RECLAIM_ZONES Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 02/13] btrfs: zoned: don't count in-flight data as available in statfs Johannes Thumshirn
2026-10-16  7:01   ` Naohiro Aota [this message]
2026-10-16  7:24     ` Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 03/13] btrfs: zoned: don't recheck the reclaim threshold of zoned block-groups Johannes Thumshirn
2026-10-16  7:47   ` Naohiro Aota
2026-10-14 12:03 ` [PATCH 04/13] btrfs: zoned: don't account superblock zones as available data space Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 05/13] btrfs: zoned: factor out resetting a block group in place Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 06/13] btrfs: zoned: prepare reserving the data relocation block group at runtime Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 07/13] btrfs: zoned: promote reset data block groups to the relocation target Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 08/13] btrfs: zoned: return finished relocation block groups to the data space_info Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 09/13] btrfs: zoned: reuse block groups emptied by reclaim as relocation target Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 10/13] btrfs: add btrfs_bg_type_to_num_stripes Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 11/13] btrfs: zoned: keep a zone free for relocation when allocating data chunks Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 12/13] btrfs: zoned: don't count the relocation zone reserve as available in statfs Johannes Thumshirn
2026-10-14 12:03 ` [PATCH 13/13] btrfs: zoned: provide zoned specific reclaim sweep Johannes Thumshirn

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=DM62IP78U8F2.SBLRTEQNLPQ6@wdc.com \
    --to=naohiro.aota@wdc.com \
    --cc=Hans.Holmberg@wdc.com \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.