dovecot-2.2: lib-fs: Optimized fs_stat() for fs-metawrap after w...

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 9 19:28:35 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/fa42da3cc614
changeset: 18319:fa42da3cc614
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 09 21:27:51 2015 +0200
description:
lib-fs: Optimized fs_stat() for fs-metawrap after writing a file.

diffstat:

 src/lib-fs/fs-metawrap.c |  12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diffs (29 lines):

diff -r 4a80d3bbf14d -r fa42da3cc614 src/lib-fs/fs-metawrap.c
--- a/src/lib-fs/fs-metawrap.c	Mon Mar 09 20:33:13 2015 +0200
+++ b/src/lib-fs/fs-metawrap.c	Mon Mar 09 21:27:51 2015 +0200
@@ -354,6 +354,8 @@
 	input2 = i_stream_create_concat(inputs);
 	i_stream_unref(&inputs[0]);
 	i_stream_unref(&inputs[1]);
+
+	file->metadata_write_size = str_len(file->metadata_header);
 	return input2;
 }
 
@@ -450,6 +452,16 @@
 
 	if (!file->fs->wrap_metadata)
 		return fs_stat(file->super, st_r);
+
+	if (file->metadata_write_size != 0) {
+		/* fs_stat() after a write. we can do this quickly. */
+		if (fs_stat(file->super, st_r) < 0)
+			return -1;
+		i_assert((uoff_t)st_r->st_size > file->metadata_write_size);
+		st_r->st_size -= file->metadata_write_size;
+		return 0;
+	}
+
 	input = fs_read_stream(_file, IO_BLOCK_SIZE);
 	if ((ret = i_stream_get_size(input, TRUE, &input_size)) < 0) {
 		fs_set_error(_file->fs, "i_stream_get_size(%s) failed: %m",


More information about the dovecot-cvs mailing list