Skip to content

Commit

Permalink
write-size: add command line option
Browse files Browse the repository at this point in the history
This option forces the buffer size when writing a file on the receiver
side.
  • Loading branch information
aoblet committed May 9, 2023
1 parent 0ae8c3a commit 2533d7e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 8 additions & 0 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions rsync.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion rsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2533d7e

Please sign in to comment.