2004-10-21 16:19:02

by Jan Engelhardt

[permalink] [raw]
Subject: Quota warnings somewhat broken

Hello,


When a user exceeds his soft (and hard) disk quota, a warning message is
printed to current->tty. However, output is a bit offset:

$ dd if=/dev/zero of=blk bs=1024 count=100000
hda1: write failed, user block limit reached.
dd: opening `blk': Disk quota exceeded

This is due to the messages in fs/dquot.c only ending in "\n" but should
probably end in "\r\n".
A patch can be found @
http://linux01.org:2222/f/hxtools/kernel/265-quota_warnfix.diff (only use the
dquot.c chunk). Despite it saying 2.6.4, it's still in 2.6.9.

Any takers?



Jan Engelhardt
--
Gesellschaft f?r Wissenschaftliche Datenverarbeitung
Am Fassberg, 37077 G?ttingen, http://www.gwdg.de
Tel 0162.3520895 or 05502.3009.63


2004-10-22 09:40:37

by Jan Kara

[permalink] [raw]
Subject: [PATCH] Quota warnings somewhat broken

Hello,

> When a user exceeds his soft (and hard) disk quota, a warning message is
> printed to current->tty. However, output is a bit offset:
>
> $ dd if=/dev/zero of=blk bs=1024 count=100000
> hda1: write failed, user block limit reached.
> dd: opening `blk': Disk quota exceeded
>
> This is due to the messages in fs/dquot.c only ending in "\n" but should
> probably end in "\r\n".
Thanks for notifying. It looks like a good idea. Attached patch should apply
well to 2.6.9. Linus, please apply.

Honza

Fix end of lines in quota messages.
Signed-off-by: Jan Kara

diff -ru linux-2.6.8.1/fs/dquot.c linux-2.6.8.1-messfix/fs/dquot.c
--- linux-2.6.8.1/fs/dquot.c 2004-10-19 12:07:08.000000000 +0200
+++ linux-2.6.8.1-messfix/fs/dquot.c 2004-10-22 11:28:26.678037906 +0200
@@ -811,22 +811,22 @@
tty_write_message(current->signal->tty, quotatypes[dquot->dq_type]);
switch (warntype) {
case IHARDWARN:
- msg = " file limit reached.\n";
+ msg = " file limit reached.\r\n";
break;
case ISOFTLONGWARN:
- msg = " file quota exceeded too long.\n";
+ msg = " file quota exceeded too long.\r\n";
break;
case ISOFTWARN:
- msg = " file quota exceeded.\n";
+ msg = " file quota exceeded.\r\n";
break;
case BHARDWARN:
- msg = " block limit reached.\n";
+ msg = " block limit reached.\r\n";
break;
case BSOFTLONGWARN:
- msg = " block quota exceeded too long.\n";
+ msg = " block quota exceeded too long.\r\n";
break;
case BSOFTWARN:
- msg = " block quota exceeded.\n";
+ msg = " block quota exceeded.\r\n";
break;
}
tty_write_message(current->signal->tty, msg);

2004-10-22 15:07:20

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] Quota warnings somewhat broken



On Fri, 22 Oct 2004, Jan Kara wrote:
>
> Thanks for notifying. It looks like a good idea. Attached patch should apply
> well to 2.6.9. Linus, please apply.

Why does this code use tty_write_message() in the first place? It's a bit
rude to mess up the users tty without any way to disable it, isn't it?

Linus

2004-10-22 15:28:38

by Alan

[permalink] [raw]
Subject: Re: [PATCH] Quota warnings somewhat broken

On Gwe, 2004-10-22 at 16:07, Linus Torvalds wrote:
> Why does this code use tty_write_message() in the first place? It's a bit
> rude to mess up the users tty without any way to disable it, isn't it?

Tradition I guess. It's what every other quota system does, including
making annoying messes. In the new world order I guess it should be a
netlink message out to dbus and the desktop ;)

2004-10-22 17:17:21

by Jan Engelhardt

[permalink] [raw]
Subject: [PATCH] Re: [PATCH] Quota warnings somewhat broken


>> Why does this code use tty_write_message() in the first place? It's a bit
>> rude to mess up the users tty without any way to disable it, isn't it?

See http://linux01.org:2222/f/hxtools/kernel/265-quota_warnflag.diff for a
patch that allows the administrator of the local box to change this behavior
via sysctl.

>Tradition I guess. It's what every other quota system does, including
>making annoying messes. In the new world order I guess it should be a
>netlink message out to dbus and the desktop ;)



