diff --git a/fileio.c b/fileio.c index 69c9a7b49..93dfd139b 100644 --- a/fileio.c +++ b/fileio.c @@ -34,6 +34,7 @@ #define ALIGNED_LENGTH(len) ((((len) - 1) | (ALIGN_BOUNDARY-1)) + 1) extern int sparse_files; +extern int write_size; OFF_T preallocated_len = 0; @@ -158,7 +159,7 @@ int write_file(int f, int use_seek, OFF_T offset, const char *buf, int len) offset += r1; } else { if (!wf_writeBuf) { - wf_writeBufSize = WRITE_SIZE * 8; + wf_writeBufSize = write_size * 8; wf_writeBufCnt = 0; wf_writeBuf = new_array(char, wf_writeBufSize); } diff --git a/options.c b/options.c index 184e83733..08e611049 100644 --- a/options.c +++ b/options.c @@ -137,6 +137,7 @@ int inplace = 0; int delay_updates = 0; int32 block_size = 0; int max_map_size = 256*1024; +int write_size = 32*1024; time_t stop_at_utime = 0; char *skip_compress = NULL; char *copy_as = NULL; @@ -742,6 +743,7 @@ static struct poptOption long_options[] = { {"cc", 0, POPT_ARG_STRING, &checksum_choice, 0, 0, 0 }, {"block-size", 'B', POPT_ARG_STRING, 0, OPT_BLOCK_SIZE, 0, 0 }, {"max-map-size", 0, POPT_ARG_INT, &max_map_size, 0, 0, 0 }, + {"write-size", 0, POPT_ARG_INT, &write_size, 0, 0, 0 }, {"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 }, {"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 }, {"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 }, @@ -2778,6 +2780,12 @@ void server_options(char **args, int *argc_p) args[ac++] = arg; } + if (write_size) { + if (asprintf(&arg, "--write-size=%d", write_size) < 0) + goto oom; + args[ac++] = arg; + } + if (io_timeout) { if (asprintf(&arg, "--timeout=%d", io_timeout) < 0) goto oom; diff --git a/rsync.1.md b/rsync.1.md index ba2eb82c3..88536efee 100644 --- a/rsync.1.md +++ b/rsync.1.md @@ -473,6 +473,7 @@ has its own detailed description later in this manpage. --one-file-system, -x don't cross filesystem boundaries --block-size=SIZE, -B force a fixed checksum block-size --max-map-size force mmap read block size (expressed in bytes, useful for fast storage, default 256K) +--write-size force write block size (expressed in bytes, default 32K) --rsh=COMMAND, -e specify the remote shell to use --rsync-path=PROGRAM specify the rsync to run on remote machine --existing skip creating new files on receiver @@ -2138,6 +2139,12 @@ expand it. > --max-map-size 4194304 +0. `--write-size=SIZE` + + This option forces the buffer size when writing a file on the receiver side. + + By default, 32K and expressed in Bytes. + 0. `--rsh=COMMAND`, `-e` This option allows you to choose an alternative remote shell program to use diff --git a/rsync.h b/rsync.h index 8608a832f..bca544175 100644 --- a/rsync.h +++ b/rsync.h @@ -153,7 +153,6 @@ #define RSYNC_PORT 873 #define SPARSE_WRITE_SIZE (1024) -#define WRITE_SIZE (32*1024) #define CHUNK_SIZE (32*1024) #define IO_BUFFER_SIZE (32*1024) #define MAX_BLOCK_SIZE ((int32)1 << 17)