File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / patches / slow-down.diff
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:32:36 2021 UTC (3 years, 2 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_2_3, HEAD
rsync 3.2.3

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: e94bad1c156fc3910f24e2b3b71a81b0b0bdeb70
diff --git a/flist.c b/flist.c
--- a/flist.c
+++ b/flist.c
@@ -73,6 +73,7 @@ extern int sender_symlink_iconv;
 extern int output_needs_newline;
 extern int sender_keeps_checksum;
 extern int unsort_ndx;
+extern unsigned long sleep_asec;
 extern uid_t our_uid;
 extern struct stats stats;
 extern char *filesfrom_host;
@@ -1837,6 +1838,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
@@ -113,6 +113,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;
@@ -764,6 +765,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
@@ -459,6 +459,7 @@ detailed description below for a complete description.
 --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
 --write-batch=FILE       write a batched update to FILE
diff -Nurp a/rsync.1 b/rsync.1
--- a/rsync.1
+++ b/rsync.1
@@ -535,6 +535,7 @@ detailed description below for a complet
 --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
 --write-batch=FILE       write a batched update to FILE
diff -Nurp a/rsync.1.html b/rsync.1.html
--- a/rsync.1.html
+++ b/rsync.1.html
@@ -450,6 +450,7 @@ detailed description below for a complet
 --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
 --write-batch=FILE       write a batched update to FILE

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>