Re: [PATCH] ext4: compare inode's i_projid with EXT4_DEF_PROJID rather than check EXT4_INODE_PROJINHERIT flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Tue, 7 Dec 2021, Roman Anufriev wrote:

Commit 7ddf79a10395 ("ext4: only set project inherit bit for directory")
removes EXT4_INODE_PROJINHERIT flag from regular files. This makes
ext4_statfs() output incorrect (function does not apply quota limits
on used/available space, etc) when called on dentry of regular file
with project quota enabled.

This patch fixes this by comparing inode's i_projid with
EXT4_DEF_PROJID, as there is no point in calling ext4_statfs_project()
for inode with default project id.

$ sudo project_quota info dir/
project   2147516417
usage     4096
limit     5242880
inodes    4
ilimit    0
$ sudo project_quota info dir/file | grep project
project   2147516417
$ df -h /dev/loop0
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      232M  2.1M  214M   1% /mnt/ext4img

without patch:
$ df -h dir/
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      5.0M  4.0K  5.0M   1% /mnt/ext4img
$ df -h dir/file
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      232M  2.1M  214M   1% /mnt/ext4img

with patch:
$ df -h dir/
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      5.0M  4.0K  5.0M   1% /mnt/ext4img
$ df -h dir/file
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      5.0M  4.0K  5.0M   1% /mnt/ext4img

Signed-off-by: Roman Anufriev <dotdot@xxxxxxxxxxxxxx>
---
fs/ext4/super.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 79b6a0c..682d675 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -6074,6 +6074,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
	struct super_block *sb = dentry->d_sb;
	struct ext4_sb_info *sbi = EXT4_SB(sb);
	struct ext4_super_block *es = sbi->s_es;
+	kprojid_t kprojid;
	ext4_fsblk_t overhead = 0, resv_blocks;
	s64 bfree;
	resv_blocks = EXT4_C2B(sbi, atomic64_read(&sbi->s_resv_clusters));
@@ -6098,9 +6099,10 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
	buf->f_fsid = uuid_to_fsid(es->s_uuid);

#ifdef CONFIG_QUOTA
-	if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) &&
+	kprojid = EXT4_I(dentry->d_inode)->i_projid;
+	if ((from_kprojid(current_user_ns(), kprojid) != EXT4_DEF_PROJID) &&
	    sb_has_quota_limits_enabled(sb, PRJQUOTA))
-		ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf);
+		ext4_statfs_project(sb, kprojid, buf);
#endif
	return 0;
}
--
2.7.4



+Cc Wang Shilong <wshilong@xxxxxxx> author of 7ddf79a10395



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux