]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: prevent __btrfs_dump_space_info() to underflow its free space
authorQu Wenruo <wqu@suse.com>
Thu, 16 Sep 2021 12:43:29 +0000 (20:43 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Sep 2021 08:09:22 +0000 (10:09 +0200)
commit3ea04ccd78cdc48f76823b9ce503629472c668d4
treec1cffcb81bc7b5f13681abf0ae4ff6e22cc9a9c9
parente53f83a89a28e36e077f40f458f1c887a46c0a4d
btrfs: prevent __btrfs_dump_space_info() to underflow its free space

commit 0619b7901473c380abc05d45cf9c70bee0707db3 upstream.

It's not uncommon where __btrfs_dump_space_info() gets 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/
CC: stable@vger.kernel.org # 5.4+
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/space-info.c