Fixed 2 failing hunks.
[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
6f921167
WD
17--- old/flist.c
18+++ new/flist.c
c8a8b4a7 19@@ -63,6 +63,7 @@ extern int copy_links;
6f921167
WD
20 extern int copy_unsafe_links;
21 extern int protocol_version;
22 extern int sanitize_paths;
23+extern unsigned long sleep_asec;
6f921167 24 extern struct stats stats;
c8a8b4a7 25 extern char *filesfrom_host;
56e792f1 26
c8a8b4a7 27@@ -1465,6 +1466,9 @@ static void send_directory(int f, struct
6f921167
WD
28 }
29
9c85142a 30 send_file_name(f, flist, fbuf, NULL, flags, filter_level);
6f921167
WD
31+ /* Sleep for a bit, to avoid hammering the disk. */
32+ if (sleep_asec)
33+ usleep(sleep_asec);
34 }
35
36 fbuf[len] = '\0';
37--- old/options.c
38+++ new/options.c
c8a8b4a7 39@@ -106,6 +106,7 @@ int size_only = 0;
6f921167
WD
40 int daemon_bwlimit = 0;
41 int bwlimit = 0;
42 int fuzzy_basis = 0;
43+unsigned long sleep_asec = 0;
44 size_t bwlimit_writemax = 0;
45 int ignore_existing = 0;
46 int ignore_non_existing = 0;
c8a8b4a7 47@@ -416,6 +417,7 @@ void usage(enum logcode F)
fc068916 48 rprintf(F," --password-file=FILE read daemon-access password from FILE\n");
6f921167
WD
49 rprintf(F," --list-only list the files instead of copying them\n");
50 rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
51+ rprintf(F," --slow-down=USECs sleep N usec while creating the filelist\n");
52 rprintf(F," --write-batch=FILE write a batched update to FILE\n");
53 rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n");
54 rprintf(F," --read-batch=FILE read a batched update from FILE\n");
c8a8b4a7 55@@ -583,6 +585,7 @@ static struct poptOption long_options[]
6f921167 56 {"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 },
6cbbe66d
WD
57 {"no-itemize-changes",0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
58 {"no-i", 0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
6f921167 59+ {"slow-down", 0, POPT_ARG_LONG, &sleep_asec, 0, 0, 0 },
6cbbe66d
WD
60 {"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 },
61 {"no-bwlimit", 0, POPT_ARG_VAL, &bwlimit, 0, 0, 0 },
62 {"backup", 'b', POPT_ARG_VAL, &make_backups, 1, 0, 0 },