Blame SOURCES/rsync-3.1.3-sparse-block.patch

90f149
diff --git a/fileio.c b/fileio.c
90f149
index b183e20..72d6076 100644
90f149
--- a/fileio.c
90f149
+++ b/fileio.c
90f149
@@ -34,6 +34,7 @@
90f149
 #define ALIGNED_LENGTH(len) ((((len) - 1) | (ALIGN_BOUNDRY-1)) + 1)
90f149
 
90f149
 extern int sparse_files;
90f149
+extern int sparse_files_block_size;
90f149
 
90f149
 OFF_T preallocated_len = 0;
90f149
 
90f149
@@ -147,7 +148,7 @@ int write_file(int f, int use_seek, OFF_T offset, const char *buf, int len)
90f149
 	while (len > 0) {
90f149
 		int r1;
90f149
 		if (sparse_files > 0) {
90f149
-			int len1 = MIN(len, SPARSE_WRITE_SIZE);
90f149
+			int len1 = MIN(len, sparse_files_block_size ? sparse_files_block_size : SPARSE_WRITE_SIZE);
90f149
 			r1 = write_sparse(f, use_seek, offset, buf, len1);
90f149
 			offset += r1;
90f149
 		} else {
90f149
diff --git a/options.c b/options.c
90f149
index 195672e..d08c05a 100644
90f149
--- a/options.c
90f149
+++ b/options.c
90f149
@@ -76,6 +76,7 @@ int remove_source_files = 0;
90f149
 int one_file_system = 0;
90f149
 int protocol_version = PROTOCOL_VERSION;
90f149
 int sparse_files = 0;
90f149
+long sparse_files_block_size = 0;
90f149
 int preallocate_files = 0;
90f149
 int do_compression = 0;
90f149
 int def_compress_level = NOT_SPECIFIED;
90f149
@@ -717,6 +718,7 @@ void usage(enum logcode F)
90f149
   rprintf(F,"     --fake-super            store/recover privileged attrs using xattrs\n");
90f149
 #endif
90f149
   rprintf(F," -S, --sparse                turn sequences of nulls into sparse blocks\n");
90f149
+  rprintf(F,"     --sparse-block=SIZE     set block size used to handle sparse files\n");
90f149
 #ifdef SUPPORT_PREALLOCATION
90f149
   rprintf(F,"     --preallocate           allocate dest files before writing them\n");
90f149
 #else
90f149
@@ -927,6 +929,7 @@ static struct poptOption long_options[] = {
90f149
   {"sparse",          'S', POPT_ARG_VAL,    &sparse_files, 1, 0, 0 },
90f149
   {"no-sparse",        0,  POPT_ARG_VAL,    &sparse_files, 0, 0, 0 },
90f149
   {"no-S",             0,  POPT_ARG_VAL,    &sparse_files, 0, 0, 0 },
90f149
+  {"sparse-block",     0,  POPT_ARG_LONG,   &sparse_files_block_size, 0, 0, 0 },
90f149
   {"preallocate",      0,  POPT_ARG_NONE,   &preallocate_files, 0, 0, 0},
90f149
   {"inplace",          0,  POPT_ARG_VAL,    &inplace, 1, 0, 0 },
90f149
   {"no-inplace",       0,  POPT_ARG_VAL,    &inplace, 0, 0, 0 },
90f149
diff --git a/options.c b/options.c
90f149
index b12da55..5a27452 100644
90f149
--- a/options.c
90f149
+++ b/options.c
90f149
@@ -2606,6 +2606,12 @@ void server_options(char **args, int *argc_p)
90f149
 		args[ac++] = arg;
90f149
 	}
90f149
 
90f149
+	if (sparse_files_block_size) {
90f149
+		if (asprintf(&arg, "--sparse-block=%lu", sparse_files_block_size) < 0)
90f149
+			goto oom;
90f149
+		args[ac++] = arg;
90f149
+	}
90f149
+
90f149
 	if (io_timeout) {
90f149
 		if (asprintf(&arg, "--timeout=%d", io_timeout) < 0)
90f149
 			goto oom;
90f149
diff --git a/rsync.yo b/rsync.yo
90f149
--- a/rsync.yo
90f149
+++ b/rsync.yo
90f149
@@ -377,6 +377,7 @@ to the detailed description below for a complete description.  verb(
90f149
      --super                 receiver attempts super-user activities
90f149
      --fake-super            store/recover privileged attrs using xattrs
90f149
  -S, --sparse                turn sequences of nulls into sparse blocks
90f149
+     --sparse-block=SIZE     set block size used to handle sparse files
90f149
      --preallocate           allocate dest files before writing
90f149
  -n, --dry-run               perform a trial run with no changes made
90f149
  -W, --whole-file            copy files whole (w/o delta-xfer algorithm)
90f149
@@ -1299,6 +1300,15 @@ If combined with bf(--sparse), the file will only have sparse blocks (as
90f149
 opposed to allocated sequences of null bytes) if the kernel version and
90f149
 filesystem type support creating holes in the allocated data.
90f149
90f149
+dit(bf(--sparse-block=SIZE)) Change the block size used to handle sparse files
90f149
+to SIZE bytes.  This option only has an effect if the bf(--sparse) (bf(-S))
90f149
+option was also specified.  The default block size used by rsync to detect a
90f149
+file hole is 1024 bytes; when the receiver writes data to the destination file
90f149
+and option bf(--sparse) is used, rsync checks every 1024-bytes chunk to detect
90f149
+if they are actually filled with data or not.  With certain filesystems,
90f149
+optimized to receive data streams for example, enlarging this block size can
90f149
+strongly increase performance.  The option can be used to tune this block size.
90f149
+
90f149
 dit(bf(-n, --dry-run)) This makes rsync perform a trial run that doesn't
90f149
 make any changes (and produces mostly the same output as a real run).  It
90f149
 is most commonly used in combination with the bf(-v, --verbose) and/or
90f149
diff --git a/rsync.1 b/rsync.1
90f149
index 855dd47..1d7af3c 100644
90f149
--- a/rsync.1
90f149
+++ b/rsync.1
90f149
@@ -454,6 +454,7 @@ to the detailed description below for a complete description.
90f149
      \-\-super                 receiver attempts super\-user activities
90f149
      \-\-fake\-super            store/recover privileged attrs using xattrs
90f149
  \-S, \-\-sparse                turn sequences of nulls into sparse blocks
90f149
+     \-\-sparse-block=SIZE      set block size used to handle sparse files
90f149
      \-\-preallocate           allocate dest files before writing
90f149
  \-n, \-\-dry\-run               perform a trial run with no changes made
90f149
  \-W, \-\-whole\-file            copy files whole (w/o delta\-xfer algorithm)
90f149
@@ -1493,6 +1493,16 @@ If combined with \fB\-\-sparse\fP, the file will only have sparse blocks (as
90f149
 opposed to allocated sequences of null bytes) if the kernel version and
90f149
 filesystem type support creating holes in the allocated data.
90f149
 .IP 
90f149
+.IP "\fB\-\-sparse\-block=SIZE\fP"
90f149
+Change the block size used to handle sparse files
90f149
+to SIZE bytes.  This option only has an effect if the \fB\-\-sparse\fP (\fB\-S\fP)
90f149
+option was also specified.  The default block size used by rsync to detect a
90f149
+file hole is 1024 bytes; when the receiver writes data to the destination file
90f149
+and option \fB\-\-sparse\fP is used, rsync checks every 1024\-bytes chunk to detect
90f149
+if they are actually filled with data or not.  With certain filesystems,
90f149
+optimized to receive data streams for example, enlarging this block size can
90f149
+strongly increase performance.  The option can be used to tune this block size.
90f149
+.IP
90f149
 .IP "\fB\-n, \-\-dry\-run\fP"
90f149
 This makes rsync perform a trial run that doesn\(cq\&t
90f149
 make any changes (and produces mostly the same output as a real run).  It