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

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