Skip to content

Commit e850301

Browse files
Eric Sandeendjwong
authored andcommitted
xfs: per-type quota timers and warn limits
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 <[email protected]> [zlang: new way to get defquota in xfs_qm_init_timelimits] [zlang: remove redundant defq assign] Signed-off-by: Zorro Lang <[email protected]> Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent ce6e7e7 commit e850301

File tree

6 files changed

+55
-54
lines changed

6 files changed

+55
-54
lines changed

fs/xfs/xfs_dquot.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ xfs_qm_adjust_dqtimers(
116116
struct xfs_mount *mp,
117117
struct xfs_dquot *dq)
118118
{
119+
struct xfs_quotainfo *qi = mp->m_quotainfo;
119120
struct xfs_disk_dquot *d = &dq->q_core;
121+
struct xfs_def_quota *defq;
122+
120123
ASSERT(d->d_id);
124+
defq = xfs_get_defquota(qi, xfs_dquot_type(dq));
121125

122126
#ifdef DEBUG
123127
if (d->d_blk_hardlimit)
@@ -139,7 +143,7 @@ xfs_qm_adjust_dqtimers(
139143
(be64_to_cpu(d->d_bcount) >
140144
be64_to_cpu(d->d_blk_hardlimit)))) {
141145
d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
142-
mp->m_quotainfo->qi_btimelimit);
146+
defq->btimelimit);
143147
} else {
144148
d->d_bwarns = 0;
145149
}
@@ -162,7 +166,7 @@ xfs_qm_adjust_dqtimers(
162166
(be64_to_cpu(d->d_icount) >
163167
be64_to_cpu(d->d_ino_hardlimit)))) {
164168
d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
165-
mp->m_quotainfo->qi_itimelimit);
169+
defq->itimelimit);
166170
} else {
167171
d->d_iwarns = 0;
168172
}
@@ -185,7 +189,7 @@ xfs_qm_adjust_dqtimers(
185189
(be64_to_cpu(d->d_rtbcount) >
186190
be64_to_cpu(d->d_rtb_hardlimit)))) {
187191
d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
188-
mp->m_quotainfo->qi_rtbtimelimit);
192+
defq->rtbtimelimit);
189193
} else {
190194
d->d_rtbwarns = 0;
191195
}

