Hello,
Is there any reason why dovecot relies on S= instead of real disk size email
takes?
1) compressed mails take less than than the S= specified
2) we could avoid using "S=" for the lookups and count every file
there, including indexes and mails without S=... if we'd read filesizes
Eample:
# ls -l '1567026317.M331058P4751.testing.server.com,S=3086,W=3148:2,S'
-rw------- 1 dev mail 1274 Aug 29 00:05
1567026317.M331058P4751.testing.server.com,S=3086,W=3148:2,S
Proposed patch (solves #1, not sure about your opinion on #2):
--- src/plugins/quota/quota-maildir.c.orig	2020-02-05 19:21:08.582998417 -0700
+++ src/plugins/quota/quota-maildir.c	2020-02-05 19:21:22.184998798 -0700
@@ -84,7 +84,7 @@
 
 		p = strstr(dp->d_name, ",S=");
 		num = (uoff_t)-1;
-		if (p != NULL) {
+		if (0 && p != NULL) {
 			/* ,S=nnnn[:,] */
 			p += 3;
 			for (num = 0; *p >= '0' && *p <= '9'; p++)
@@ -104,7 +104,7 @@
 			str_truncate(path, len);
 			str_append(path, dp->d_name);
 			if (stat(str_c(path), &st) == 0) {
-				*total_bytes += st.st_size;
+				*total_bytes += st.st_blocks * 512;
 				*total_count += 1;
 			} else if (errno != ENOENT && errno != ESTALE) {
 				*error_r = t_strdup_printf(
Thank you!
--
Best regards,
Martynas Bendorius
I think these changes will confuse users because calculated quota wouldn't be equals with total messages sizes. Marsistynas Bendorius ????? 2020-02-07 11:07:> Is there any reason why dovecot relies on S= instead of real disk size > email takes? > > 1) compressed mails take less than than the S= specified > 2) we could avoid using "S=" for the lookups and count every file > there, including indexes and mails without S=... if we'd read > filesizes-- With best regards, Max Kostikov W: https://kostikov.co | DeltaChat: mk at eprove.net -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: <https://dovecot.org/pipermail/dovecot/attachments/20200208/03d63359/attachment.sig>
Doesn't it currently confuse them? Because they'd reach their quota, while actually there would be a lot of disk space left :) + their whole mailbox could take a lot more space due to indexes and other files in the filesystem, and quota would not be reached. Also, I've dovecot is using fstat's st_size parameter. This is not "correct", in that the actual space used on disk is always higher. If we count the number of 512B blocks used (st_blocks), and multiply by 512 to get the true disk usage. I'll be looking forward for your feedback/ideas. Thank you! -- Best regards, Martynas Bendorius> On 2020-02-08, at 17:57, Max Kostikov <max at kostikov.co> wrote: > > I think these changes will confuse users because calculated quota wouldn't be equals with total messages sizes. > > Marsistynas Bendorius ????? 2020-02-07 11:07: >> Is there any reason why dovecot relies on S= instead of real disk size >> email takes? >> 1) compressed mails take less than than the S= specified >> 2) we could avoid using "S=" for the lookups and count every file >> there, including indexes and mails without S=... if we'd read >> filesizes > > > -- > With best regards, > Max Kostikov > > W: https://kostikov.co | DeltaChat: mk at eprove.net