From: Timo Sirainen Date: Fri, 14 May 2010 08:40:24 +0000 (+0200) Subject: Use IO_BLOCK_SIZE macro to specify how large read/write syscalls to use. X-Git-Tag: 2.0.beta6~221 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ed2d0f6b5e67e2663d44489d9da3176823789a8;p=thirdparty%2Fdovecot%2Fcore.git Use IO_BLOCK_SIZE macro to specify how large read/write syscalls to use. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/dbox-common/dbox-file.c b/src/lib-storage/index/dbox-common/dbox-file.c index 39a89812c6..3a61fbf7c3 100644 --- a/src/lib-storage/index/dbox-common/dbox-file.c +++ b/src/lib-storage/index/dbox-common/dbox-file.c @@ -23,7 +23,7 @@ #include #include -#define DBOX_READ_BLOCK_SIZE 4096 +#define DBOX_READ_BLOCK_SIZE IO_BLOCK_SIZE #ifndef DBOX_FILE_LOCK_METHOD_FLOCK static const struct dotlock_settings dotlock_set = { diff --git a/src/lib-storage/index/mbox/mbox-file.c b/src/lib-storage/index/mbox/mbox-file.c index 99a5232580..d3ad904490 100644 --- a/src/lib-storage/index/mbox/mbox-file.c +++ b/src/lib-storage/index/mbox/mbox-file.c @@ -10,7 +10,7 @@ #include #include -#define MBOX_READ_BLOCK_SIZE (1024*4) +#define MBOX_READ_BLOCK_SIZE IO_BLOCK_SIZE int mbox_file_open(struct mbox_mailbox *mbox) { diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index b80acb8eed..cafc79857a 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -11,7 +11,7 @@ /* Block size when read()ing message header. */ #define MAIL_READ_HDR_BLOCK_SIZE (1024*4) /* Block size when read()ing message (header and) body. */ -#define MAIL_READ_FULL_BLOCK_SIZE (1024*8) +#define MAIL_READ_FULL_BLOCK_SIZE IO_BLOCK_SIZE struct mail_storage_module_register { unsigned int id; diff --git a/src/lib/compat.h b/src/lib/compat.h index 7623b109c6..abc01e4543 100644 --- a/src/lib/compat.h +++ b/src/lib/compat.h @@ -260,4 +260,9 @@ int i_my_clock_gettime(int clk_id, struct timespec *tp); int fdatasync(int); #endif +/* Try to keep IO operations at least this size */ +#ifndef IO_BLOCK_SIZE +# define IO_BLOCK_SIZE 8192 +#endif + #endif diff --git a/src/lib/file-set-size.c b/src/lib/file-set-size.c index d19edd4c27..88b1e02c06 100644 --- a/src/lib/file-set-size.c +++ b/src/lib/file-set-size.c @@ -19,7 +19,7 @@ int file_set_size(int fd, off_t size) #ifdef HAVE_POSIX_FALLOCATE static bool posix_fallocate_supported = TRUE; #endif - char block[4096]; + char block[IO_BLOCK_SIZE]; off_t offset; ssize_t ret; struct stat st; diff --git a/src/lib/istream-internal.h b/src/lib/istream-internal.h index d245c6a9ed..9b369ae947 100644 --- a/src/lib/istream-internal.h +++ b/src/lib/istream-internal.h @@ -4,7 +4,7 @@ #include "istream.h" #include "iostream-internal.h" -#define I_STREAM_MIN_SIZE 4096 +#define I_STREAM_MIN_SIZE IO_BLOCK_SIZE struct istream_private { /* inheritance: */ diff --git a/src/lib/ostream-file.c b/src/lib/ostream-file.c index 953d6dd01e..d010d1c6a2 100644 --- a/src/lib/ostream-file.c +++ b/src/lib/ostream-file.c @@ -19,7 +19,7 @@ /* try to keep the buffer size within 4k..128k. ReiserFS may actually return 128k as optimal size. */ -#define DEFAULT_OPTIMAL_BLOCK_SIZE 4096 +#define DEFAULT_OPTIMAL_BLOCK_SIZE IO_BLOCK_SIZE #define MAX_OPTIMAL_BLOCK_SIZE (128*1024) #define IS_STREAM_EMPTY(fstream) \ diff --git a/src/lib/ostream.c b/src/lib/ostream.c index 28ff49f1df..b6ec95752a 100644 --- a/src/lib/ostream.c +++ b/src/lib/ostream.c @@ -247,7 +247,7 @@ int o_stream_pwrite(struct ostream *stream, const void *data, size_t size, static off_t o_stream_default_send_istream(struct ostream_private *outstream, struct istream *instream) { - return io_stream_copy(&outstream->ostream, instream, 1024); + return io_stream_copy(&outstream->ostream, instream, IO_BLOCK_SIZE); } struct ostream *o_stream_create(struct ostream_private *_stream)