diff mbox series

[RFC,2/3] f2fs: show prjquota info on statfs for a file

Message ID 20191118050949.15629-2-cgxu519@mykernel.net
State New
Headers show
Series [RFC,1/3] ext4: show prjquota info on statfs for a file | expand

Commit Message

Chengguang Xu Nov. 18, 2019, 5:09 a.m. UTC
Currently we replace filesystem statistics using prjquota info
on statfs when specified directory has project id inherit flag.
However, statfs on a file(accurately non-dir) which is under the
project quota dir(with inherit flag) still shows whole filesystem
statistics. In container use case, it will give container user
inconsistent experience and cause confusion about available free
space.

Detail info like below:
We use project quota to limit disk space usage for a container
and run df command inside container.

Run df on a directory:

[root /]# df -h /etc/
Filesystem      Size  Used Avail Use% Mounted on
kataShared      1.0G   13M 1012M   2% /

Run df on a file:

[root /]# df -h /etc/exports
Filesystem      Size  Used Avail Use% Mounted on
kataShared      1.5T  778M  1.5T   1% /

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/f2fs/super.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1443cee15863..c5b9a92d606b 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1287,8 +1287,9 @@  static int f2fs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_fsid.val[1] = (u32)(id >> 32);
 
 #ifdef CONFIG_QUOTA
-	if (is_inode_flag_set(dentry->d_inode, FI_PROJ_INHERIT) &&
-			sb_has_quota_limits_enabled(sb, PRJQUOTA)) {
+	if ((is_inode_flag_set(dentry->d_inode, FI_PROJ_INHERIT) ||
+	     !S_ISDIR(dentry->d_inode->i_mode)) &&
+	    sb_has_quota_limits_enabled(sb, PRJQUOTA)) {
 		f2fs_statfs_project(sb, F2FS_I(dentry->d_inode)->i_projid, buf);
 	}
 #endif