Commit 438769e3 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: refactor default quota limits by resource

Now that we've split up the dquot resource fields into separate structs,
do the same for the default limits to enable further refactoring.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 51dbb1be
...@@ -77,22 +77,22 @@ xfs_qm_adjust_dqlimits( ...@@ -77,22 +77,22 @@ xfs_qm_adjust_dqlimits(
ASSERT(dq->q_id); ASSERT(dq->q_id);
defq = xfs_get_defquota(q, xfs_dquot_type(dq)); defq = xfs_get_defquota(q, xfs_dquot_type(dq));
if (defq->bsoftlimit && !dq->q_blk.softlimit) { if (defq->blk.soft && !dq->q_blk.softlimit) {
dq->q_blk.softlimit = defq->bsoftlimit; dq->q_blk.softlimit = defq->blk.soft;
prealloc = 1; prealloc = 1;
} }
if (defq->bhardlimit && !dq->q_blk.hardlimit) { if (defq->blk.hard && !dq->q_blk.hardlimit) {
dq->q_blk.hardlimit = defq->bhardlimit; dq->q_blk.hardlimit = defq->blk.hard;
prealloc = 1; prealloc = 1;
} }
if (defq->isoftlimit && !dq->q_ino.softlimit) if (defq->ino.soft && !dq->q_ino.softlimit)
dq->q_ino.softlimit = defq->isoftlimit; dq->q_ino.softlimit = defq->ino.soft;
if (defq->ihardlimit && !dq->q_ino.hardlimit) if (defq->ino.hard && !dq->q_ino.hardlimit)
dq->q_ino.hardlimit = defq->ihardlimit; dq->q_ino.hardlimit = defq->ino.hard;
if (defq->rtbsoftlimit && !dq->q_rtb.softlimit) if (defq->rtb.soft && !dq->q_rtb.softlimit)
dq->q_rtb.softlimit = defq->rtbsoftlimit; dq->q_rtb.softlimit = defq->rtb.soft;
if (defq->rtbhardlimit && !dq->q_rtb.hardlimit) if (defq->rtb.hard && !dq->q_rtb.hardlimit)
dq->q_rtb.hardlimit = defq->rtbhardlimit; dq->q_rtb.hardlimit = defq->rtb.hard;
if (prealloc) if (prealloc)
xfs_dquot_set_prealloc_limits(dq); xfs_dquot_set_prealloc_limits(dq);
...@@ -137,7 +137,7 @@ xfs_qm_adjust_dqtimers( ...@@ -137,7 +137,7 @@ xfs_qm_adjust_dqtimers(
(dq->q_blk.hardlimit && (dq->q_blk.hardlimit &&
(dq->q_blk.count > dq->q_blk.hardlimit))) { (dq->q_blk.count > dq->q_blk.hardlimit))) {
dq->q_blk.timer = ktime_get_real_seconds() + dq->q_blk.timer = ktime_get_real_seconds() +
defq->btimelimit; defq->blk.time;
} else { } else {
dq->q_blk.warnings = 0; dq->q_blk.warnings = 0;
} }
...@@ -156,7 +156,7 @@ xfs_qm_adjust_dqtimers( ...@@ -156,7 +156,7 @@ xfs_qm_adjust_dqtimers(
(dq->q_ino.hardlimit && (dq->q_ino.hardlimit &&
(dq->q_ino.count > dq->q_ino.hardlimit))) { (dq->q_ino.count > dq->q_ino.hardlimit))) {
dq->q_ino.timer = ktime_get_real_seconds() + dq->q_ino.timer = ktime_get_real_seconds() +
defq->itimelimit; defq->ino.time;
} else { } else {
dq->q_ino.warnings = 0; dq->q_ino.warnings = 0;
} }
...@@ -175,7 +175,7 @@ xfs_qm_adjust_dqtimers( ...@@ -175,7 +175,7 @@ xfs_qm_adjust_dqtimers(
(dq->q_rtb.hardlimit && (dq->q_rtb.hardlimit &&
(dq->q_rtb.count > dq->q_rtb.hardlimit))) { (dq->q_rtb.count > dq->q_rtb.hardlimit))) {
dq->q_rtb.timer = ktime_get_real_seconds() + dq->q_rtb.timer = ktime_get_real_seconds() +
defq->rtbtimelimit; defq->rtb.time;
} else { } else {
dq->q_rtb.warnings = 0; dq->q_rtb.warnings = 0;
} }
......
...@@ -562,12 +562,12 @@ xfs_qm_set_defquota( ...@@ -562,12 +562,12 @@ xfs_qm_set_defquota(
* Timers and warnings have been already set, let's just set the * Timers and warnings have been already set, let's just set the
* default limits for this quota type * default limits for this quota type
*/ */
defq->bhardlimit = dqp->q_blk.hardlimit; defq->blk.hard = dqp->q_blk.hardlimit;
defq->bsoftlimit = dqp->q_blk.softlimit; defq->blk.soft = dqp->q_blk.softlimit;
defq->ihardlimit = dqp->q_ino.hardlimit; defq->ino.hard = dqp->q_ino.hardlimit;
defq->isoftlimit = dqp->q_ino.softlimit; defq->ino.soft = dqp->q_ino.softlimit;
defq->rtbhardlimit = dqp->q_rtb.hardlimit; defq->rtb.hard = dqp->q_rtb.hardlimit;
defq->rtbsoftlimit = dqp->q_rtb.softlimit; defq->rtb.soft = dqp->q_rtb.softlimit;
xfs_qm_dqdestroy(dqp); xfs_qm_dqdestroy(dqp);
} }
...@@ -584,12 +584,12 @@ xfs_qm_init_timelimits( ...@@ -584,12 +584,12 @@ xfs_qm_init_timelimits(
defq = xfs_get_defquota(qinf, type); defq = xfs_get_defquota(qinf, type);
defq->btimelimit = XFS_QM_BTIMELIMIT; defq->blk.time = XFS_QM_BTIMELIMIT;
defq->itimelimit = XFS_QM_ITIMELIMIT; defq->ino.time = XFS_QM_ITIMELIMIT;
defq->rtbtimelimit = XFS_QM_RTBTIMELIMIT; defq->rtb.time = XFS_QM_RTBTIMELIMIT;
defq->bwarnlimit = XFS_QM_BWARNLIMIT; defq->blk.warn = XFS_QM_BWARNLIMIT;
defq->iwarnlimit = XFS_QM_IWARNLIMIT; defq->ino.warn = XFS_QM_IWARNLIMIT;
defq->rtbwarnlimit = XFS_QM_RTBWARNLIMIT; defq->rtb.warn = XFS_QM_RTBWARNLIMIT;
/* /*
* We try to get the limits from the superuser's limits fields. * We try to get the limits from the superuser's limits fields.
...@@ -608,17 +608,17 @@ xfs_qm_init_timelimits( ...@@ -608,17 +608,17 @@ xfs_qm_init_timelimits(
* more writing. If it is zero, a default is used. * more writing. If it is zero, a default is used.
*/ */
if (dqp->q_blk.timer) if (dqp->q_blk.timer)
defq->btimelimit = dqp->q_blk.timer; defq->blk.time = dqp->q_blk.timer;
if (dqp->q_ino.timer) if (dqp->q_ino.timer)
defq->itimelimit = dqp->q_ino.timer; defq->ino.time = dqp->q_ino.timer;
if (dqp->q_rtb.timer) if (dqp->q_rtb.timer)
defq->rtbtimelimit = dqp->q_rtb.timer; defq->rtb.time = dqp->q_rtb.timer;
if (dqp->q_blk.warnings) if (dqp->q_blk.warnings)
defq->bwarnlimit = dqp->q_blk.warnings; defq->blk.warn = dqp->q_blk.warnings;
if (dqp->q_ino.warnings) if (dqp->q_ino.warnings)
defq->iwarnlimit = dqp->q_ino.warnings; defq->ino.warn = dqp->q_ino.warnings;
if (dqp->q_rtb.warnings) if (dqp->q_rtb.warnings)
defq->rtbwarnlimit = dqp->q_rtb.warnings; defq->rtb.warn = dqp->q_rtb.warnings;
xfs_qm_dqdestroy(dqp); xfs_qm_dqdestroy(dqp);
} }
......
...@@ -30,20 +30,18 @@ extern struct kmem_zone *xfs_qm_dqtrxzone; ...@@ -30,20 +30,18 @@ extern struct kmem_zone *xfs_qm_dqtrxzone;
!dqp->q_rtb.count && \ !dqp->q_rtb.count && \
!dqp->q_ino.count) !dqp->q_ino.count)
struct xfs_quota_limits {
xfs_qcnt_t hard; /* default hard limit */
xfs_qcnt_t soft; /* default soft limit */
time64_t time; /* limit for timers */
xfs_qwarncnt_t warn; /* limit for warnings */
};
/* Defaults for each quota type: time limits, warn limits, usage limits */ /* Defaults for each quota type: time limits, warn limits, usage limits */
struct xfs_def_quota { struct xfs_def_quota {
time64_t btimelimit; /* limit for blks timer */ struct xfs_quota_limits blk;
time64_t itimelimit; /* limit for inodes timer */ struct xfs_quota_limits ino;
time64_t rtbtimelimit; /* limit for rt blks timer */ struct xfs_quota_limits rtb;
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 */
xfs_qcnt_t isoftlimit; /* default inode count soft limit */
xfs_qcnt_t rtbhardlimit; /* default realtime blk hard limit */
xfs_qcnt_t rtbsoftlimit; /* default realtime blk soft limit */
}; };
/* /*
......
...@@ -502,8 +502,8 @@ xfs_qm_scall_setqlim( ...@@ -502,8 +502,8 @@ xfs_qm_scall_setqlim(
dqp->q_blk.softlimit = soft; dqp->q_blk.softlimit = soft;
xfs_dquot_set_prealloc_limits(dqp); xfs_dquot_set_prealloc_limits(dqp);
if (id == 0) { if (id == 0) {
defq->bhardlimit = hard; defq->blk.hard = hard;
defq->bsoftlimit = soft; defq->blk.soft = soft;
} }
} else { } else {
xfs_debug(mp, "blkhard %Ld < blksoft %Ld", hard, soft); xfs_debug(mp, "blkhard %Ld < blksoft %Ld", hard, soft);
...@@ -518,8 +518,8 @@ xfs_qm_scall_setqlim( ...@@ -518,8 +518,8 @@ xfs_qm_scall_setqlim(
dqp->q_rtb.hardlimit = hard; dqp->q_rtb.hardlimit = hard;
dqp->q_rtb.softlimit = soft; dqp->q_rtb.softlimit = soft;
if (id == 0) { if (id == 0) {
defq->rtbhardlimit = hard; defq->rtb.hard = hard;
defq->rtbsoftlimit = soft; defq->rtb.soft = soft;
} }
} else { } else {
xfs_debug(mp, "rtbhard %Ld < rtbsoft %Ld", hard, soft); xfs_debug(mp, "rtbhard %Ld < rtbsoft %Ld", hard, soft);
...@@ -535,8 +535,8 @@ xfs_qm_scall_setqlim( ...@@ -535,8 +535,8 @@ xfs_qm_scall_setqlim(
dqp->q_ino.hardlimit = hard; dqp->q_ino.hardlimit = hard;
dqp->q_ino.softlimit = soft; dqp->q_ino.softlimit = soft;
if (id == 0) { if (id == 0) {
defq->ihardlimit = hard; defq->ino.hard = hard;
defq->isoftlimit = soft; defq->ino.soft = soft;
} }
} else { } else {
xfs_debug(mp, "ihard %Ld < isoft %Ld", hard, soft); xfs_debug(mp, "ihard %Ld < isoft %Ld", hard, soft);
...@@ -554,11 +554,11 @@ xfs_qm_scall_setqlim( ...@@ -554,11 +554,11 @@ xfs_qm_scall_setqlim(
if (id == 0) { if (id == 0) {
if (newlim->d_fieldmask & QC_SPC_WARNS) if (newlim->d_fieldmask & QC_SPC_WARNS)
defq->bwarnlimit = newlim->d_spc_warns; defq->blk.warn = newlim->d_spc_warns;
if (newlim->d_fieldmask & QC_INO_WARNS) if (newlim->d_fieldmask & QC_INO_WARNS)
defq->iwarnlimit = newlim->d_ino_warns; defq->ino.warn = newlim->d_ino_warns;
if (newlim->d_fieldmask & QC_RT_SPC_WARNS) if (newlim->d_fieldmask & QC_RT_SPC_WARNS)
defq->rtbwarnlimit = newlim->d_rt_spc_warns; defq->rtb.warn = newlim->d_rt_spc_warns;
} }
/* /*
...@@ -579,11 +579,11 @@ xfs_qm_scall_setqlim( ...@@ -579,11 +579,11 @@ xfs_qm_scall_setqlim(
if (id == 0) { if (id == 0) {
if (newlim->d_fieldmask & QC_SPC_TIMER) if (newlim->d_fieldmask & QC_SPC_TIMER)
defq->btimelimit = newlim->d_spc_timer; defq->blk.time = newlim->d_spc_timer;
if (newlim->d_fieldmask & QC_INO_TIMER) if (newlim->d_fieldmask & QC_INO_TIMER)
defq->itimelimit = newlim->d_ino_timer; defq->ino.time = newlim->d_ino_timer;
if (newlim->d_fieldmask & QC_RT_SPC_TIMER) if (newlim->d_fieldmask & QC_RT_SPC_TIMER)
defq->rtbtimelimit = newlim->d_rt_spc_timer; defq->rtb.time = newlim->d_rt_spc_timer;
} }
if (id != 0) { if (id != 0) {
......
...@@ -37,12 +37,12 @@ xfs_qm_fill_state( ...@@ -37,12 +37,12 @@ xfs_qm_fill_state(
tstate->flags |= QCI_SYSFILE; tstate->flags |= QCI_SYSFILE;
tstate->blocks = ip->i_d.di_nblocks; tstate->blocks = ip->i_d.di_nblocks;
tstate->nextents = ip->i_df.if_nextents; tstate->nextents = ip->i_df.if_nextents;
tstate->spc_timelimit = (u32)defq->btimelimit; tstate->spc_timelimit = (u32)defq->blk.time;
tstate->ino_timelimit = (u32)defq->itimelimit; tstate->ino_timelimit = (u32)defq->ino.time;
tstate->rt_spc_timelimit = (u32)defq->rtbtimelimit; tstate->rt_spc_timelimit = (u32)defq->rtb.time;
tstate->spc_warnlimit = defq->bwarnlimit; tstate->spc_warnlimit = defq->blk.warn;
tstate->ino_warnlimit = defq->iwarnlimit; tstate->ino_warnlimit = defq->ino.warn;
tstate->rt_spc_warnlimit = defq->rtbwarnlimit; tstate->rt_spc_warnlimit = defq->rtb.warn;
if (tempqip) if (tempqip)
xfs_irele(ip); xfs_irele(ip);
} }
......
...@@ -587,25 +587,25 @@ xfs_trans_dqresv( ...@@ -587,25 +587,25 @@ xfs_trans_dqresv(
if (flags & XFS_TRANS_DQ_RES_BLKS) { if (flags & XFS_TRANS_DQ_RES_BLKS) {
hardlimit = dqp->q_blk.hardlimit; hardlimit = dqp->q_blk.hardlimit;
if (!hardlimit) if (!hardlimit)
hardlimit = defq->bhardlimit; hardlimit = defq->blk.hard;
softlimit = dqp->q_blk.softlimit; softlimit = dqp->q_blk.softlimit;
if (!softlimit) if (!softlimit)
softlimit = defq->bsoftlimit; softlimit = defq->blk.soft;
timer = dqp->q_blk.timer; timer = dqp->q_blk.timer;
warns = dqp->q_blk.warnings; warns = dqp->q_blk.warnings;
warnlimit = defq->bwarnlimit; warnlimit = defq->blk.warn;
resbcountp = &dqp->q_blk.reserved; resbcountp = &dqp->q_blk.reserved;
} else { } else {
ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
hardlimit = dqp->q_rtb.hardlimit; hardlimit = dqp->q_rtb.hardlimit;
if (!hardlimit) if (!hardlimit)
hardlimit = defq->rtbhardlimit; hardlimit = defq->rtb.hard;
softlimit = dqp->q_rtb.softlimit; softlimit = dqp->q_rtb.softlimit;
if (!softlimit) if (!softlimit)
softlimit = defq->rtbsoftlimit; softlimit = defq->rtb.soft;
timer = dqp->q_rtb.timer; timer = dqp->q_rtb.timer;
warns = dqp->q_rtb.warnings; warns = dqp->q_rtb.warnings;
warnlimit = defq->rtbwarnlimit; warnlimit = defq->rtb.warn;
resbcountp = &dqp->q_rtb.reserved; resbcountp = &dqp->q_rtb.reserved;
} }
...@@ -640,13 +640,13 @@ xfs_trans_dqresv( ...@@ -640,13 +640,13 @@ xfs_trans_dqresv(
total_count = dqp->q_ino.reserved + ninos; total_count = dqp->q_ino.reserved + ninos;
timer = dqp->q_ino.timer; timer = dqp->q_ino.timer;
warns = dqp->q_ino.warnings; warns = dqp->q_ino.warnings;
warnlimit = defq->iwarnlimit; warnlimit = defq->ino.warn;
hardlimit = dqp->q_ino.hardlimit; hardlimit = dqp->q_ino.hardlimit;
if (!hardlimit) if (!hardlimit)
hardlimit = defq->ihardlimit; hardlimit = defq->ino.hard;
softlimit = dqp->q_ino.softlimit; softlimit = dqp->q_ino.softlimit;
if (!softlimit) if (!softlimit)
softlimit = defq->isoftlimit; softlimit = defq->ino.soft;
if (hardlimit && total_count > hardlimit) { if (hardlimit && total_count > hardlimit) {
xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN); xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment