[Dovecot] [BUG] Incorrect maildir quota value after maildirsize creation

Adam Osuchowski adwol at zonk.pl
Sun Jul 12 22:25:47 EEST 2009


I found a problem with maildir++ quota. When dovecot creates maildirsize
file, it counts quota wrong. This is, how I reproduce a situation on
version 1.2.0:

First, I remove maildirsize file:

# cd /var/mail/test
# rm -f maildirsize
# ls -la
total 32
drwx--S--- 5 mbox mbox 4096 Jul 12 20:45 .
drwxrwsr-x 3 root mbox 4096 Jul 12 20:39 ..
drwx--S--- 2 mbox mbox 4096 Jul  9 20:45 cur
-rw------- 1 mbox mbox  491 Jul 12 20:45 dovecot-uidlist
-rw------- 1 mbox mbox    8 Jul 12 20:45 dovecot-uidvalidity
-rw------- 1 mbox mbox 8536 Jul 12 20:45 dovecot.index.cache
-rw------- 1 mbox mbox  284 Jul 12 20:45 dovecot.index.log
drwx--S--- 2 mbox mbox 4096 Jul 12 00:58 new
drwx--S--- 2 mbox mbox 4096 Jul 12 00:58 tmp

I have 8 emails which take 14183471 bytes together:

# find cur new -type f | wc -l
8
# find cur new -type f -printf '%s\n' | awk 'END { print a } { a += $0 }'
14183471

Now, I connect to dovecot via POP3 and delete exactly _one_ email which
takes 969 bytes. After that, maildirsize file has been created:

# ls -la
total 48
drwx--S--- 5 mbox mbox 4096 Jul 12 20:50 .
drwxrwsr-x 3 root mbox 4096 Jul 12 20:39 ..
drwx--S--- 2 mbox mbox 4096 Jul 12 20:50 cur
-rw------- 1 mbox mbox  491 Jul 12 20:45 dovecot-uidlist
-rw------- 1 mbox mbox    8 Jul 12 20:45 dovecot-uidvalidity
-rw------- 1 mbox mbox 8536 Jul 12 20:50 dovecot.index.cache
-rw------- 1 mbox mbox  532 Jul 12 20:50 dovecot.index.log
-rw------- 1 mbox mbox   28 Jul 12 20:50 maildirsize
drwx--S--- 2 mbox mbox 4096 Jul  9 00:58 new
drwx--S--- 2 mbox mbox 4096 Jul  9 00:58 tmp
# cat maildirsize
5242880S
14182502 7
-969 -1

So, maildirsize says, that there should be 7-1=6 emails which should take
14182502-969=14181533 bytes together. In fact, there are 7 emails (I delete
only one of eight emails) which take 14182502 bytes together (deleted
email taked 969 bytes):

# find cur new -type f | wc -l
7
# find cur new -type f -printf '%s\n' | awk 'END { print a } { a += $0 }'
14182502

I figured, that dovecot after physically file removal, calls function
maildir_quota_update(), which calls maildirquota_refresh() first (which
in turn recalculate quota with new values), and then calls
maildirsize_update(), which additionally and incorrectly decreases quota
value.

Regards,
Adam.


More information about the dovecot mailing list