imho, dovecot 1.00 RC2 has two bugs at the maildir quota implementation 1. Incorrect calculation of used storage and count of messages When calculating, dovecot counts "." and ".." directory entries. So, if there are no subdirs and messages in maildir, maildirsize still shows 4 messages and some used storage. My workaround is --- src/plugins/quota/quota-maildir.c.orig Sun Jun 11 21:36:24 2006 +++ src/plugins/quota/quota-maildir.c Thu Jul 13 11:33:58 2006 =======================================================@@ -82,6 +82,8 @@ len = str_len(path); while ((dp = readdir(dirp)) != NULL) { + if (!strcmp(dp->d_name, ".")) continue; + if (!strcmp(dp->d_name, "..")) continue; p = strstr(dp->d_name, ",S="); num = (uoff_t)-1; if (p != NULL) { =======================================================This patch skips special directory entries. 2. Under some condition maildirsize contains invalid data Consider a such situation 1. User begins pop3 session 2. dovecot calls this sequence of procedures maildir_quota_transaction_begin -> maildirquota_refresh -> maildirsize_read While reading maildirsize's data, may be situation when mailbox size must be recalculated (maildirsize greater 5120, quotas was changed...). In this case dovecot closes maildirsize's file descriptor (root->fd) and assigns it "-1". After that code calls maildirsize_recalculate -> maildirsize_write So maildirsize is rewritten and contains valid data. BUT file descriptor (root->fd) still contains "-1" 3. User retrieves and deletes some messages, then quits. So maildirsize must be updated. 4. Code calls maildir_quota_transaction_commit, but root->fd equals "-1", so maildirsize_update doesn't calls and maildirsize contains incorrect (obsolete) data My workaround is =======================================================--- src/plugins/quota/quota-maildir.c.orig Sun Jun 11 21:36:24 2006 +++ src/plugins/quota/quota-maildir.c Thu Jul 13 11:33:58 2006 @@ -246,11 +248,12 @@ return -1; } - if (file_dotlock_replace(&dotlock, 0) < 0) { + if (file_dotlock_replace(&dotlock, DOTLOCK_REPLACE_FLAG_DONT_CLOSE_FD) < 0) { mail_storage_set_critical(storage, "file_dotlock_replace(%s) failed: %m", path); return -1; } + root->fd = fd; return 0; } =======================================================This patch preserves fd after writing recalculated maildirsize file, and when maildir_quota_transaction_commit is called, root->fd contains valid file descriptor. -- Alexander Zagrebin