fs/xfs/xfs_qm.c

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -577,59 +577,53 @@ xfs_qm_set_defquota(
577577
static void
578578
xfs_qm_init_timelimits(
579579
struct xfs_mount *mp,
580-
struct xfs_quotainfo *qinf)
580+
uint type)
581581
{
582+
struct xfs_quotainfo *qinf = mp->m_quotainfo;
583+
struct xfs_def_quota *defq;
582584
struct xfs_disk_dquot *ddqp;
583585
struct xfs_dquot *dqp;
584-
uint type;
585586
int error;
586587

587-
qinf->qi_btimelimit = XFS_QM_BTIMELIMIT;
588-
qinf->qi_itimelimit = XFS_QM_ITIMELIMIT;
589-
qinf->qi_rtbtimelimit = XFS_QM_RTBTIMELIMIT;
590-
qinf->qi_bwarnlimit = XFS_QM_BWARNLIMIT;
591-
qinf->qi_iwarnlimit = XFS_QM_IWARNLIMIT;
592-
qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
588+
defq = xfs_get_defquota(qinf, type);
589+
590+
defq->btimelimit = XFS_QM_BTIMELIMIT;
591+
defq->itimelimit = XFS_QM_ITIMELIMIT;
592+
defq->rtbtimelimit = XFS_QM_RTBTIMELIMIT;
593+
defq->bwarnlimit = XFS_QM_BWARNLIMIT;
594+
defq->iwarnlimit = XFS_QM_IWARNLIMIT;
595+
defq->rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
593596

594597
/*
595598
* We try to get the limits from the superuser's limits fields.
596599
* This is quite hacky, but it is standard quota practice.
597600
*
598601
* Since we may not have done a quotacheck by this point, just read
599602
* the dquot without attaching it to any hashtables or lists.
600-
*
601-
* Timers and warnings are globally set by the first timer found in
602-
* user/group/proj quota types, otherwise a default value is used.
603-
* This should be split into different fields per quota type.
604603
*/
605-
if (XFS_IS_UQUOTA_RUNNING(mp))
606-
type = XFS_DQ_USER;
607-
else if (XFS_IS_GQUOTA_RUNNING(mp))
608-
type = XFS_DQ_GROUP;
609-
else
610-
type = XFS_DQ_PROJ;
611604
error = xfs_qm_dqget_uncached(mp, 0, type, &dqp);
612605
if (error)
613606
return;
614607

615608
ddqp = &dqp->q_core;
609+
616610
/*
617611
* The warnings and timers set the grace period given to
618612
* a user or group before he or she can not perform any
619613
* more writing. If it is zero, a default is used.
620614
*/
621615
if (ddqp->d_btimer)
622-
qinf->qi_btimelimit = be32_to_cpu(ddqp->d_btimer);
616+
defq->btimelimit = be32_to_cpu(ddqp->d_btimer);
623617
if (ddqp->d_itimer)
624-
qinf->qi_itimelimit = be32_to_cpu(ddqp->d_itimer);
618+
defq->itimelimit = be32_to_cpu(ddqp->d_itimer);
625619
if (ddqp->d_rtbtimer)
626-
qinf->qi_rtbtimelimit = be32_to_cpu(ddqp->d_rtbtimer);
620+
defq->rtbtimelimit = be32_to_cpu(ddqp->d_rtbtimer);
627621
if (ddqp->d_bwarns)
628-
qinf->qi_bwarnlimit = be16_to_cpu(ddqp->d_bwarns);
622+
defq->bwarnlimit = be16_to_cpu(ddqp->d_bwarns);
629623
if (ddqp->d_iwarns)
630-
qinf->qi_iwarnlimit = be16_to_cpu(ddqp->d_iwarns);
624+
defq->iwarnlimit = be16_to_cpu(ddqp->d_iwarns);
631625
if (ddqp->d_rtbwarns)
632-
qinf->qi_rtbwarnlimit = be16_to_cpu(ddqp->d_rtbwarns);
626+
defq->rtbwarnlimit = be16_to_cpu(ddqp->d_rtbwarns);
633627

634628
xfs_qm_dqdestroy(dqp);
635629
}
@@ -675,7 +669,9 @@ xfs_qm_init_quotainfo(
675669

676670
mp->m_qflags |= (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD);
677671

678-
xfs_qm_init_timelimits(mp, qinf);
672+
xfs_qm_init_timelimits(mp, XFS_DQ_USER);
673+
xfs_qm_init_timelimits(mp, XFS_DQ_GROUP);
674+
xfs_qm_init_timelimits(mp, XFS_DQ_PROJ);
679675

680676
if (XFS_IS_UQUOTA_RUNNING(mp))
681677
xfs_qm_set_defquota(mp, XFS_DQ_USER, qinf);

fs/xfs/xfs_qm.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ extern struct kmem_zone *xfs_qm_dqtrxzone;
4141
*/
4242
#define XFS_DQUOT_CLUSTER_SIZE_FSB (xfs_filblks_t)1
4343

44+
/* Defaults for each quota type: time limits, warn limits, usage limits */
4445
struct xfs_def_quota {
46+
time64_t btimelimit; /* limit for blks timer */
47+
time64_t itimelimit; /* limit for inodes timer */
48+
time64_t rtbtimelimit; /* limit for rt blks timer */
49+
xfs_qwarncnt_t bwarnlimit; /* limit for blks warnings */
50+
xfs_qwarncnt_t iwarnlimit; /* limit for inodes warnings */
51+
xfs_qwarncnt_t rtbwarnlimit; /* limit for rt blks warnings */
4552
xfs_qcnt_t bhardlimit; /* default data blk hard limit */
4653
xfs_qcnt_t bsoftlimit; /* default data blk soft limit */
4754
xfs_qcnt_t ihardlimit; /* default inode count hard limit */
@@ -64,12 +71,6 @@ struct xfs_quotainfo {
6471
struct xfs_inode *qi_pquotaip; /* project quota inode */
6572
struct list_lru qi_lru;
6673
int qi_dquots;
67-
time64_t qi_btimelimit; /* limit for blks timer */
68-
time64_t qi_itimelimit; /* limit for inodes timer */
69-
time64_t qi_rtbtimelimit;/* limit for rt blks timer */
70-
xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */
71-
xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */
72-
xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */
7374
struct mutex qi_quotaofflock;/* to serialize quotaoff */
7475
xfs_filblks_t qi_dqchunklen; /* # BBs in a chunk of dqs */
7576
uint qi_dqperchunk; /* # ondisk dq in above chunk */

fs/xfs/xfs_qm_syscalls.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,23 +563,23 @@ xfs_qm_scall_setqlim(
563563
* for warnings.
564564
*/
565565
if (newlim->d_fieldmask & QC_SPC_TIMER) {
566-
q->qi_btimelimit = newlim->d_spc_timer;
566+
defq->btimelimit = newlim->d_spc_timer;
567567
ddq->d_btimer = cpu_to_be32(newlim->d_spc_timer);
568568
}
569569
if (newlim->d_fieldmask & QC_INO_TIMER) {
570-
q->qi_itimelimit = newlim->d_ino_timer;
570+
defq->itimelimit = newlim->d_ino_timer;
571571
ddq->d_itimer = cpu_to_be32(newlim->d_ino_timer);
572572
}
573573
if (newlim->d_fieldmask & QC_RT_SPC_TIMER) {
574-
q->qi_rtbtimelimit = newlim->d_rt_spc_timer;
574+
defq->rtbtimelimit = newlim->d_rt_spc_timer;
575575
ddq->d_rtbtimer = cpu_to_be32(newlim->d_rt_spc_timer);
576576
}
577577
if (newlim->d_fieldmask & QC_SPC_WARNS)
578-
q->qi_bwarnlimit = newlim->d_spc_warns;
578+
defq->bwarnlimit = newlim->d_spc_warns;
579579
if (newlim->d_fieldmask & QC_INO_WARNS)
580-
q->qi_iwarnlimit = newlim->d_ino_warns;
580+
defq->iwarnlimit = newlim->d_ino_warns;
581581
if (newlim->d_fieldmask & QC_RT_SPC_WARNS)
582-
q->qi_rtbwarnlimit = newlim->d_rt_spc_warns;
582+
defq->rtbwarnlimit = newlim->d_rt_spc_warns;
583583
} else {
584584
/*
585585
* If the user is now over quota, start the timelimit.

fs/xfs/xfs_quotaops.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ xfs_qm_fill_state(
2121
struct qc_type_state *tstate,
2222
struct xfs_mount *mp,
2323
struct xfs_inode *ip,
24-
xfs_ino_t ino)
24+
xfs_ino_t ino,
25+
struct xfs_def_quota *defq)
2526
{
26-
struct xfs_quotainfo *q = mp->m_quotainfo;
2727
bool tempqip = false;
2828

2929
tstate->ino = ino;
@@ -37,12 +37,12 @@ xfs_qm_fill_state(
3737
tstate->flags |= QCI_SYSFILE;
3838
tstate->blocks = ip->i_d.di_nblocks;
3939
tstate->nextents = ip->i_df.if_nextents;
40-
tstate->spc_timelimit = (u32)q->qi_btimelimit;
41-
tstate->ino_timelimit = (u32)q->qi_itimelimit;
42-
tstate->rt_spc_timelimit = (u32)q->qi_rtbtimelimit;
43-
tstate->spc_warnlimit = q->qi_bwarnlimit;
44-
tstate->ino_warnlimit = q->qi_iwarnlimit;
45-
tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit;
40+
tstate->spc_timelimit = (u32)defq->btimelimit;
41+
tstate->ino_timelimit = (u32)defq->itimelimit;
42+
tstate->rt_spc_timelimit = (u32)defq->rtbtimelimit;
43+
tstate->spc_warnlimit = defq->bwarnlimit;
44+
tstate->ino_warnlimit = defq->iwarnlimit;
45+
tstate->rt_spc_warnlimit = defq->rtbwarnlimit;
4646
if (tempqip)
4747
xfs_irele(ip);
4848
}
@@ -77,11 +77,11 @@ xfs_fs_get_quota_state(
7777
state->s_state[PRJQUOTA].flags |= QCI_LIMITS_ENFORCED;
7878

7979
xfs_qm_fill_state(&state->s_state[USRQUOTA], mp, q->qi_uquotaip,
80-
mp->m_sb.sb_uquotino);
80+
mp->m_sb.sb_uquotino, &q->qi_usr_default);
8181
xfs_qm_fill_state(&state->s_state[GRPQUOTA], mp, q->qi_gquotaip,
82-
mp->m_sb.sb_gquotino);
82+
mp->m_sb.sb_gquotino, &q->qi_grp_default);
8383
xfs_qm_fill_state(&state->s_state[PRJQUOTA], mp, q->qi_pquotaip,
84-
mp->m_sb.sb_pquotino);
84+
mp->m_sb.sb_pquotino, &q->qi_prj_default);
8585
return 0;
8686
}
8787

fs/xfs/xfs_trans_dquot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ xfs_trans_dqresv(
602602
softlimit = defq->bsoftlimit;
603603
timer = be32_to_cpu(dqp->q_core.d_btimer);
604604
warns = be16_to_cpu(dqp->q_core.d_bwarns);
605-
warnlimit = dqp->q_mount->m_quotainfo->qi_bwarnlimit;
605+
warnlimit = defq->bwarnlimit;
606606
resbcountp = &dqp->q_res_bcount;
607607
} else {
608608
ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
@@ -614,7 +614,7 @@ xfs_trans_dqresv(
614614
softlimit = defq->rtbsoftlimit;
615615
timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
616616
warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
617-
warnlimit = dqp->q_mount->m_quotainfo->qi_rtbwarnlimit;
617+
warnlimit = defq->rtbwarnlimit;
618618
resbcountp = &dqp->q_res_rtbcount;
619619
}
620620

@@ -650,7 +650,7 @@ xfs_trans_dqresv(
650650
total_count = be64_to_cpu(dqp->q_core.d_icount) + ninos;
651651
timer = be32_to_cpu(dqp->q_core.d_itimer);
652652
warns = be16_to_cpu(dqp->q_core.d_iwarns);
653-
warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit;
653+
warnlimit = defq->iwarnlimit;
654654
hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit);
655655
if (!hardlimit)
656656
hardlimit = defq->ihardlimit;

0 commit comments

Comments
 (0)