summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2023-09-18 10:34:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-06 14:57:04 +0200
commitd6a749e4cab2bb51950baf0dac87822db8833bc9 (patch)
tree27e0405749d0428cf2ddb8f56ab63ff50cabfaf1
parentf3ad8874541d671d4ec21581196bd3f38973805b (diff)
downloadlinux-stable-d6a749e4cab2bb51950baf0dac87822db8833bc9.tar.gz
linux-stable-d6a749e4cab2bb51950baf0dac87822db8833bc9.tar.bz2
linux-stable-d6a749e4cab2bb51950baf0dac87822db8833bc9.zip
btrfs: properly report 0 avail for very full file systems
commit 58bfe2ccec5f9f137b41dd38f335290dcc13cd5c upstream. A user reported some issues with smaller file systems that get very full. While investigating this issue I noticed that df wasn't showing 100% full, despite having 0 chunk space and having < 1MiB of available metadata space. This turns out to be an overflow issue, we're doing: total_available_metadata_space - SZ_4M < global_block_rsv_size to determine if there's not enough space to make metadata allocations, which overflows if total_available_metadata_space is < 4M. Fix this by checking to see if our available space is greater than the 4M threshold. This makes df properly report 100% usage on the file system. CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Josef Bacik <josef@toxicpanda.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>
-rw-r--r--fs/btrfs/super.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 6438300fa246..582b71b7fa77 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2418,7 +2418,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
* calculated f_bavail.
*/
if (!mixed && block_rsv->space_info->full &&
- total_free_meta - thresh < block_rsv->size)
+ (total_free_meta < thresh || total_free_meta - thresh < block_rsv->size))
buf->f_bavail = 0;
buf->f_type = BTRFS_SUPER_MAGIC;