* [PATCH] btrfs: prevent __btrfs_dump_space_info() to underflow its free space
@ 2021-09-16 12:43 Qu Wenruo
2021-09-16 13:40 ` Anand Jain
2021-09-17 10:37 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2021-09-16 12:43 UTC (permalink / raw)
To: linux-btrfs; +Cc: Eli V
It's not uncommon where __btrfs_dump_space_info() get called
under over-commit situations.
In that case free space would underflow as total allocated space is not
enough to handle all the over-committed space.
Such underflow values can sometimes cause confusion for users enabled
enospc_debug mount option, and takes some seconds for developers to
convert the underflow value to signed result.
Just output the free space as s64 to avoid such problem.
Reported-by: Eli V <eliventer@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/CAJtFHUSy4zgyhf-4d9T+KdJp9w=UgzC2A0V=VtmaeEpcGgm1-Q@mail.gmail.com/
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/space-info.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 5ada02e0e629..e9a562d96ba6 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -414,9 +414,9 @@ static void __btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
{
lockdep_assert_held(&info->lock);
- btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull",
+ btrfs_info(fs_info, "space_info %llu has %lld free, is %sfull",
info->flags,
- info->total_bytes - btrfs_space_info_used(info, true),
+ (s64)(info->total_bytes - btrfs_space_info_used(info, true)),
info->full ? "" : "not ");
btrfs_info(fs_info,
"space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu zone_unusable=%llu",
--
2.33.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: prevent __btrfs_dump_space_info() to underflow its free space
2021-09-16 12:43 [PATCH] btrfs: prevent __btrfs_dump_space_info() to underflow its free space Qu Wenruo
@ 2021-09-16 13:40 ` Anand Jain
2021-09-17 10:37 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2021-09-16 13:40 UTC (permalink / raw)
To: Qu Wenruo, linux-btrfs; +Cc: Eli V
On 16/09/2021 20:43, Qu Wenruo wrote:
> It's not uncommon where __btrfs_dump_space_info() get called
> under over-commit situations.
>
> In that case free space would underflow as total allocated space is not
> enough to handle all the over-committed space.
>
> Such underflow values can sometimes cause confusion for users enabled
> enospc_debug mount option, and takes some seconds for developers to
> convert the underflow value to signed result.
>
> Just output the free space as s64 to avoid such problem.
Yeah. I don't see any reason not to.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Thanks, Anand
>
> Reported-by: Eli V <eliventer@gmail.com>
> Link: https://lore.kernel.org/linux-btrfs/CAJtFHUSy4zgyhf-4d9T+KdJp9w=UgzC2A0V=VtmaeEpcGgm1-Q@mail.gmail.com/
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/space-info.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
> index 5ada02e0e629..e9a562d96ba6 100644
> --- a/fs/btrfs/space-info.c
> +++ b/fs/btrfs/space-info.c
> @@ -414,9 +414,9 @@ static void __btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
> {
> lockdep_assert_held(&info->lock);
>
> - btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull",
> + btrfs_info(fs_info, "space_info %llu has %lld free, is %sfull",
> info->flags,
> - info->total_bytes - btrfs_space_info_used(info, true),
> + (s64)(info->total_bytes - btrfs_space_info_used(info, true)),
> info->full ? "" : "not ");
> btrfs_info(fs_info,
> "space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu zone_unusable=%llu",
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: prevent __btrfs_dump_space_info() to underflow its free space
2021-09-16 12:43 [PATCH] btrfs: prevent __btrfs_dump_space_info() to underflow its free space Qu Wenruo
2021-09-16 13:40 ` Anand Jain
@ 2021-09-17 10:37 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-09-17 10:37 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs, Eli V
On Thu, Sep 16, 2021 at 08:43:29PM +0800, Qu Wenruo wrote:
> It's not uncommon where __btrfs_dump_space_info() get called
> under over-commit situations.
>
> In that case free space would underflow as total allocated space is not
> enough to handle all the over-committed space.
>
> Such underflow values can sometimes cause confusion for users enabled
> enospc_debug mount option, and takes some seconds for developers to
> convert the underflow value to signed result.
>
> Just output the free space as s64 to avoid such problem.
>
> Reported-by: Eli V <eliventer@gmail.com>
> Link: https://lore.kernel.org/linux-btrfs/CAJtFHUSy4zgyhf-4d9T+KdJp9w=UgzC2A0V=VtmaeEpcGgm1-Q@mail.gmail.com/
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-17 10:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 12:43 [PATCH] btrfs: prevent __btrfs_dump_space_info() to underflow its free space Qu Wenruo
2021-09-16 13:40 ` Anand Jain
2021-09-17 10:37 ` David Sterba
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.