aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext4/super.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 874dd25b7481..266174b268cc 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -4458,6 +4458,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
4458 struct ext4_sb_info *sbi = EXT4_SB(sb); 4458 struct ext4_sb_info *sbi = EXT4_SB(sb);
4459 struct ext4_super_block *es = sbi->s_es; 4459 struct ext4_super_block *es = sbi->s_es;
4460 u64 fsid; 4460 u64 fsid;
4461 s64 bfree;
4461 4462
4462 if (test_opt(sb, MINIX_DF)) { 4463 if (test_opt(sb, MINIX_DF)) {
4463 sbi->s_overhead_last = 0; 4464 sbi->s_overhead_last = 0;
@@ -4501,8 +4502,10 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
4501 buf->f_type = EXT4_SUPER_MAGIC; 4502 buf->f_type = EXT4_SUPER_MAGIC;
4502 buf->f_bsize = sb->s_blocksize; 4503 buf->f_bsize = sb->s_blocksize;
4503 buf->f_blocks = ext4_blocks_count(es) - sbi->s_overhead_last; 4504 buf->f_blocks = ext4_blocks_count(es) - sbi->s_overhead_last;
4504 buf->f_bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter) - 4505 bfree = percpu_counter_sum_positive(&sbi->s_freeblocks_counter) -
4505 percpu_counter_sum_positive(&sbi->s_dirtyblocks_counter); 4506 percpu_counter_sum_positive(&sbi->s_dirtyblocks_counter);
4507 /* prevent underflow in case that few free space is available */
4508 buf->f_bfree = max_t(s64, bfree, 0);
4506 buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es); 4509 buf->f_bavail = buf->f_bfree - ext4_r_blocks_count(es);
4507 if (buf->f_bfree < ext4_r_blocks_count(es)) 4510 if (buf->f_bfree < ext4_r_blocks_count(es))
4508 buf->f_bavail = 0; 4511 buf->f_bavail = 0;