Skip to content

Commit dbcbc7b

Browse files
committed
xfs: refactor testing if a particular dquot is being enforced
Create a small helper to test if enforcement is enabled for a given incore dquot and replace the open-code logic testing. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 8cd4901 commit dbcbc7b

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

fs/xfs/xfs_dquot.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,23 @@ static inline struct xfs_dquot *xfs_inode_dquot(struct xfs_inode *ip, int type)
156156
}
157157
}
158158

159+
/* Decide if the dquot's limits are actually being enforced. */
160+
static inline bool
161+
xfs_dquot_is_enforced(
162+
const struct xfs_dquot *dqp)
163+
{
164+
switch (dqp->dq_flags & XFS_DQTYPE_REC_MASK) {
165+
case XFS_DQTYPE_USER:
166+
return XFS_IS_UQUOTA_ENFORCED(dqp->q_mount);
167+
case XFS_DQTYPE_GROUP:
168+
return XFS_IS_GQUOTA_ENFORCED(dqp->q_mount);
169+
case XFS_DQTYPE_PROJ:
170+
return XFS_IS_PQUOTA_ENFORCED(dqp->q_mount);
171+
}
172+
ASSERT(0);
173+
return false;
174+
}
175+
159176
/*
160177
* Check whether a dquot is under low free space conditions. We assume the quota
161178
* is enabled and enforced.

fs/xfs/xfs_qm_syscalls.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,19 +660,14 @@ xfs_qm_scall_getquota_fill_qc(
660660
* gets turned off. No need to confuse the user level code,
661661
* so return zeroes in that case.
662662
*/
663-
if ((!XFS_IS_UQUOTA_ENFORCED(mp) && type == XFS_DQTYPE_USER) ||
664-
(!XFS_IS_GQUOTA_ENFORCED(mp) && type == XFS_DQTYPE_GROUP) ||
665-
(!XFS_IS_PQUOTA_ENFORCED(mp) && type == XFS_DQTYPE_PROJ)) {
663+
if (!xfs_dquot_is_enforced(dqp)) {
666664
dst->d_spc_timer = 0;
667665
dst->d_ino_timer = 0;
668666
dst->d_rt_spc_timer = 0;
669667
}
670668

671669
#ifdef DEBUG
672-
if (((XFS_IS_UQUOTA_ENFORCED(mp) && type == XFS_DQTYPE_USER) ||
673-
(XFS_IS_GQUOTA_ENFORCED(mp) && type == XFS_DQTYPE_GROUP) ||
674-
(XFS_IS_PQUOTA_ENFORCED(mp) && type == XFS_DQTYPE_PROJ)) &&
675-
dqp->q_id != 0) {
670+
if (xfs_dquot_is_enforced(dqp) && dqp->q_id != 0) {
676671
if ((dst->d_space > dst->d_spc_softlimit) &&
677672
(dst->d_spc_softlimit > 0)) {
678673
ASSERT(dst->d_spc_timer != 0);

fs/xfs/xfs_trans_dquot.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,7 @@ xfs_trans_dqresv(
650650
}
651651

652652
if ((flags & XFS_QMOPT_FORCE_RES) == 0 && dqp->q_id &&
653-
((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) ||
654-
(XFS_IS_GQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISGDQ(dqp)) ||
655-
(XFS_IS_PQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISPDQ(dqp)))) {
653+
xfs_dquot_is_enforced(dqp)) {
656654
int quota_nl;
657655
bool fatal;
658656

0 commit comments

Comments
 (0)