[Devel] [PATCH RH9 3/6] ext4: Teach statfs to report reduced disk usage

Kirill Tkhai ktkhai at virtuozzo.com
Tue Oct 5 18:42:36 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>
Signed-off-by: Kirill Tkhai <ktkhai 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 03ade65fbe51..f09a2432a20e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -6290,6 +6290,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;
 }
 




More information about the Devel mailing list