-
Notifications
You must be signed in to change notification settings - Fork 8
/
slow-down.diff
68 lines (62 loc) · 2.71 KB
/
slow-down.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
This patch adds a --slow-down=USECs option that causes the sender to scan
the filelist more slowly, and the generator to scan for deletions more
slowly. It doesn't do anything to make anyone slow down during the normal
transfer processing, though.
The idea is to lessen rsync's impact on disk I/O. Unfortunately, there
should really be a way to affect more of rsync's processing, perhaps by
specifying a maximum disk I/O rate (and have that affect a maximum stat()
rate or something like that).
To use this patch, run these commands for a successful build:
patch -p1 <patches/slow-down.diff
./configure (optional if already run)
make
based-on: 6c8ca91c731b7bf2b081694bda85b7dadc2b7aff
diff --git a/flist.c b/flist.c
--- a/flist.c
+++ b/flist.c
@@ -74,6 +74,7 @@ extern int output_needs_newline;
extern int sender_keeps_checksum;
extern int trust_sender_filter;
extern int unsort_ndx;
+extern unsigned long sleep_asec;
extern uid_t our_uid;
extern struct stats stats;
extern char *filesfrom_host;
@@ -1879,6 +1880,9 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
}
send_file_name(f, flist, fbuf, NULL, flags, filter_level);
+ /* Sleep for a bit, to avoid hammering the disk. */
+ if (sleep_asec)
+ usleep(sleep_asec);
}
fbuf[len] = '\0';
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
@@ -122,6 +122,7 @@ int size_only = 0;
int daemon_bwlimit = 0;
int bwlimit = 0;
int fuzzy_basis = 0;
+unsigned long sleep_asec = 0;
size_t bwlimit_writemax = 0;
int ignore_existing = 0;
int ignore_non_existing = 0;
@@ -774,6 +775,7 @@ static struct poptOption long_options[] = {
{"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 },
{"no-itemize-changes",0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
{"no-i", 0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
+ {"slow-down", 0, POPT_ARG_LONG, &sleep_asec, 0, 0, 0 },
{"bwlimit", 0, POPT_ARG_STRING, &bwlimit_arg, OPT_BWLIMIT, 0, 0 },
{"no-bwlimit", 0, POPT_ARG_VAL, &bwlimit, 0, 0, 0 },
{"backup", 'b', POPT_ARG_VAL, &make_backups, 1, 0, 0 },
diff --git a/rsync.1.md b/rsync.1.md
--- a/rsync.1.md
+++ b/rsync.1.md
@@ -547,6 +547,7 @@ has its own detailed description later in this manpage.
--early-input=FILE use FILE for daemon's early exec input
--list-only list the files instead of copying them
--bwlimit=RATE limit socket I/O bandwidth
+--slow-down=USECs sleep N usec while creating the filelist
--stop-after=MINS Stop rsync after MINS minutes have elapsed
--stop-at=y-m-dTh:m Stop rsync at the specified point in time
--fsync fsync every written file