Quota inconsistency when copying 2GB of mails

2008-12-18 Thread Ewald Dieterich

Hi,

in Cyrus 2.3.13, when you do an IMAP COPY of mails with a total size of 
more then 2GB, the quota gets inconsistent because some variables 
overflow (at least on systems where sizeof(int) == 4).


The attached patch changes some data types so that IMAP COPY works 
again, but I'm not sure if this is a proper fix.


I think there is a similar problem in MULTIAPPEND (the total size in 
cmd_append() is declared as unsigned) but I didn't test it.


I filed bug 3127 in bugzilla.

Ewald
diff -r -u cyrus-imapd-2.3.13.orig/imap/append.c cyrus-imapd-2.3.13/imap/append.c
--- cyrus-imapd-2.3.13.orig/imap/append.c	2008-09-23 16:19:42.0 +
+++ cyrus-imapd-2.3.13/imap/append.c	2008-12-18 13:25:06.0 +
@@ -107,7 +107,7 @@
  */
 int append_check(const char *name, int format, 
 		 struct auth_state *auth_state,
-		 long aclcheck, long quotacheck)
+		 long aclcheck, quota_t quotacheck)
 {
 struct mailbox m;
 int r;
@@ -173,7 +173,7 @@
 int append_setup(struct appendstate *as, const char *name,
 		 int format, 
 		 const char *userid, struct auth_state *auth_state,
-		 long aclcheck, long quotacheck)
+		 long aclcheck, quota_t quotacheck)
 {
 int r;
 
@@ -251,7 +251,7 @@
 /* may return non-zero, indicating that the entire append has failed
  and the mailbox is probably in an inconsistent state. */
 int append_commit(struct appendstate *as, 
-		  long quotacheck __attribute__((unused)),
+		  quota_t quotacheck __attribute__((unused)),
 		  unsigned long *uidvalidity, 
 		  unsigned long *start,
 		  unsigned long *num)
@@ -323,7 +323,7 @@
 else {
 	quota_abort(as-tid);
 	syslog(LOG_ERR,
-	   LOSTQUOTA: unable to record use of %u bytes in quota file %s,
+	   LOSTQUOTA: unable to record use of  QUOTA_T_FMT  bytes in quota file %s,
 	   as-quota_used, as-m.quota.root);
 }
 
diff -r -u cyrus-imapd-2.3.13.orig/imap/append.h cyrus-imapd-2.3.13/imap/append.h
--- cyrus-imapd-2.3.13.orig/imap/append.h	2008-03-24 17:09:16.0 +
+++ cyrus-imapd-2.3.13/imap/append.h	2008-12-18 13:22:56.0 +
@@ -91,7 +91,7 @@
 int seen_alloced;
 
 /* the amount of quota we've used so far in this append */
-int quota_used;
+quota_t quota_used;
 
 /* txn for updating quota */
 struct txn *tid;
@@ -103,16 +103,16 @@
 
 extern int append_check(const char *name, int format, 
 			struct auth_state *auth_state,
-			long aclcheck, long quotacheck);
+			long aclcheck, quota_t quotacheck);
 
 /* appendstate must be allocated by client */
 extern int append_setup(struct appendstate *mailbox, const char *name,
 			int format, 
 			const char *userid, struct auth_state *auth_state,
-			long aclcheck, long quotacheck);
+			long aclcheck, quota_t quotacheck);
 
 extern int append_commit(struct appendstate *mailbox,
-			 long quotacheck,
+			 quota_t quotacheck,
 			 unsigned long *uidvalidity, 
 			 unsigned long *startuid, 
 			 unsigned long *num);
