aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_qm.c
diff options
context:
space:
mode:
authorCarlos Maiolino <cmaiolino@redhat.com>2016-02-07 19:27:55 -0500
committerDave Chinner <david@fromorbit.com>2016-02-07 19:27:55 -0500
commitbe6079461abf796e29d02b450a16908f4bf58f6c (patch)
tree0f4454763b5f89cd966387414a64c067640b244e /fs/xfs/xfs_qm.c
parent296c24e26ee3af2dbfecb482e6bc9560bd34c455 (diff)
xfs: Split default quota limits by quota type
Default quotas are globally set due historical reasons. IRIX only supported user and project quotas, and default quota was only applied to user quotas. In Linux, when a default quota is set, all different quota types inherits the same default value. An user with a quota limit larger than the default quota value, will still be limited to the default value because the group quotas also inherits the default quotas. Unless the group which the user belongs to have a custom quota limit set. This patch aims to split the default quota value by quota type. Allowing each quota type having different default values. Default time limits are still set globally. XFS does not set a per-user/group timer, but a single global timer. For changing this behavior, some changes should be made in user-space tools another bugs being fixed. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_qm.c')
-rw-r--r--fs/xfs/xfs_qm.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 532ab79d38fe..be125e1758c1 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -560,6 +560,37 @@ xfs_qm_shrink_count(
560 return list_lru_shrink_count(&qi->qi_lru, sc); 560 return list_lru_shrink_count(&qi->qi_lru, sc);
561} 561}
562 562
563STATIC void
564xfs_qm_set_defquota(
565 xfs_mount_t *mp,
566 uint type,
567 xfs_quotainfo_t *qinf)
568{
569 xfs_dquot_t *dqp;
570 struct xfs_def_quota *defq;
571 int error;
572
573 error = xfs_qm_dqread(mp, 0, type, XFS_QMOPT_DOWARN, &dqp);
574
575 if (!error) {
576 xfs_disk_dquot_t *ddqp = &dqp->q_core;
577
578 defq = xfs_get_defquota(dqp, qinf);
579
580 /*
581 * Timers and warnings have been already set, let's just set the
582 * default limits for this quota type
583 */
584 defq->bhardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
585 defq->bsoftlimit = be64_to_cpu(ddqp->d_blk_softlimit);
586 defq->ihardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
587 defq->isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit);
588 defq->rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
589 defq->rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
590 xfs_qm_dqdestroy(dqp);
591 }
592}
593
563/* 594/*
564 * This initializes all the quota information that's kept in the 595 * This initializes all the quota information that's kept in the
565 * mount structure 596 * mount structure
@@ -606,19 +637,19 @@ xfs_qm_init_quotainfo(
606 * We try to get the limits from the superuser's limits fields. 637 * We try to get the limits from the superuser's limits fields.
607 * This is quite hacky, but it is standard quota practice. 638 * This is quite hacky, but it is standard quota practice.
608 * 639 *
609 * We look at the USR dquot with id == 0 first, but if user quotas
610 * are not enabled we goto the GRP dquot with id == 0.
611 * We don't really care to keep separate default limits for user
612 * and group quotas, at least not at this point.
613 *
614 * Since we may not have done a quotacheck by this point, just read 640 * Since we may not have done a quotacheck by this point, just read
615 * the dquot without attaching it to any hashtables or lists. 641 * the dquot without attaching it to any hashtables or lists.
642 *
643 * Timers and warnings are globally set by the first timer found in
644 * user/group/proj quota types, otherwise a default value is used.
645 * This should be split into different fields per quota type.
616 */ 646 */
617 error = xfs_qm_dqread(mp, 0, 647 error = xfs_qm_dqread(mp, 0,
618 XFS_IS_UQUOTA_RUNNING(mp) ? XFS_DQ_USER : 648 XFS_IS_UQUOTA_RUNNING(mp) ? XFS_DQ_USER :
619 (XFS_IS_GQUOTA_RUNNING(mp) ? XFS_DQ_GROUP : 649 (XFS_IS_GQUOTA_RUNNING(mp) ? XFS_DQ_GROUP :
620 XFS_DQ_PROJ), 650 XFS_DQ_PROJ),
621 XFS_QMOPT_DOWARN, &dqp); 651 XFS_QMOPT_DOWARN, &dqp);
652
622 if (!error) { 653 if (!error) {
623 xfs_disk_dquot_t *ddqp = &dqp->q_core; 654 xfs_disk_dquot_t *ddqp = &dqp->q_core;
624 655
@@ -639,13 +670,6 @@ xfs_qm_init_quotainfo(
639 be16_to_cpu(ddqp->d_iwarns) : XFS_QM_IWARNLIMIT; 670 be16_to_cpu(ddqp->d_iwarns) : XFS_QM_IWARNLIMIT;
640 qinf->qi_rtbwarnlimit = ddqp->d_rtbwarns ? 671 qinf->qi_rtbwarnlimit = ddqp->d_rtbwarns ?
641 be16_to_cpu(ddqp->d_rtbwarns) : XFS_QM_RTBWARNLIMIT; 672 be16_to_cpu(ddqp->d_rtbwarns) : XFS_QM_RTBWARNLIMIT;
642 qinf->qi_bhardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
643 qinf->qi_bsoftlimit = be64_to_cpu(ddqp->d_blk_softlimit);
644 qinf->qi_ihardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
645 qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit);
646 qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
647 qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
648
649 xfs_qm_dqdestroy(dqp); 673 xfs_qm_dqdestroy(dqp);
650 } else { 674 } else {
651 qinf->qi_btimelimit = XFS_QM_BTIMELIMIT; 675 qinf->qi_btimelimit = XFS_QM_BTIMELIMIT;
@@ -656,6 +680,13 @@ xfs_qm_init_quotainfo(
656 qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT; 680 qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
657 } 681 }
658 682
683 if (XFS_IS_UQUOTA_RUNNING(mp))
684 xfs_qm_set_defquota(mp, XFS_DQ_USER, qinf);
685 if (XFS_IS_GQUOTA_RUNNING(mp))
686 xfs_qm_set_defquota(mp, XFS_DQ_GROUP, qinf);
687 if (XFS_IS_PQUOTA_RUNNING(mp))
688 xfs_qm_set_defquota(mp, XFS_DQ_PROJ, qinf);
689
659 qinf->qi_shrinker.count_objects = xfs_qm_shrink_count; 690 qinf->qi_shrinker.count_objects = xfs_qm_shrink_count;
660 qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan; 691 qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
661 qinf->qi_shrinker.seeks = DEFAULT_SEEKS; 692 qinf->qi_shrinker.seeks = DEFAULT_SEEKS;