Commit | Line | Data |
---|---|---|
6f921167 WD |
1 | This patch adds a --slow-down=USECs option that causes the sender to scan |
2 | the filelist more slowly, and the generator to scan for deletions more | |
3 | slowly. It doesn't do anything to make anyone slow down during the normal | |
4 | transfer processing, though. | |
5 | ||
6 | The idea is to lessen rsync's impact on disk I/O. Unfortunately, there | |
7 | should really be a way to affect more of rsync's processing, perhaps by | |
8 | specifying a maximum disk I/O rate (and have that affect a maximum stat() | |
9 | rate or something like that). | |
10 | ||
03019e41 WD |
11 | To 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 | ||
cc3e685d WD |
17 | diff --git a/flist.c b/flist.c |
18 | --- a/flist.c | |
19 | +++ b/flist.c | |
f9df736a | 20 | @@ -68,6 +68,7 @@ extern int sanitize_paths; |
cc3e685d | 21 | extern int munge_symlinks; |
d4dd2dd5 WD |
22 | extern int need_unsorted_flist; |
23 | extern int unsort_ndx; | |
6f921167 | 24 | +extern unsigned long sleep_asec; |
6f921167 | 25 | extern struct stats stats; |
c8a8b4a7 | 26 | extern char *filesfrom_host; |
56e792f1 | 27 | |
65ecbe35 | 28 | @@ -1542,6 +1543,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len, |
6f921167 WD |
29 | } |
30 | ||
9c85142a | 31 | send_file_name(f, flist, fbuf, NULL, flags, filter_level); |
6f921167 WD |
32 | + /* Sleep for a bit, to avoid hammering the disk. */ |
33 | + if (sleep_asec) | |
34 | + usleep(sleep_asec); | |
35 | } | |
36 | ||
37 | fbuf[len] = '\0'; | |
cc3e685d WD |
38 | diff --git a/options.c b/options.c |
39 | --- a/options.c | |
40 | +++ b/options.c | |
c0c7984e | 41 | @@ -109,6 +109,7 @@ int size_only = 0; |
6f921167 WD |
42 | int daemon_bwlimit = 0; |
43 | int bwlimit = 0; | |
44 | int fuzzy_basis = 0; | |
45 | +unsigned long sleep_asec = 0; | |
46 | size_t bwlimit_writemax = 0; | |
47 | int ignore_existing = 0; | |
48 | int ignore_non_existing = 0; | |
c0c7984e | 49 | @@ -424,6 +425,7 @@ void usage(enum logcode F) |
fc068916 | 50 | rprintf(F," --password-file=FILE read daemon-access password from FILE\n"); |
6f921167 WD |
51 | rprintf(F," --list-only list the files instead of copying them\n"); |
52 | rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); | |
53 | + rprintf(F," --slow-down=USECs sleep N usec while creating the filelist\n"); | |
54 | rprintf(F," --write-batch=FILE write a batched update to FILE\n"); | |
55 | rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); | |
56 | rprintf(F," --read-batch=FILE read a batched update from FILE\n"); | |
c0c7984e | 57 | @@ -604,6 +606,7 @@ static struct poptOption long_options[] = { |
6f921167 | 58 | {"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 }, |
6cbbe66d WD |
59 | {"no-itemize-changes",0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 }, |
60 | {"no-i", 0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 }, | |
6f921167 | 61 | + {"slow-down", 0, POPT_ARG_LONG, &sleep_asec, 0, 0, 0 }, |
6cbbe66d WD |
62 | {"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 }, |
63 | {"no-bwlimit", 0, POPT_ARG_VAL, &bwlimit, 0, 0, 0 }, | |
64 | {"backup", 'b', POPT_ARG_VAL, &make_backups, 1, 0, 0 }, |