[Devel] [PATCH rh8 3/9] ext4: Teach statfs to report reduced disk usage
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Mar 3 19:31:12 MSK 2021
From: "Maxim V. Patlasov" <MPatlasov at parallels.com>
The magic 9 in there came from 512 bytes - the i_blocks is accounted
in these units in any case.
(cherry picked from vz7 commit 4b10f27018d330d9e03e932a98a41a3e55da81fb)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
fs/ext4/super.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 663fb3ea9315..7a41751364ab 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5818,6 +5818,22 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
sb_has_quota_limits_enabled(sb, PRJQUOTA))
ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf);
#endif
+
+ if (sbi->s_balloon_ino) {
+ struct ext4_inode_info *ei;
+ blkcnt_t balloon_blocks;
+
+ balloon_blocks = sbi->s_balloon_ino->i_blocks;
+ ei = EXT4_I(sbi->s_balloon_ino);
+ spin_lock(&ei->i_block_reservation_lock);
+ balloon_blocks += ei->i_reserved_data_blocks;
+ spin_unlock(&ei->i_block_reservation_lock);
+
+ BUG_ON(sbi->s_balloon_ino->i_blkbits < 9);
+ buf->f_blocks -= balloon_blocks >>
+ (sbi->s_balloon_ino->i_blkbits - 9);
+ }
+
return 0;
}
--
2.28.0
More information about the Devel
mailing list