diff -r -u cyrus-imapd-2.3.13.orig/imap/index.c cyrus-imapd-2.3.13/imap/index.c
--- cyrus-imapd-2.3.13.orig/imap/index.c	2008-10-09 13:59:53.0 +
+++ cyrus-imapd-2.3.13/imap/index.c	2008-12-18 13:22:56.0 +
@@ -1389,7 +1389,7 @@
 {
 static struct copyargs copyargs;
 int i;
-unsigned long totalsize = 0;
+quota_t totalsize = 0;
 int r;
 struct appendstate append_mailbox;
 char *copyuid;

Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

Re: Quota inconsistency...

2004-10-20 Thread Jure Pe_ar
On Mon, 18 Oct 2004 15:20:08 -0400
Scott Adkins [EMAIL PROTECTED] wrote:

 We have a user that was reporting that she was way *way* over her quota.
 She was alotted only 100MB, and for some reason, she was showing that she
 was using over 400MB of space on her IMAP account!  Furthermore, looking
 at actual disk space consumption, she waas actually only using 261KB,
 which is barely anything at all.

Can confirm this on 2.2.6 and 2.2.8. My quota fixing script ran over our
tree tonight and found mailboxes as large as 900mb (our quotas are 10mb by
default). Looks like for these quota was not being updated at all.
I also have many situations where user complains about being 10 times over
quota while they just deleted all their unneeded mail .. 

 I have yet to figure out a good way to fix this discrepancy.  I thought
 that maybe doing a recursive reconstruct on her account would maybe sync
 up her quota entry to what was actually in use.  Nope.  I thought that the
 quota command would be able to do something with it, again nope, unless I
 am just missing an option somwehere.  I even used cyradm to do a
 setquota on the user to see if it would fix it, and again it did not.

I use a shell script that rewrites the quota files. Altough i have no idea
why cyrus doesnt like to modify them on its own. Permissions are ok ...


I first noticed this quota issue a while ago running quota -f -d. After that
some quotas were really off ...


-- 

Jure Pear
http://jure.pecar.org/

---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html


Quota inconsistency...

2004-10-18 Thread Scott Adkins
We have a user that was reporting that she was way *way* over her quota.
She was alotted only 100MB, and for some reason, she was showing that she
was using over 400MB of space on her IMAP account!  Furthermore, looking
at actual disk space consumption, she waas actually only using 261KB,
which is barely anything at all.
I have yet to figure out a good way to fix this discrepancy.  I thought
that maybe doing a recursive reconstruct on her account would maybe sync
up her quota entry to what was actually in use.  Nope.  I thought that the
quota command would be able to do something with it, again nope, unless I
am just missing an option somwehere.  I even used cyradm to do a setquota
on the user to see if it would fix it, and again it did not.
I editted the file (we are using legacy file format, which is plain text)
manually and removed a couple digits.  This brought her down to about 41MB
of disk space used, and thus 41% of her quota.  This gets her working, but
I still can't find a way to have the server re-figure out how much she is
actually using and write that to the file.
I finally just deleted the quota file altogether and used cyradm to create
it again using setquota.  Well, it created a new quota file for her, but
now it shows her sitting at 0KB used out of 100MB, so it is still not right.
Other than doing a du on her disk space and manually typing in the value
in the quota file, what should I be doing?
Thanks,
Scott
--
+---+
 Scott W. Adkinshttp://www.cns.ohiou.edu/~sadkins/
  UNIX Systems Engineer  mailto:[EMAIL PROTECTED]
   ICQ 7626282 Work (740)593-9478 Fax (740)593-1944
+---+
PGP Public Key available at http://www.cns.ohiou.edu/~sadkins/pgp/

pgpwVjbOXHGXy.pgp
Description: PGP signature


Re: Quota inconsistency...

2004-10-18 Thread Derrick J Brashear
On Mon, 18 Oct 2004, Scott Adkins wrote:
We have a user that was reporting that she was way *way* over her quota.
She was alotted only 100MB, and for some reason, she was showing that she
was using over 400MB of space on her IMAP account!  Furthermore, looking
at actual disk space consumption, she waas actually only using 261KB,
which is barely anything at all.
You left out what version of Cyrus you're running. Some quota bugs have 
been fixed over time, if we know what you have it will be easier to know 
what you're hitting.
---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html