* [PATCH] btrfs: do not subtract delalloc from avail bytes
@ 2024-07-11 15:05 Naohiro Aota
2024-07-12 20:11 ` Boris Burkov
0 siblings, 1 reply; 2+ messages in thread
From: Naohiro Aota @ 2024-07-11 15:05 UTC (permalink / raw)
To: linux-btrfs; +Cc: Naohiro Aota
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] btrfs: do not subtract delalloc from avail bytes
2024-07-11 15:05 [PATCH] btrfs: do not subtract delalloc from avail bytes Naohiro Aota
@ 2024-07-12 20:11 ` Boris Burkov
0 siblings, 0 replies; 2+ messages in thread
From: Boris Burkov @ 2024-07-12 20:11 UTC (permalink / raw)
To: Naohiro Aota; +Cc: linux-btrfs
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-12 20:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-11 15:05 [PATCH] btrfs: do not subtract delalloc from avail bytes Naohiro Aota
2024-07-12 20:11 ` Boris Burkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox