Updated patches to work with the current trunk.
[rsync/rsync-patches.git] / slow-down.diff
CommitLineData
6f921167
WD
1This patch adds a --slow-down=USECs option that causes the sender to scan
2the filelist more slowly, and the generator to scan for deletions more
3slowly. It doesn't do anything to make anyone slow down during the normal
4transfer processing, though.
5
6The idea is to lessen rsync's impact on disk I/O. Unfortunately, there
7should really be a way to affect more of rsync's processing, perhaps by
8specifying a maximum disk I/O rate (and have that affect a maximum stat()
9rate or something like that).
10
03019e41
WD
11To use this patch, run these commands for a successful build:
12
13 patch -p1 <patches/slow-down.diff
14 ./configure (optional if already run)
15 make
16
5214a41b 17based-on: 24079e988fc31af4eba56cd2701fdc5a4154980d
cc3e685d
WD
18diff --git a/flist.c b/flist.c
19--- a/flist.c
20+++ b/flist.c
5214a41b 21@@ -70,6 +70,7 @@ extern int sender_symlink_iconv;
fc557362
WD
22 extern int output_needs_newline;
23 extern int sender_keeps_checksum;
d4dd2dd5 24 extern int unsort_ndx;
6f921167 25+extern unsigned long sleep_asec;
6f921167 26 extern struct stats stats;
c8a8b4a7 27 extern char *filesfrom_host;
fc557362 28 extern char *usermap, *groupmap;
5214a41b 29@@ -1752,6 +1753,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
6f921167
WD
30 }
31
9c85142a 32 send_file_name(f, flist, fbuf, NULL, flags, filter_level);
6f921167
WD
33+ /* Sleep for a bit, to avoid hammering the disk. */
34+ if (sleep_asec)
35+ usleep(sleep_asec);
36 }
37
38 fbuf[len] = '\0';
cc3e685d
WD
39diff --git a/options.c b/options.c
40--- a/options.c
41+++ b/options.c
fc557362 42@@ -108,6 +108,7 @@ int size_only = 0;
6f921167
WD
43 int daemon_bwlimit = 0;
44 int bwlimit = 0;
45 int fuzzy_basis = 0;
46+unsigned long sleep_asec = 0;
47 size_t bwlimit_writemax = 0;
48 int ignore_existing = 0;
49 int ignore_non_existing = 0;
72e5645e 50@@ -776,6 +777,7 @@ void usage(enum logcode F)
fc068916 51 rprintf(F," --password-file=FILE read daemon-access password from FILE\n");
6f921167 52 rprintf(F," --list-only list the files instead of copying them\n");
5214a41b 53 rprintf(F," --bwlimit=RATE limit socket I/O bandwidth\n");
6f921167
WD
54+ rprintf(F," --slow-down=USECs sleep N usec while creating the filelist\n");
55 rprintf(F," --write-batch=FILE write a batched update to FILE\n");
56 rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n");
57 rprintf(F," --read-batch=FILE read a batched update from FILE\n");
72e5645e 58@@ -964,6 +966,7 @@ static struct poptOption long_options[] = {
6f921167 59 {"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 },
6cbbe66d
WD
60 {"no-itemize-changes",0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
61 {"no-i", 0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
6f921167 62+ {"slow-down", 0, POPT_ARG_LONG, &sleep_asec, 0, 0, 0 },
5214a41b 63 {"bwlimit", 0, POPT_ARG_STRING, &bwlimit_arg, OPT_BWLIMIT, 0, 0 },
6cbbe66d
WD
64 {"no-bwlimit", 0, POPT_ARG_VAL, &bwlimit, 0, 0, 0 },
65 {"backup", 'b', POPT_ARG_VAL, &make_backups, 1, 0, 0 },