Jan Engelhardt
--
Gesellschaft f?r Wissenschaftliche Datenverarbeitung
Am Fassberg, 37077 G?ttingen, http://www.gwdg.de
Tel 0162.3520895 or 05502.3009.63

2004-10-22 23:39:48

by Chris Wedgwood

[permalink] [raw]
Subject: Re: [PATCH] Quota warnings somewhat broken

On Fri, Oct 22, 2004 at 03:25:06PM +0100, Alan Cox wrote:

> Tradition I guess. It's what every other quota system does,
> including making annoying messes. In the new world order I guess it
> should be a netlink message out to dbus and the desktop ;)

it's pretty obnoxious as-is and ideally if people want to preserve
this it should be sysctl'able off or something

2004-10-25 11:15:30

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] Quota warnings somewhat broken

> On Fri, 22 Oct 2004, Jan Kara wrote:
> >
> > Thanks for notifying. It looks like a good idea. Attached patch should apply
> > well to 2.6.9. Linus, please apply.
>
> Why does this code use tty_write_message() in the first place? It's a bit
> rude to mess up the users tty without any way to disable it, isn't it?
OK, I'll tide up a bit a patch of Jan Engelhardt <[email protected]>
and send it to you.

Honza
--
Jan Kara <[email protected]>
SuSE CR Labs

2004-10-27 12:29:46

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] Quota warnings somewhat broken

> > On Fri, 22 Oct 2004, Jan Kara wrote:
> > >
> > > Thanks for notifying. It looks like a good idea. Attached patch should apply
> > > well to 2.6.9. Linus, please apply.
> >
> > Why does this code use tty_write_message() in the first place? It's a bit
> > rude to mess up the users tty without any way to disable it, isn't it?
> OK, I'll tide up a bit a patch of Jan Engelhardt <[email protected]>
> and send it to you.
Here's the promised patch to allow root to turn off quota warnings
into the console. The patch is based on the one by Jan Engelhardt. Please
apply.
Honza

Allow root to turn off quota warnings into the console.

Signed-off-by: Jan Kara <[email protected]>

diff -ru linux-2.6.9/fs/dquot.c linux-2.6.9-quotawarn/fs/dquot.c
--- linux-2.6.9/fs/dquot.c 2004-10-18 23:54:39.000000000 +0200
+++ linux-2.6.9-quotawarn/fs/dquot.c 2004-10-25 15:48:56.000000000 +0200
@@ -774,8 +774,13 @@
clear_bit(DQ_BLKS_B, &dquot->dq_flags);
}

+static int flag_print_warnings = 1;
+
static inline int need_print_warning(struct dquot *dquot)
{
+ if (!flag_print_warnings)
+ return 0;
+
switch (dquot->dq_type) {
case USRQUOTA:
return current->fsuid == dquot->dq_id;
@@ -803,6 +808,7 @@

if (!need_print_warning(dquot) || (flag && test_and_set_bit(flag, &dquot->dq_flags)))
return;
+
tty_write_message(current->signal->tty, dquot->dq_sb->s_id);
if (warntype == ISOFTWARN || warntype == BSOFTWARN)
tty_write_message(current->signal->tty, ": warning, ");
@@ -1722,6 +1728,14 @@
.mode = 0444,
.proc_handler = &proc_dointvec,
},
+ {
+ .ctl_name = FS_DQ_WARNINGS,
+ .procname = "warnings",
+ .data = &flag_print_warnings,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec,
+ },
{ .ctl_name = 0 },
};

diff -ru linux-2.6.9/include/linux/sysctl.h linux-2.6.9-quotawarn/include/linux/sysctl.h
--- linux-2.6.9/include/linux/sysctl.h 2004-10-18 23:54:31.000000000 +0200
+++ linux-2.6.9-quotawarn/include/linux/sysctl.h 2004-10-25 15:43:47.000000000 +0200
@@ -662,7 +662,7 @@
FS_LEASES=13, /* int: leases enabled */
FS_DIR_NOTIFY=14, /* int: directory notification enabled */
FS_LEASE_TIME=15, /* int: maximum time to wait for a lease break */
- FS_DQSTATS=16, /* disc quota usage statistics */
+ FS_DQSTATS=16, /* disc quota usage statistics and control */
FS_XFS=17, /* struct: control xfs parameters */
FS_AIO_NR=18, /* current system-wide number of aio requests */
FS_AIO_MAX_NR=19, /* system-wide maximum number of aio requests */
@@ -678,6 +678,7 @@
FS_DQ_ALLOCATED = 6,
FS_DQ_FREE = 7,
FS_DQ_SYNCS = 8,
+ FS_DQ_WARNINGS = 9,
};

/* CTL_DEBUG names: */