From patchwork Mon Nov 18 05:09:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 1196509 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mykernel.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="Hd4TEPjE"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47GcVy4zmZz9sRD for ; Mon, 18 Nov 2019 16:11:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbfKRFLQ (ORCPT ); Mon, 18 Nov 2019 00:11:16 -0500 Received: from sender3-of-o52.zoho.com.cn ([124.251.121.247]:21961 "EHLO sender2.zoho.com.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725816AbfKRFLP (ORCPT ); Mon, 18 Nov 2019 00:11:15 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1574053816; cv=none; d=zoho.com.cn; s=zohoarc; b=nOqkrGkbDhtS3JDMvQRPuCCRI17CD3aKZSTRZtWSBRtIjONCrKc6v+eLP7IuCi+Tkb0VZoRzf+u9HRwRyoZxjpE3o/LBCY/xtjVY9lmLKSyHDBAtPBSmHY/MkEagt4xEyqco26PSMXg93wv5ol1WfKIHQt+zoEOWThlUcRAGN+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1574053816; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=BsgB+uLSbI/A7RpGrDvhjCegyC49pCxyhfWI2lOuUfk=; b=PTPwfFgv2WlRWueS8Em/r/X8tv6FghRBaJJqvDQHrdYADltuXdTTk+PPpD9x7DXGGxiajBFuHx+ywgo4prEMy5XC3vRT4LdJwBbfwIffx2ETasq8EpSMJaSyDqKAEK4aliVEMaWCccd8f334fuTtopvX2yodxA6oYCsKxH3LQIs= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1574053816; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1765; bh=BsgB+uLSbI/A7RpGrDvhjCegyC49pCxyhfWI2lOuUfk=; b=Hd4TEPjE8y+eT9uAecADUdrpdpM8idvHMa1WowClTYYDjvX+VFqMB/ZTpEKHKjQi efzGVbutkWe2JrkyEhT91eL6JxU5nE58/YJUeOzq8cRZoz3qf/lUNAW3IQPj19sZVxj 2ViUFwDHjLT3p5JQPt2yg7VxII6IbzbJfqaDVpmA= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1574053813058511.6204774440098; Mon, 18 Nov 2019 13:10:13 +0800 (CST) From: Chengguang Xu To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, jaegeuk@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, Chengguang Xu Message-ID: <20191118050949.15629-1-cgxu519@mykernel.net> Subject: [RFC PATCH 1/3] ext4: show prjquota info on statfs for a file Date: Mon, 18 Nov 2019 13:09:47 +0800 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-ZohoCNMailClient: External Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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 From patchwork Mon Nov 18 05:09:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 1196508 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mykernel.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="Jz7cAV9v"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47GcVx3yNhz9sPj for ; Mon, 18 Nov 2019 16:11:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726169AbfKRFLK (ORCPT ); Mon, 18 Nov 2019 00:11:10 -0500 Received: from sender3-of-o52.zoho.com.cn ([124.251.121.247]:21960 "EHLO sender2.zoho.com.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725208AbfKRFLK (ORCPT ); Mon, 18 Nov 2019 00:11:10 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1574053818; cv=none; d=zoho.com.cn; s=zohoarc; b=CFiTydxXmqD9bMG7v780o3N8ddqWN6K3FCgyTdlTsez+ICLl9SEtemLlO1rFmwdlnFVn0KaMzc1ve2S2pA//ZQDSMywCMchSASZ55qhlGgITwNozY47/lo2c/INkLP4RSjDGEAEdUnzyuSWpR2MhhKkB3r8PeWHkAF6uLKrdeQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1574053818; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=W+4d37NiUZrTVp/T//URhJAtULIpMWsOCTG3JUgcQbA=; b=SfZrHruFtbvLbpQPjNc72IC+JSlnZfJ+XGA4IFDCxatxJXqhBCbg8JNLUagIec/KDcUIuQTVBtngdQoSW3hkUMbcgLGEpH8Fm+eXwz7ARt58nKunz86ZgaxuRX//6Mv41ix92didw44LkKsvKlQgBBZdKpmg9s6dWyjCHjCQdl8= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1574053818; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1801; bh=W+4d37NiUZrTVp/T//URhJAtULIpMWsOCTG3JUgcQbA=; b=Jz7cAV9vUe3W4KyujDLRcYQXLcQV6tl7gVqHx1v+Ljon9oHqojtRod0Rc50n5YC5 ZkEOZtA8Vu7ezLL5/F5sGKbob4KLpIxLDCTIwMJBQFp3pj5hakvhUeJmc/iSvEmO7Gl mbdedSI3usWavsqw8+/jaZGYDbtDrn2dLYPcKTdA= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 157405381681740.021350625482796; Mon, 18 Nov 2019 13:10:16 +0800 (CST) From: Chengguang Xu To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, jaegeuk@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, Chengguang Xu Message-ID: <20191118050949.15629-2-cgxu519@mykernel.net> Subject: [RFC PATCH 2/3] f2fs: show prjquota info on statfs for a file Date: Mon, 18 Nov 2019 13:09:48 +0800 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191118050949.15629-1-cgxu519@mykernel.net> References: <20191118050949.15629-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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 From patchwork Mon Nov 18 05:09:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 1196510 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mykernel.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="SvQFCdzi"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47GcVz5nffz9sRK for ; Mon, 18 Nov 2019 16:11:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbfKRFLN (ORCPT ); Mon, 18 Nov 2019 00:11:13 -0500 Received: from sender3-of-o52.zoho.com.cn ([124.251.121.247]:21962 "EHLO sender2.zoho.com.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725934AbfKRFLN (ORCPT ); Mon, 18 Nov 2019 00:11:13 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1574053820; cv=none; d=zoho.com.cn; s=zohoarc; b=O70woNDRmcMXazDUfoFGwElRurDEqQkMMtwkKp5K6lJNE3JlmbUwmddwyfDJ7Kkk5NEvifaMbe3QSg6S5Iv6S1jQYwHVE6d1/0UQ7O/xMDxDChXuolGDg50qnLURp0ieO5L6an++ZJmdOKHov5kAWqEcrQy87VGwPGrP2RT4zGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1574053820; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=GDu82HfY7CnDAb1EdcuqFswUt9CFFN7VyyP2enB6TlQ=; b=NDFYFZseRQVlvn4/MTP/3tm5xReBr2b8K0fkVe9XORh9WOWXlGgKFK4Poqc0odvNBXvnoxWJupOFspTrPLGsgl5L8vMj4wc2cPV2Dhk2Iwd7ERh1HPNWQtIZLW9WzYmgnq0cqPFlHanvOHDqjAiQQWS1CunrfKkT8g2lzoj2Y0o= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1574053820; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1682; bh=GDu82HfY7CnDAb1EdcuqFswUt9CFFN7VyyP2enB6TlQ=; b=SvQFCdziN57bDfl1glECMMWGyxlsxq9Aynk00GSL3RpiZdBV94P6CXT5PQ7cPCMs wN/J3OMCE6VSFOTFYPs2cvzwGGBK6Mzzx1e2xeeEmYZ7+14+K4gzJ04m7HZQNDFmtlr V4RcyxibAcDC8EEC3xIl29I12Q7l48+i8mv7Tutg= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1574053818929531.7015154867489; Mon, 18 Nov 2019 13:10:18 +0800 (CST) From: Chengguang Xu To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, jaegeuk@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, Chengguang Xu Message-ID: <20191118050949.15629-3-cgxu519@mykernel.net> Subject: [RFC PATCH 3/3] xfs: show prjquota info on statfs for a file Date: Mon, 18 Nov 2019 13:09:49 +0800 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191118050949.15629-1-cgxu519@mykernel.net> References: <20191118050949.15629-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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);