Skip to content

Commit c525460

Browse files
jankaraLinus Torvalds
authored andcommitted
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>
1 parent 22dd483 commit c525460

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎fs/dquot.c‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,18 @@ static inline void dquot_decr_space(struct dquot *dquot, qsize_t number)
827827
clear_bit(DQ_BLKS_B, &dquot->dq_flags);
828828
}
829829

830+
static 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+
830842
#ifdef CONFIG_PRINT_QUOTA_WARNING
831843
static int flag_print_warnings = 1;
832844

@@ -845,16 +857,12 @@ static inline int need_print_warning(struct dquot *dquot)
845857
}
846858

847859
/* Print warning to user which exceeded quota */
848-
static void print_warning(struct dquot *dquot, const char warntype)
860+
static void print_warning(struct dquot *dquot, const int warntype)
849861
{
850862
char *msg = NULL;
851863
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);
856864

857-
if (!need_print_warning(dquot) || (flag && test_and_set_bit(flag, &dquot->dq_flags)))
865+
if (!need_print_warning(dquot))
858866
return;
859867

860868
mutex_lock(&tty_mutex);
@@ -969,7 +977,8 @@ static inline void flush_warnings(struct dquot * const *dquots, char *warntype)
969977
int i;
970978

971979
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])) {
973982
#ifdef CONFIG_PRINT_QUOTA_WARNING
974983
print_warning(dquots[i], warntype[i]);
975984
#endif

0 commit comments

Comments
 (0)