[Dovecot] Problems with the fs-quota plugin on delivery stage
Hi All!
Just noticed a strange behavior of the FS quota plugin on delivery stage. We use group FS quotas via NFS. And quota-tool says:
Disk quotas for group #5751796 (gid 5751796): Filesystem blocks quota limit grace nfse:/export 1276 10240 10240
I run:
cat ./test.eml | /usr/local/libexec/dovecot/deliver -e -n -d xxxx@xxxxx.xxxx
and get:
Quota exceeded (mailbox for user is full)
But ./test.eml is 7088147 bytes and it is not above the quota.
dovecot debug log is:
May 12 20:01:46 dovecot: deliver(xxxx@xxxxx.xxxx): fs quota block device = nfse:/export May 12 20:01:46 dovecot: deliver(xxxx@xxxxx.xxxx): fs quota mount point = /mount/m5 May 12 20:01:47 dovecot: deliver(xxxx@xxxxx.xxxx): quota-fs: host=nfse, path=/export, gid=5751796, bytes May 12 20:01:47 dovecot: deliver(xxxx@xxxxx.xxxx): quota-fs: gid=5751796, value=8409088, limit=10485760, active=1 May 12 20:01:47 dovecot: deliver(xxxx@xxxxx.xxxx): from=xxxx@xxxxx.xxxx, msgid=<4BEA4744.1040701@xxxx@xxxxx.xxxx>: save failed to INBOX: Quota exceeded (mailbox for user is full)
It seems that "value=8409088, limit=10485760" shows that the quota is no problem, but "save failed".
If I become that user, then no problems. I can copy ./test.eml without problems. Now quota-tool says:
Filesystem blocks quota limit grace nfse:/export 8212 10240 10240
If I try to copy again(over quota), then honestly get:
cp: closing `./test2.msg': Disk quota exceeded
If I switch off quota plugin on dovecot.conf (LDA specific settings), then:
- The first delivery is without error, but the INBOX is corrupted(last msg is clipped) but quota-tool show only 3300 blocks used (quota is 10240 blocks).
- Following delivery big msgs (over quoted) ends with an error: "Not enough disk space" (this is correct, because the quota is really ended)
- Following delivery small msgs (above quoted) ends well, msgs are delivered (used 3304 blocks and etc.)
Our setup: -- slackware 11.0, x86_32 -- linux 2.6.31.6 -- dovecot 1.2.11 -- mailbox(not maildir) via NFS storage.
Please, tell me where to start looking for the problem?
=kostik
Kostik wrote:
Just noticed a strange behavior of the FS quota plugin on delivery stage.
My /usr/local/sbin/dovecot -n is:
# 1.2.11: /usr/local/etc/dovecot.conf # OS: Linux 2.6.32.12 i686 Slackware 11.0.0 base_dir: /var/run/dovecot/ protocols: imap pop3 listen(default): *:143 listen(imap): *:143 listen(pop3): *:110 disable_plaintext_auth: no login_dir: /var/run/dovecot/login login_executable(default): /usr/local/libexec/dovecot/imap-login login_executable(imap): /usr/local/libexec/dovecot/imap-login login_executable(pop3): /usr/local/libexec/dovecot/pop3-login mail_debug: yes mmap_disable: yes mail_nfs_storage: yes mail_nfs_index: yes lock_method: dotlock mbox_read_locks: dotlock_try mbox_write_locks: dotlock_try mbox_lock_timeout: 150 mbox_dotlock_change_timeout: 60 mbox_very_dirty_syncs: yes mail_executable(default): /usr/local/libexec/dovecot/imap mail_executable(imap): /usr/local/libexec/dovecot/imap mail_executable(pop3): /usr/local/libexec/dovecot/pop3 mail_plugins(default): quota imap_quota mail_log mail_plugins(imap): quota imap_quota mail_log mail_plugins(pop3): mail_plugin_dir(default): /usr/local/lib/dovecot/imap mail_plugin_dir(imap): /usr/local/lib/dovecot/imap mail_plugin_dir(pop3): /usr/local/lib/dovecot/pop3 pop3_no_flag_updates(default): no pop3_no_flag_updates(imap): no pop3_no_flag_updates(pop3): yes pop3_client_workarounds(default): pop3_client_workarounds(imap): pop3_client_workarounds(pop3): outlook-no-nuls oe-ns-eoh lda: postmaster_address: MAILER-DAEMON@xxxxx.xxxx quota_full_tempfail: no deliver_log_format: from=<%f>, msgid=%m: %$ sendmail_path: /usr/lib/sendmail rejection_subject: Rejected: %s rejection_reason: Your message to <%t> was automatically rejected:%n%r auth_socket_path: /var/run/dovecot/auth-master auth default: mechanisms: plain login debug: yes passdb: driver: sql userdb: driver: prefetch socket: type: listen master: path: /var/run/dovecot/auth-master mode: 384 plugin: quota: fs:Quota:user mail_log_events: delete undelete expunge copy mailbox_delete mailbox_rename mail_log_fields: box from subject size
=kostik
Hi!
Kostik wrote:
Just noticed a strange behavior of the FS quota plugin on delivery stage.
Is there anyone know? This log message...
May 12 20:01:47 dovecot: deliver(xxxx@xxxxx.xxxx): quota-fs: gid=5751796, value=8409088, limit=10485760, active=1
shows "value=8409088" before or after delivery?
I added debugging printf() into src/plugins/quota/quota.c and got strange data. When I try to deliver 7088147 bytes msg into 10485760 bytes limit mailbox with 1320941 bytes already used, then in:
static int quota_default_test_alloc(...) is:
if (ctx->count_left != 0 && ctx->bytes_left >= ctx->bytes_used + size) return 1;
I get:
ctx->bytes_left = 2076672 ctx->bytes_used = 0 msg size = 7088147 and current limits are: current(used)=8409088 limit=10485760
It's very odd, because the msg is not yet delivered, but the disk space is already occupied. The INBOX file actually does not contain this message, but quota-tool already shows the new used space as if already with the received message.
Is this correct? Because the msg could not be delivered in a mailbox, but does not exceed its limit.
=kositk
Kostik wrote:
Just noticed a strange behavior of the FS quota plugin on delivery stage. Is there anyone know? This log message...
May 12 20:01:47 dovecot: deliver(xxxx@xxxxx.xxxx): quota-fs: gid=5751796, value=8409088, limit=10485760, active=1
shows "value=8409088" before or after delivery?
I think I localized the problem:
When dovecot deliver create temp file (from here ./src/lib/istream-seekable.c), then it create temp file in users homedir. If users homedir under fs-quota then used space growing. Then when deliver tries to deliver this msg in INBOX, quota plugin return used space already WITH temp file. But it is not correct, because the message size is taken into account twice.
Timo or someone else: how to change the location for creating temporary files and to avoid such deliver behavior?
=kostik
On Mon, 2010-05-17 at 17:02 +0400, Kostik wrote:
May 12 20:01:47 dovecot: deliver(xxxx@xxxxx.xxxx): from=xxxx@xxxxx.xxxx, msgid=<4BEA4744.1040701@xxxx@xxxxx.xxxx>: save failed to INBOX: Quota exceeded (mailbox for user is full)
BTW. It's also possible to use :noenforcing flag so Dovecot wouldn't try to enforce the quota limit but just let the write() on filesystem fail.
Timo or someone else: how to change the location for creating temporary files and to avoid such deliver behavior?
Hmmh. I kind of hate the idea of making this configurable.. Maybe if filesystem quota is enabled, Dovecot should use /tmp and otherwise home. Yeah, did that to v2.0:
http://hg.dovecot.org/dovecot-2.0/rev/e63dd7e7ea6e http://hg.dovecot.org/dovecot-2.0/rev/bd8ed4b97fe3
If someone still really wants to use some other directory, it's possible to write a plugin to override it.
participants (2)
-
Kostik
-
Timo Sirainen