All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Anufriev <dotdot@yandex-team.ru>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, jack@suse.cz, dmtrmonakhov@yandex-team.ru,
	dotdot@yandex-team.ru
Subject: [PATCH] ext4: compare inode's i_projid with EXT4_DEF_PROJID rather than check EXT4_INODE_PROJINHERIT flag
Date: Tue,  7 Dec 2021 16:18:42 +0300	[thread overview]
Message-ID: <1638883122-8953-1-git-send-email-dotdot@yandex-team.ru> (raw)

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@yandex-team.ru>
---
 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


             reply	other threads:[~2021-12-07 13:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-07 13:18 Roman Anufriev [this message]
2021-12-07 14:05 ` [PATCH] ext4: compare inode's i_projid with EXT4_DEF_PROJID rather than check EXT4_INODE_PROJINHERIT flag Roman Anufriev
2021-12-07 19:34   ` Theodore Y. Ts'o
2021-12-09 22:53     ` Andreas Dilger
2021-12-09 23:30       ` Dave Chinner
2021-12-10 19:53         ` Roman Anufriev
2021-12-10 19:53       ` Roman Anufriev
2021-12-11  0:49       ` Darrick J. Wong
2021-12-10 19:55     ` Roman Anufriev
2021-12-14  5:06       ` Dave Chinner
2021-12-17  0:17         ` Andreas Dilger
2021-12-17  2:39           ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1638883122-8953-1-git-send-email-dotdot@yandex-team.ru \
    --to=dotdot@yandex-team.ru \
    --cc=dmtrmonakhov@yandex-team.ru \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.