aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-01-17 17:36:19 -0500
committerAlex Elder <aelder@sgi.com>2010-01-21 14:44:28 -0500
commita210c1aa7f6c90b729cc3a72d03e789b13cb6c47 (patch)
treeff454424108c99d97fd0797d52330b711f65154a /fs
parent4d1f88d75b00c4d23f4c51305ab5b779a86ef74e (diff)
xfs: implement quota warnings via netlink
Wire up quota_send_warning to send quota warnings over netlink. This is used by various desktops to show user quota warnings. Tested by running the quota_nld daemon while running the xfstest quota tests and observing the warnings. I'll see how I can get a more formal testcase for it written. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/quota/xfs_trans_dquot.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c
index b9db6f781cd6..c3ab75cb1d9a 100644
--- a/fs/xfs/quota/xfs_trans_dquot.c
+++ b/fs/xfs/quota/xfs_trans_dquot.c
@@ -589,6 +589,20 @@ xfs_trans_unreserve_and_mod_dquots(
589 } 589 }
590} 590}
591 591
592STATIC void
593xfs_quota_warn(
594 struct xfs_mount *mp,
595 struct xfs_dquot *dqp,
596 int type)
597{
598 /* no warnings for project quotas - we just return ENOSPC later */
599 if (dqp->dq_flags & XFS_DQ_PROJ)
600 return;
601 quota_send_warning((dqp->dq_flags & XFS_DQ_USER) ? USRQUOTA : GRPQUOTA,
602 be32_to_cpu(dqp->q_core.d_id), mp->m_super->s_dev,
603 type);
604}
605
592/* 606/*
593 * This reserves disk blocks and inodes against a dquot. 607 * This reserves disk blocks and inodes against a dquot.
594 * Flags indicate if the dquot is to be locked here and also 608 * Flags indicate if the dquot is to be locked here and also
@@ -657,13 +671,21 @@ xfs_trans_dqresv(
657 * nblks. 671 * nblks.
658 */ 672 */
659 if (hardlimit > 0ULL && 673 if (hardlimit > 0ULL &&
660 hardlimit <= nblks + *resbcountp) 674 hardlimit <= nblks + *resbcountp) {
675 xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN);
661 goto error_return; 676 goto error_return;
677 }
662 if (softlimit > 0ULL && 678 if (softlimit > 0ULL &&
663 softlimit <= nblks + *resbcountp && 679 softlimit <= nblks + *resbcountp) {
664 ((timer != 0 && get_seconds() > timer) || 680 if ((timer != 0 && get_seconds() > timer) ||
665 (warns != 0 && warns >= warnlimit))) 681 (warns != 0 && warns >= warnlimit)) {
666 goto error_return; 682 xfs_quota_warn(mp, dqp,
683 QUOTA_NL_BSOFTLONGWARN);
684 goto error_return;
685 }
686
687 xfs_quota_warn(mp, dqp, QUOTA_NL_BSOFTWARN);
688 }
667 } 689 }
668 if (ninos > 0) { 690 if (ninos > 0) {
669 count = be64_to_cpu(dqp->q_core.d_icount); 691 count = be64_to_cpu(dqp->q_core.d_icount);
@@ -677,12 +699,19 @@ xfs_trans_dqresv(
677 if (!softlimit) 699 if (!softlimit)
678 softlimit = q->qi_isoftlimit; 700 softlimit = q->qi_isoftlimit;
679 701
680 if (hardlimit > 0ULL && count >= hardlimit) 702 if (hardlimit > 0ULL && count >= hardlimit) {
681 goto error_return; 703 xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN);
682 if (softlimit > 0ULL && count >= softlimit &&
683 ((timer != 0 && get_seconds() > timer) ||
684 (warns != 0 && warns >= warnlimit)))
685 goto error_return; 704 goto error_return;
705 }
706 if (softlimit > 0ULL && count >= softlimit) {
707 if ((timer != 0 && get_seconds() > timer) ||
708 (warns != 0 && warns >= warnlimit)) {
709 xfs_quota_warn(mp, dqp,
710 QUOTA_NL_ISOFTLONGWARN);
711 goto error_return;
712 }
713 xfs_quota_warn(mp, dqp, QUOTA_NL_ISOFTWARN);
714 }
686 } 715 }
687 } 716 }
688 717