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 | ||
11 | --- old/flist.c | |
12 | +++ new/flist.c | |
13 | @@ -58,6 +58,7 @@ extern int copy_links; | |
14 | extern int copy_unsafe_links; | |
15 | extern int protocol_version; | |
16 | extern int sanitize_paths; | |
17 | +extern unsigned long sleep_asec; | |
18 | extern const char *io_write_phase; | |
19 | extern struct stats stats; | |
20 | extern struct file_list *the_file_list; | |
21 | @@ -1049,6 +1050,9 @@ static void send_directory(int f, struct | |
22 | } | |
23 | ||
24 | send_file_name(f, flist, fbuf, NULL, 0); | |
25 | + /* Sleep for a bit, to avoid hammering the disk. */ | |
26 | + if (sleep_asec) | |
27 | + usleep(sleep_asec); | |
28 | } | |
29 | ||
30 | fbuf[len] = '\0'; | |
31 | --- old/options.c | |
32 | +++ new/options.c | |
33 | @@ -102,6 +102,7 @@ int size_only = 0; | |
34 | int daemon_bwlimit = 0; | |
35 | int bwlimit = 0; | |
36 | int fuzzy_basis = 0; | |
37 | +unsigned long sleep_asec = 0; | |
38 | size_t bwlimit_writemax = 0; | |
39 | int ignore_existing = 0; | |
40 | int ignore_non_existing = 0; | |
41 | @@ -364,6 +365,7 @@ void usage(enum logcode F) | |
42 | rprintf(F," --password-file=FILE read password from FILE\n"); | |
43 | rprintf(F," --list-only list the files instead of copying them\n"); | |
44 | rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); | |
45 | + rprintf(F," --slow-down=USECs sleep N usec while creating the filelist\n"); | |
46 | rprintf(F," --write-batch=FILE write a batched update to FILE\n"); | |
47 | rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); | |
48 | rprintf(F," --read-batch=FILE read a batched update from FILE\n"); | |
49 | @@ -492,6 +494,7 @@ static struct poptOption long_options[] | |
50 | {"log-format", 0, POPT_ARG_STRING, &log_format, 0, 0, 0 }, | |
51 | {"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 }, | |
52 | {"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 }, | |
53 | + {"slow-down", 0, POPT_ARG_LONG, &sleep_asec, 0, 0, 0 }, | |
54 | {"backup", 'b', POPT_ARG_NONE, &make_backups, 0, 0, 0 }, | |
55 | {"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 }, | |
56 | {"suffix", 0, POPT_ARG_STRING, &backup_suffix, 0, 0, 0 }, |