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

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