From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH 5/6] xfs: per-type quota timers and warn limits
Date: Tue, 19 May 2020 09:27:45 -0700 [thread overview]
Message-ID: <20200519162745.GO17627@magnolia> (raw)
In-Reply-To: <e27a2dff-f728-f69e-32b6-a83eee7effef@redhat.com>
On Mon, May 18, 2020 at 01:51:44PM -0500, Eric Sandeen wrote:
> From: Eric Sandeen <sandeen@redhat.com>
>
> Move timers and warnings out of xfs_quotainfo and into xfs_def_quota
> so that we can utilize them on a per-type basis, rather than enforcing
> them based on the values found in the first enabled quota type.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> Reviewed-by: Allison Collins <allison.henderson@oracle.com>
> [zlang: new way to get defquota in xfs_qm_init_timelimits]
> [zlang: remove redundant defq assign]
> Signed-off-by: Zorro Lang <zlang@redhat.com>
Makes sense, I was always confused by the old behavior of picking the
defaults from the first quota type we saw...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_dquot.c | 9 ++++---
> fs/xfs/xfs_qm.c | 54 +++++++++++++++++++---------------------
> fs/xfs/xfs_qm.h | 13 +++++-----
> fs/xfs/xfs_qm_syscalls.c | 12 ++++-----
> fs/xfs/xfs_quotaops.c | 22 ++++++++--------
> fs/xfs/xfs_trans_dquot.c | 6 ++---
> 6 files changed, 58 insertions(+), 58 deletions(-)
>
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 6d6afc0297b3..0e0a15c17789 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -116,7 +116,10 @@ xfs_qm_adjust_dqtimers(
> struct xfs_mount *mp,
> struct xfs_dquot *dq)
> {
> + struct xfs_quotainfo *qi = mp->m_quotainfo;
> struct xfs_disk_dquot *d = &dq->q_core;
> + struct xfs_def_quota *defq = xfs_get_defquota(dq, qi);
> +
> ASSERT(d->d_id);
>
> #ifdef DEBUG
> @@ -139,7 +142,7 @@ xfs_qm_adjust_dqtimers(
> (be64_to_cpu(d->d_bcount) >
> be64_to_cpu(d->d_blk_hardlimit)))) {
> d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
> - mp->m_quotainfo->qi_btimelimit);
> + defq->btimelimit);
> } else {
> d->d_bwarns = 0;
> }
> @@ -162,7 +165,7 @@ xfs_qm_adjust_dqtimers(
> (be64_to_cpu(d->d_icount) >
> be64_to_cpu(d->d_ino_hardlimit)))) {
> d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
> - mp->m_quotainfo->qi_itimelimit);
> + defq->itimelimit);
> } else {
> d->d_iwarns = 0;
> }
> @@ -185,7 +188,7 @@ xfs_qm_adjust_dqtimers(
> (be64_to_cpu(d->d_rtbcount) >
> be64_to_cpu(d->d_rtb_hardlimit)))) {
> d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
> - mp->m_quotainfo->qi_rtbtimelimit);
> + defq->rtbtimelimit);
> } else {
> d->d_rtbwarns = 0;
> }
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index e97a3802939c..9eaab2368d3d 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -577,19 +577,26 @@ xfs_qm_set_defquota(
> static void
> xfs_qm_init_timelimits(
> struct xfs_mount *mp,
> - struct xfs_quotainfo *qinf)
> + uint type)
> {
> + struct xfs_quotainfo *qinf = mp->m_quotainfo;
> + struct xfs_def_quota *defq;
> struct xfs_disk_dquot *ddqp;
> struct xfs_dquot *dqp;
> - uint type;
> int error;
>
> - qinf->qi_btimelimit = XFS_QM_BTIMELIMIT;
> - qinf->qi_itimelimit = XFS_QM_ITIMELIMIT;
> - qinf->qi_rtbtimelimit = XFS_QM_RTBTIMELIMIT;
> - qinf->qi_bwarnlimit = XFS_QM_BWARNLIMIT;
> - qinf->qi_iwarnlimit = XFS_QM_IWARNLIMIT;
> - qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
> + error = xfs_qm_dqget_uncached(mp, 0, type, &dqp);
> + if (error)
> + return;
> +
> + defq = xfs_get_defquota(dqp, qinf);
> +
> + defq->btimelimit = XFS_QM_BTIMELIMIT;
> + defq->itimelimit = XFS_QM_ITIMELIMIT;
> + defq->rtbtimelimit = XFS_QM_RTBTIMELIMIT;
> + defq->bwarnlimit = XFS_QM_BWARNLIMIT;
> + defq->iwarnlimit = XFS_QM_IWARNLIMIT;
> + defq->rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
>
> /*
> * We try to get the limits from the superuser's limits fields.
> @@ -597,39 +604,26 @@ xfs_qm_init_timelimits(
> *
> * Since we may not have done a quotacheck by this point, just read
> * the dquot without attaching it to any hashtables or lists.
> - *
> - * Timers and warnings are globally set by the first timer found in
> - * user/group/proj quota types, otherwise a default value is used.
> - * This should be split into different fields per quota type.
> */
> - if (XFS_IS_UQUOTA_RUNNING(mp))
> - type = XFS_DQ_USER;
> - else if (XFS_IS_GQUOTA_RUNNING(mp))
> - type = XFS_DQ_GROUP;
> - else
> - type = XFS_DQ_PROJ;
> - error = xfs_qm_dqget_uncached(mp, 0, type, &dqp);
> - if (error)
> - return;
> -
> ddqp = &dqp->q_core;
> +
> /*
> * The warnings and timers set the grace period given to
> * a user or group before he or she can not perform any
> * more writing. If it is zero, a default is used.
> */
> if (ddqp->d_btimer)
> - qinf->qi_btimelimit = be32_to_cpu(ddqp->d_btimer);
> + defq->btimelimit = be32_to_cpu(ddqp->d_btimer);
> if (ddqp->d_itimer)
> - qinf->qi_itimelimit = be32_to_cpu(ddqp->d_itimer);
> + defq->itimelimit = be32_to_cpu(ddqp->d_itimer);
> if (ddqp->d_rtbtimer)
> - qinf->qi_rtbtimelimit = be32_to_cpu(ddqp->d_rtbtimer);
> + defq->rtbtimelimit = be32_to_cpu(ddqp->d_rtbtimer);
> if (ddqp->d_bwarns)
> - qinf->qi_bwarnlimit = be16_to_cpu(ddqp->d_bwarns);
> + defq->bwarnlimit = be16_to_cpu(ddqp->d_bwarns);
> if (ddqp->d_iwarns)
> - qinf->qi_iwarnlimit = be16_to_cpu(ddqp->d_iwarns);
> + defq->iwarnlimit = be16_to_cpu(ddqp->d_iwarns);
> if (ddqp->d_rtbwarns)
> - qinf->qi_rtbwarnlimit = be16_to_cpu(ddqp->d_rtbwarns);
> + defq->rtbwarnlimit = be16_to_cpu(ddqp->d_rtbwarns);
>
> xfs_qm_dqdestroy(dqp);
> }
> @@ -675,7 +669,9 @@ xfs_qm_init_quotainfo(
>
> mp->m_qflags |= (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD);
>
> - xfs_qm_init_timelimits(mp, qinf);
> + xfs_qm_init_timelimits(mp, XFS_DQ_USER);
> + xfs_qm_init_timelimits(mp, XFS_DQ_GROUP);
> + xfs_qm_init_timelimits(mp, XFS_DQ_PROJ);
>
> if (XFS_IS_UQUOTA_RUNNING(mp))
> xfs_qm_set_defquota(mp, XFS_DQ_USER, qinf);
> diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h
> index 3a850401b102..761286bf7fb2 100644
> --- a/fs/xfs/xfs_qm.h
> +++ b/fs/xfs/xfs_qm.h
> @@ -41,7 +41,14 @@ extern struct kmem_zone *xfs_qm_dqtrxzone;
> */
> #define XFS_DQUOT_CLUSTER_SIZE_FSB (xfs_filblks_t)1
>
> +/* Defaults for each quota type: time limits, warn limits, usage limits */
> struct xfs_def_quota {
> + time64_t btimelimit; /* limit for blks timer */
> + time64_t itimelimit; /* limit for inodes timer */
> + time64_t rtbtimelimit; /* limit for rt blks timer */
> + xfs_qwarncnt_t bwarnlimit; /* limit for blks warnings */
> + xfs_qwarncnt_t iwarnlimit; /* limit for inodes warnings */
> + xfs_qwarncnt_t rtbwarnlimit; /* limit for rt blks warnings */
> xfs_qcnt_t bhardlimit; /* default data blk hard limit */
> xfs_qcnt_t bsoftlimit; /* default data blk soft limit */
> xfs_qcnt_t ihardlimit; /* default inode count hard limit */
> @@ -64,12 +71,6 @@ struct xfs_quotainfo {
> struct xfs_inode *qi_pquotaip; /* project quota inode */
> struct list_lru qi_lru;
> int qi_dquots;
> - time64_t qi_btimelimit; /* limit for blks timer */
> - time64_t qi_itimelimit; /* limit for inodes timer */
> - time64_t qi_rtbtimelimit;/* limit for rt blks timer */
> - xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */
> - xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */
> - xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */
> struct mutex qi_quotaofflock;/* to serialize quotaoff */
> xfs_filblks_t qi_dqchunklen; /* # BBs in a chunk of dqs */
> uint qi_dqperchunk; /* # ondisk dq in above chunk */
> diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
> index 301a284ee4f9..29c1d5d4104d 100644
> --- a/fs/xfs/xfs_qm_syscalls.c
> +++ b/fs/xfs/xfs_qm_syscalls.c
> @@ -563,23 +563,23 @@ xfs_qm_scall_setqlim(
> * for warnings.
> */
> if (newlim->d_fieldmask & QC_SPC_TIMER) {
> - q->qi_btimelimit = newlim->d_spc_timer;
> + defq->btimelimit = newlim->d_spc_timer;
> ddq->d_btimer = cpu_to_be32(newlim->d_spc_timer);
> }
> if (newlim->d_fieldmask & QC_INO_TIMER) {
> - q->qi_itimelimit = newlim->d_ino_timer;
> + defq->itimelimit = newlim->d_ino_timer;
> ddq->d_itimer = cpu_to_be32(newlim->d_ino_timer);
> }
> if (newlim->d_fieldmask & QC_RT_SPC_TIMER) {
> - q->qi_rtbtimelimit = newlim->d_rt_spc_timer;
> + defq->rtbtimelimit = newlim->d_rt_spc_timer;
> ddq->d_rtbtimer = cpu_to_be32(newlim->d_rt_spc_timer);
> }
> if (newlim->d_fieldmask & QC_SPC_WARNS)
> - q->qi_bwarnlimit = newlim->d_spc_warns;
> + defq->bwarnlimit = newlim->d_spc_warns;
> if (newlim->d_fieldmask & QC_INO_WARNS)
> - q->qi_iwarnlimit = newlim->d_ino_warns;
> + defq->iwarnlimit = newlim->d_ino_warns;
> if (newlim->d_fieldmask & QC_RT_SPC_WARNS)
> - q->qi_rtbwarnlimit = newlim->d_rt_spc_warns;
> + defq->rtbwarnlimit = newlim->d_rt_spc_warns;
> } else {
> /*
> * If the user is now over quota, start the timelimit.
> diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
> index cb16a91dd1d4..51be282d28b3 100644
> --- a/fs/xfs/xfs_quotaops.c
> +++ b/fs/xfs/xfs_quotaops.c
> @@ -21,9 +21,9 @@ xfs_qm_fill_state(
> struct qc_type_state *tstate,
> struct xfs_mount *mp,
> struct xfs_inode *ip,
> - xfs_ino_t ino)
> + xfs_ino_t ino,
> + struct xfs_def_quota *defq)
> {
> - struct xfs_quotainfo *q = mp->m_quotainfo;
> bool tempqip = false;
>
> tstate->ino = ino;
> @@ -37,12 +37,12 @@ xfs_qm_fill_state(
> tstate->flags |= QCI_SYSFILE;
> tstate->blocks = ip->i_d.di_nblocks;
> tstate->nextents = ip->i_d.di_nextents;
> - tstate->spc_timelimit = (u32)q->qi_btimelimit;
> - tstate->ino_timelimit = (u32)q->qi_itimelimit;
> - tstate->rt_spc_timelimit = (u32)q->qi_rtbtimelimit;
> - tstate->spc_warnlimit = q->qi_bwarnlimit;
> - tstate->ino_warnlimit = q->qi_iwarnlimit;
> - tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit;
> + tstate->spc_timelimit = (u32)defq->btimelimit;
> + tstate->ino_timelimit = (u32)defq->itimelimit;
> + tstate->rt_spc_timelimit = (u32)defq->rtbtimelimit;
> + tstate->spc_warnlimit = defq->bwarnlimit;
> + tstate->ino_warnlimit = defq->iwarnlimit;
> + tstate->rt_spc_warnlimit = defq->rtbwarnlimit;
> if (tempqip)
> xfs_irele(ip);
> }
> @@ -77,11 +77,11 @@ xfs_fs_get_quota_state(
> state->s_state[PRJQUOTA].flags |= QCI_LIMITS_ENFORCED;
>
> xfs_qm_fill_state(&state->s_state[USRQUOTA], mp, q->qi_uquotaip,
> - mp->m_sb.sb_uquotino);
> + mp->m_sb.sb_uquotino, &q->qi_usr_default);
> xfs_qm_fill_state(&state->s_state[GRPQUOTA], mp, q->qi_gquotaip,
> - mp->m_sb.sb_gquotino);
> + mp->m_sb.sb_gquotino, &q->qi_grp_default);
> xfs_qm_fill_state(&state->s_state[PRJQUOTA], mp, q->qi_pquotaip,
> - mp->m_sb.sb_pquotino);
> + mp->m_sb.sb_pquotino, &q->qi_prj_default);
> return 0;
> }
>
> diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> index 20542076e32a..aa25647e0864 100644
> --- a/fs/xfs/xfs_trans_dquot.c
> +++ b/fs/xfs/xfs_trans_dquot.c
> @@ -602,7 +602,7 @@ xfs_trans_dqresv(
> softlimit = defq->bsoftlimit;
> timer = be32_to_cpu(dqp->q_core.d_btimer);
> warns = be16_to_cpu(dqp->q_core.d_bwarns);
> - warnlimit = dqp->q_mount->m_quotainfo->qi_bwarnlimit;
> + warnlimit = defq->bwarnlimit;
> resbcountp = &dqp->q_res_bcount;
> } else {
> ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
> @@ -614,7 +614,7 @@ xfs_trans_dqresv(
> softlimit = defq->rtbsoftlimit;
> timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
> warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
> - warnlimit = dqp->q_mount->m_quotainfo->qi_rtbwarnlimit;
> + warnlimit = defq->rtbwarnlimit;
> resbcountp = &dqp->q_res_rtbcount;
> }
>
> @@ -650,7 +650,7 @@ xfs_trans_dqresv(
> total_count = be64_to_cpu(dqp->q_core.d_icount) + ninos;
> timer = be32_to_cpu(dqp->q_core.d_itimer);
> warns = be16_to_cpu(dqp->q_core.d_iwarns);
> - warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit;
> + warnlimit = defq->iwarnlimit;
> hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit);
> if (!hardlimit)
> hardlimit = defq->ihardlimit;
> --
> 2.17.0
>
>
next prev parent reply other threads:[~2020-05-19 16:27 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-18 18:46 [PATCH 0/SEVERAL] xfs, xfstests, xfsprogs: quota timer updates Eric Sandeen
2020-05-18 18:48 ` [PATCH 0/6] xfs: quota timer enhancements Eric Sandeen
2020-05-18 18:48 ` [PATCH 1/6] xfs: group quota should return EDQUOT when prj quota enabled Eric Sandeen
2020-05-19 16:22 ` Darrick J. Wong
2020-05-18 18:49 ` [PATCH 2/6] xfs: always return -ENOSPC on project quota reservation failure Eric Sandeen
2020-05-19 16:18 ` Darrick J. Wong
2020-05-18 18:49 ` [PATCH 3/6] xfs: fix up some whitespace in quota code Eric Sandeen
2020-05-19 16:25 ` Darrick J. Wong
2020-05-18 18:50 ` [PATCH 4/6] xfs: pass xfs_dquot to xfs_qm_adjust_dqtimers Eric Sandeen
2020-05-19 16:26 ` Darrick J. Wong
2020-05-18 18:51 ` [PATCH 5/6] xfs: per-type quota timers and warn limits Eric Sandeen
2020-05-19 16:27 ` Darrick J. Wong [this message]
2020-05-20 18:41 ` [PATCH 4.5/6] xfs: switch xfs_get_defquota to take explicit type Eric Sandeen
2020-05-20 20:36 ` Darrick J. Wong
2020-05-20 20:41 ` Eric Sandeen
2020-05-20 20:49 ` Darrick J. Wong
2020-05-20 18:43 ` [PATCH 5/6 V2] xfs: per-type quota timers and warn limits Eric Sandeen
2020-05-20 20:31 ` Darrick J. Wong
2020-05-20 20:42 ` Eric Sandeen
2020-05-18 18:52 ` [PATCH 6/6] xfs: allow individual quota grace period extension Eric Sandeen
2020-05-19 16:39 ` Darrick J. Wong
2020-05-19 17:21 ` Eric Sandeen
2020-05-18 19:23 ` [PATCH 0/1] xfs_quota: allow individual timer extension Eric Sandeen
2020-05-18 19:24 ` [PATCH 1/1] " Eric Sandeen
2020-05-18 20:04 ` Eric Sandeen
2020-05-18 20:09 ` [PATCH 1/1 V2] " Eric Sandeen
2020-05-19 16:38 ` Darrick J. Wong
2020-05-19 21:34 ` Darrick J. Wong
2020-05-18 19:59 ` [PATCH 0/4] fstests: more quota related tests Eric Sandeen
2020-05-18 19:59 ` [PATCH 1/4] xfs: make sure our default quota warning limits and grace periods survive quotacheck Eric Sandeen
2020-05-31 16:17 ` Eryu Guan
2020-05-18 20:00 ` [PATCH 2/4] generic: test per-type quota softlimit enforcement timeout Eric Sandeen
2020-05-31 16:15 ` Eryu Guan
2020-06-01 12:48 ` Zorro Lang
2020-06-01 14:36 ` Eric Sandeen
2020-06-01 16:39 ` Darrick J. Wong
2020-06-11 5:12 ` Zorro Lang
2020-06-11 15:40 ` Darrick J. Wong
2020-05-18 20:00 ` [PATCH 3/4] fstests: individual user grace period extension via setquota Eric Sandeen
2020-05-18 20:01 ` [PATCH 4/4] fstests: individual user grace period extension via xfs_quota Eric Sandeen
2020-05-20 15:39 ` [PATCH 0/4] fstests: more quota related tests Darrick J. Wong
2020-05-20 15:46 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200519162745.GO17627@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox