xfs: some bugfixes and code cleanups for quota
v2 cover xfs: some bugfixes and code cleanups for quota
From: Kaixu Xia <[email protected]>
Hi all,
This patchset include some bugfixes and code cleanups for qupta.
Changes for v2:
- put all the scattered patches into a single patchset.
- update the git version to fix the no function show problem.
Kaixu Xia (6):
xfs: trace quota allocations for all quota types
xfs: combine two if statements with same condition
xfs: reserve quota inode transaction space only when needed
xfs: remove unnecessary variable udqp from xfs_ioctl_setattr
xfs: remove unnecessary assertion from xfs_qm_vop_create_dqattach
xfs: simplify the flags setting in xfs_qm_scall_quotaon
fs/xfs/xfs_ioctl.c | 7 ++----- fs/xfs/xfs_iops.c | 5 ----- fs/xfs/xfs_qm.c | 7 +++---- fs/xfs/xfs_qm_syscalls.c | 6 +++--- 4 files changed, 8 insertions(+), 17 deletions(-)
Signature · 1 line
2.20.0
PATCH v2 1/6 xfs: trace quota allocations for all quota types
From: Kaixu Xia <[email protected]>
The trace event xfs_dquot_dqalloc does not depend on the value uq, so remove the condition, and trace quota allocations for all quota types.
--- fs/xfs/xfs_qm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/xfs/xfs_qm.c +1 -2
@@ -1730,8 +1730,7 @@ xfs_qm_vop_dqalloc( pq =xfs_qm_dqhold (ip->i_pdquot); } } -if (uq) -trace_xfs_dquot_dqalloc (ip); +trace_xfs_dquot_dqalloc (ip);xfs_iunlock (ip, lockflags);if (O_udqpp)
Signature · 1 line
2.20.0
PATCH v2 2/6 xfs: combine two if statements with same condition
In reply to [email protected]From: Kaixu Xia <[email protected]>
The two if statements have same condition, and the mask value does not change in xfs_setattr_nonsize(), so combine them.
--- fs/xfs/xfs_iops.c | 5 ----- 1 file changed, 5 deletions(-)
fs/xfs/xfs_iops.c +0 -5
@@ -738,12 +738,7 @@ xfs_setattr_nonsize(if (error)/* out of quota */ goto out_cancel; } - } -/* -* Change file ownership. Must be the owner or privileged. -*/ -if (mask & (ATTR_UID |ATTR_GID )) {/* * CAP_FSETID overrides the following restrictions: *
Signature · 1 line
2.20.0
PATCH v2 3/6 xfs: reserve quota inode transaction space only when needed
In reply to [email protected]From: Kaixu Xia <[email protected]>
We share an inode between gquota and pquota with the older superblock that doesn't have separate pquotino, and for the need_alloc == false case we don't need to call xfs_dir_ialloc() function, so add the check if reserved free disk blocks is needed.
--- fs/xfs/xfs_qm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/xfs/xfs_qm.c +2 -1
@@ -780,7 +780,8 @@ xfs_qm_qino_alloc( } error =xfs_trans_alloc (mp, &M_RES (mp)->tr_create, -XFS_QM_QINOCREATE_SPACE_RES (mp),0 ,0 , &tp); + need_alloc ?XFS_QM_QINOCREATE_SPACE_RES (mp) :0 , +0 ,0 , &tp);if (error)return error;
Signature · 1 line
2.20.0
PATCH v2 4/6 xfs: remove unnecessary variable udqp from xfs_ioctl_setattr
In reply to [email protected]From: Kaixu Xia <[email protected]>
The initial value of variable udqp is NULL, and we only set the flag XFS_QMOPT_PQUOTA in xfs_qm_vop_dqalloc() function, so only the pdqp value is initialized and the udqp value is still NULL. Since the udqp value is NULL in the rest part of xfs_ioctl_setattr() function, it is meaningless and do nothing. So remove it from xfs_ioctl_setattr().
--- fs/xfs/xfs_ioctl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
fs/xfs/xfs_ioctl.c +2 -5
@@ -1513,7 +1513,6 @@ xfs_ioctl_setattr(struct fsxattr old_fa;struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp; -struct xfs_dquot *udqp =NULL ;struct xfs_dquot *pdqp =NULL ;struct xfs_dquot *olddquot =NULL ;int code;
@@ -1536,7 +1535,7 @@ xfs_ioctl_setattr(if (XFS_IS_QUOTA_ON (mp)) { code =xfs_qm_vop_dqalloc (ip,VFS_I (ip)->i_uid,VFS_I (ip)->i_gid, fa->fsx_projid, -XFS_QMOPT_PQUOTA , &udqp,NULL , &pdqp); +XFS_QMOPT_PQUOTA ,NULL ,NULL , &pdqp);if (code)return code; }
@@ -1560,7 +1559,7 @@ xfs_ioctl_setattr(if (XFS_IS_QUOTA_RUNNING (mp) &&XFS_IS_PQUOTA_ON (mp) && ip->i_d.di_projid != fa->fsx_projid) { - code =xfs_qm_vop_chown_reserve (tp, ip, udqp,NULL , pdqp, + code =xfs_qm_vop_chown_reserve (tp, ip,NULL ,NULL , pdqp,capable (CAP_FOWNER ) ?XFS_QMOPT_FORCE_RES :0 );if (code)/* out of quota */ goto error_trans_cancel;
@@ -1626,7 +1625,6 @@ xfs_ioctl_setattr(* Release any dquot(s) the inode had kept before chown. */ xfs_qm_dqrele (olddquot); -xfs_qm_dqrele (udqp);xfs_qm_dqrele (pdqp);return code;
@@ -1634,7 +1632,6 @@ xfs_ioctl_setattr( error_trans_cancel:xfs_trans_cancel (tp); error_free_dquots: -xfs_qm_dqrele (udqp);xfs_qm_dqrele (pdqp);return code; }
Signature · 1 line
2.20.0
PATCH v2 5/6 xfs: remove unnecessary assertion from xfs_qm_vop_create_dqattach
In reply to [email protected]From: Kaixu Xia <[email protected]>
The check XFS_IS_QUOTA_RUNNING() has been done when enter the xfs_qm_vop_create_dqattach() function, it will return directly if the result is false, so the followed XFS_IS_QUOTA_RUNNING() assertion is unnecessary. If we truly care about this, the check also can be added to the condition of next if statements.
--- fs/xfs/xfs_qm.c | 1 - 1 file changed, 1 deletion(-)
fs/xfs/xfs_qm.c +0 -1
@@ -1932,7 +1932,6 @@ xfs_qm_vop_create_dqattach(return ;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); -ASSERT (XFS_IS_QUOTA_RUNNING (mp));if (udqp &&XFS_IS_UQUOTA_ON (mp)) {ASSERT (ip->i_udquot ==NULL );
Signature · 1 line
2.20.0
PATCH v2 6/6 xfs: simplify the flags setting in xfs_qm_scall_quotaon
In reply to [email protected]From: Kaixu Xia <[email protected]>
Simplify the setting of the flags value, and only consider quota enforcement stuff here.
--- fs/xfs/xfs_qm_syscalls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/xfs/xfs_qm_syscalls.c +3 -3
@@ -357,11 +357,11 @@ xfs_qm_scall_quotaon(int error;uint qf; - flags &= (XFS_ALL_QUOTA_ACCT |XFS_ALL_QUOTA_ENFD );/* -* Switching on quota accounting must be done at mount time. +* Switching on quota accounting must be done at mount time, +* only consider quota enforcement stuff here. */ - flags &= ~(XFS_ALL_QUOTA_ACCT ); + flags &=XFS_ALL_QUOTA_ENFD ;if (flags ==0 ) { xfs_debug(mp, "%s: zero flags, m_qflags=%x",
Signature · 1 line
2.20.0
Quoted 6 lines · On Sat, Apr 11, 2020 at 05:12:52PM +0800, [email protected] wrote:
From: Kaixu Xia <[email protected]>
Hi all,
This patchset include some bugfixes and code cleanups for qupta.
The series looks ok to me; thanks for bundling this up. :)
--D
Quoted 22 lines
Changes for v2:
- put all the scattered patches into a single patchset.
- update the git version to fix the no function show problem.Kaixu Xia (6):
xfs: trace quota allocations for all quota types
xfs: combine two if statements with same condition
xfs: reserve quota inode transaction space only when needed
xfs: remove unnecessary variable udqp fromxfs_ioctl_setattr
xfs: remove unnecessary assertion fromxfs_qm_vop_create_dqattach
xfs: simplify the flags setting inxfs_qm_scall_quotaonfs/xfs/xfs_ioctl.c | 7 ++----- fs/xfs/xfs_iops.c | 5 ----- fs/xfs/xfs_qm.c | 7 +++---- fs/xfs/xfs_qm_syscalls.c | 6 +++--- 4 files changed, 8 insertions(+), 17 deletions(-)Signature · 1 line
2.20.0