From: Boris Burkov <boris@bur.io>
To: Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: do not subtract delalloc from avail bytes
Date: Fri, 12 Jul 2024 13:11:26 -0700 [thread overview]
Message-ID: <20240712201126.GA3474272@zen.localdomain> (raw)
In-Reply-To: <5075b1ac071c767c182ddc87b228df6147ef7bc4.1720710227.git.naohiro.aota@wdc.com>
On Fri, Jul 12, 2024 at 12:05:32AM +0900, Naohiro Aota wrote:
> The block group's avail bytes printed when dumping a space info subtract
> the delalloc_bytes. However, as shown in btrfs_add_reserved_bytes() and
> btrfs_free_reserved_bytes(), it is added or subtracted along with
> "reserved" for the delalloc case, which means the "delalloc_bytes" is a
> part of the "reserved" bytes. So, excluding it to calculate the avail space
> counts delalloc_bytes twice, which can lead to an invalid result.
>
> Fixes: e50b122b832b ("btrfs: print available space for a block group when dumping a space info")
> CC: stable@vger.kernel.org # 6.6+
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Nice catch.
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
> fs/btrfs/space-info.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index 9ac94d3119e8..c1d9d3664400 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -583,8 +583,7 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
>
> spin_lock(&cache->lock);
> avail = cache->length - cache->used - cache->pinned -
> - cache->reserved - cache->delalloc_bytes -
> - cache->bytes_super - cache->zone_unusable;
> + cache->reserved - cache->bytes_super - cache->zone_unusable;
> btrfs_info(fs_info,
> "block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %llu delalloc %llu super %llu zone_unusable (%llu bytes available) %s",
> cache->start, cache->length, cache->used, cache->pinned,
> --
> 2.45.2
>
prev parent reply other threads:[~2024-07-12 20:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 15:05 [PATCH] btrfs: do not subtract delalloc from avail bytes Naohiro Aota
2024-07-12 20:11 ` Boris Burkov [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=20240712201126.GA3474272@zen.localdomain \
--to=boris@bur.io \
--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