aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2007-12-22 17:03:25 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-12-23 15:54:36 -0500
commitc525460e2754dbb33abe2b37d3d941126b2ea830 (patch)
treed19e59a039ef0e58ef8a2ec4dbbd8e4493dadd77
parent22dd483721939b4ea22d5d3925e69112f63c42bc (diff)
Don't send quota messages repeatedly when hardlimit reached
We should send quota message to netlink only once when hardlimit is reached. Otherwise user could easily make the system busy by trying to exceed the hardlimit (and also the messages could be anoying if you cannot stop writing just now). Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/dquot.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/fs/dquot.c b/fs/dquot.c
index b2592abaa713..cee7c6f428f0 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -827,6 +827,18 @@ static inline void dquot_decr_space(struct dquot *dquot, qsize_t number)
827 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 827 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
828} 828}
829 829
830static int warning_issued(struct dquot *dquot, const int warntype)
831{
832 int flag = (warntype == QUOTA_NL_BHARDWARN ||
833 warntype == QUOTA_NL_BSOFTLONGWARN) ? DQ_BLKS_B :
834 ((warntype == QUOTA_NL_IHARDWARN ||
835 warntype == QUOTA_NL_ISOFTLONGWARN) ? DQ_INODES_B : 0);
836
837 if (!flag)
838 return 0;
839 return test_and_set_bit(flag, &dquot->dq_flags);
840}
841
830#ifdef CONFIG_PRINT_QUOTA_WARNING 842#ifdef CONFIG_PRINT_QUOTA_WARNING
831static int flag_print_warnings = 1; 843static int flag_print_warnings = 1;
832 844
@@ -845,16 +857,12 @@ static inline int need_print_warning(struct dquot *dquot)
845} 857}
846 858
847/* Print warning to user which exceeded quota */ 859/* Print warning to user which exceeded quota */
848static void print_warning(struct dquot *dquot, const char warntype) 860static void print_warning(struct dquot *dquot, const int warntype)
849{ 861{
850 char *msg = NULL; 862 char *msg = NULL;
851 struct tty_struct *tty; 863 struct tty_struct *tty;
852 int flag = (warntype == QUOTA_NL_BHARDWARN ||
853 warntype == QUOTA_NL_BSOFTLONGWARN) ? DQ_BLKS_B :
854 ((warntype == QUOTA_NL_IHARDWARN ||
855 warntype == QUOTA_NL_ISOFTLONGWARN) ? DQ_INODES_B : 0);
856 864
857 if (!need_print_warning(dquot) || (flag && test_and_set_bit(flag, &dquot->dq_flags))) 865 if (!need_print_warning(dquot))
858 return; 866 return;
859 867
860 mutex_lock(&tty_mutex); 868 mutex_lock(&tty_mutex);
@@ -969,7 +977,8 @@ static inline void flush_warnings(struct dquot * const *dquots, char *warntype)
969 int i; 977 int i;
970 978
971 for (i = 0; i < MAXQUOTAS; i++) 979 for (i = 0; i < MAXQUOTAS; i++)
972 if (dquots[i] != NODQUOT && warntype[i] != QUOTA_NL_NOWARN) { 980 if (dquots[i] != NODQUOT && warntype[i] != QUOTA_NL_NOWARN &&
981 !warning_issued(dquots[i], warntype[i])) {
973#ifdef CONFIG_PRINT_QUOTA_WARNING 982#ifdef CONFIG_PRINT_QUOTA_WARNING
974 print_warning(dquots[i], warntype[i]); 983 print_warning(dquots[i], warntype[i]);
975#endif 984#endif