Linux-ext4 Archive on lore.kernel.org
 help / color / Atom feed
* [RFC PATCH 1/3] ext4: show prjquota info on statfs for a file
@ 2019-11-18  5:09 Chengguang Xu
  2019-11-18  5:09 ` [RFC PATCH 2/3] f2fs: " Chengguang Xu
  2019-11-18  5:09 ` [RFC PATCH 3/3] xfs: " Chengguang Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Chengguang Xu @ 2019-11-18  5:09 UTC (permalink / raw)
  To: linux-ext4, linux-kernel, linux-f2fs-devel, linux-xfs
  Cc: darrick.wong, jaegeuk, chao, tytso, adilger.kernel, Chengguang Xu

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/ext4/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index dd654e53ba3d..3fba22b54f5c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5607,7 +5607,8 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
 
 #ifdef CONFIG_QUOTA
-	if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) &&
+	if ((ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) ||
+	     !S_ISDIR(dentry->d_inode->i_mode)) &&
 	    sb_has_quota_limits_enabled(sb, PRJQUOTA))
 		ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf);
 #endif
-- 
2.20.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC PATCH 2/3] f2fs: show prjquota info on statfs for a file
  2019-11-18  5:09 [RFC PATCH 1/3] ext4: show prjquota info on statfs for a file Chengguang Xu
@ 2019-11-18  5:09 ` " Chengguang Xu
  2019-11-18  5:09 ` [RFC PATCH 3/3] xfs: " Chengguang Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Chengguang Xu @ 2019-11-18  5:09 UTC (permalink / raw)
  To: linux-ext4, linux-kernel, linux-f2fs-devel, linux-xfs
  Cc: darrick.wong, jaegeuk, chao, tytso, adilger.kernel, Chengguang Xu

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 --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
-- 
2.20.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC PATCH 3/3] xfs: show prjquota info on statfs for a file
  2019-11-18  5:09 [RFC PATCH 1/3] ext4: show prjquota info on statfs for a file Chengguang Xu
  2019-11-18  5:09 ` [RFC PATCH 2/3] f2fs: " Chengguang Xu
@ 2019-11-18  5:09 ` " Chengguang Xu
  2019-11-19 20:43   ` Dave Chinner
  1 sibling, 1 reply; 4+ messages in thread
From: Chengguang Xu @ 2019-11-18  5:09 UTC (permalink / raw)
  To: linux-ext4, linux-kernel, linux-f2fs-devel, linux-xfs
  Cc: darrick.wong, jaegeuk, chao, tytso, adilger.kernel, Chengguang Xu

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/xfs/xfs_super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 8d1df9f8be07..9f4d9e86572a 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1125,7 +1125,8 @@ xfs_fs_statfs(
 	statp->f_ffree = max_t(int64_t, ffree, 0);
 
 
-	if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
+	if (((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) ||
+	     !S_ISDIR(dentry->d_inode->i_mode)) &&
 	    ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
 			      (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
 		xfs_qm_statvfs(ip, statp);
-- 
2.20.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 3/3] xfs: show prjquota info on statfs for a file
  2019-11-18  5:09 ` [RFC PATCH 3/3] xfs: " Chengguang Xu
@ 2019-11-19 20:43   ` Dave Chinner
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2019-11-19 20:43 UTC (permalink / raw)
  To: Chengguang Xu
  Cc: linux-ext4, linux-kernel, linux-f2fs-devel, linux-xfs,
	darrick.wong, jaegeuk, chao, tytso, adilger.kernel

On Mon, Nov 18, 2019 at 01:09:49PM +0800, Chengguang Xu wrote:
> 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/xfs/xfs_super.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 8d1df9f8be07..9f4d9e86572a 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1125,7 +1125,8 @@ xfs_fs_statfs(
>  	statp->f_ffree = max_t(int64_t, ffree, 0);
>  
>  
> -	if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
> +	if (((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) ||
> +	     !S_ISDIR(dentry->d_inode->i_mode)) &&
>  	    ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
>  			      (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
>  		xfs_qm_statvfs(ip, statp);

So this also changes statfs() for non-directory quota uses. It will
now *always* report project quota info for a file, whether directory
quotas are in use or not. This is going to confuse users who see the
full filesystem info when they statfs a directory, then see project
quota limits when they statfs a file.

i.e. all this patch does is move the inconsistency in reporting to
non-directory based project quota users.

So from that perspective, this is not a viable solution.

What is a viable solution is to add an explicit dirquota mount
option (which we've recently discussed) that explicitly presents all
directory quota specific behaviours to userspace without tying them
to the internal project quota-based on-disk implementation. This is
the only sane way to solve this problem as it tells the filesysetm
exactly what behaviour set it should be exposing to userspace.

IOWs, the statfs code should probably end up looking like this:

-	if ((ip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
+	if ((mp->m_flags & XFS_MOUNT_DIRQUOTA) &&
 	    ((mp->m_qflags & (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))) ==
 			      (XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD))
 		xfs_qm_statvfs(ip, statp);

Cheers,

Dave.

-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18  5:09 [RFC PATCH 1/3] ext4: show prjquota info on statfs for a file Chengguang Xu
2019-11-18  5:09 ` [RFC PATCH 2/3] f2fs: " Chengguang Xu
2019-11-18  5:09 ` [RFC PATCH 3/3] xfs: " Chengguang Xu
2019-11-19 20:43   ` Dave Chinner

Linux-ext4 Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ext4/0 linux-ext4/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ext4 linux-ext4/ https://lore.kernel.org/linux-ext4 \
		linux-ext4@vger.kernel.org
	public-inbox-index linux-ext4

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ext4


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git