[SCM] The rsync repository. - branch master updated

2020-05-22 Thread Rsync CVS commit messages
The branch, master has been updated
   via  d7212df0 A little more safety in negotiate_checksum().
  from  a28bc3eb Promoting xxhash support.

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -
commit d7212df0f134ac82f9afb46d478ab3ac1511c61b
Author: Wayne Davison 
Date:   Fri May 22 19:26:30 2020 -0700

A little more safety in negotiate_checksum().

---

Summary of changes:
 checksum.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/checksum.c b/checksum.c
index 17a9507a..a21222d4 100644
--- a/checksum.c
+++ b/checksum.c
@@ -187,21 +187,24 @@ void negotiate_checksum(int f_in, int f_out, const char 
*csum_list, int saw_fail
if (saw_fail && !len)
len = strlcpy(sumbuf, "FAIL", sizeof sumbuf);
csum_list = sumbuf;
-   } else
+   } else {
+   memset(saw, 0, CSUM_SAW_BUFLEN);
csum_list = NULL;
+   }
 
if (!csum_list || !*csum_list) {
struct csum_struct *cs;
-   for (tok = sumbuf, cs = valid_checksums, len = 0; cs->name; 
cs++) {
+   int cnt = 0;
+   for (cs = valid_checksums, len = 0; cs->name; cs++) {
if (cs->num == CSUM_NONE)
continue;
-   if (tok != sumbuf)
-   *tok++ = ' ';
-   tok += strlcpy(tok, cs->name, sizeof sumbuf - (tok - 
sumbuf));
-   saw[cs->num] = ++len;
+   if (len)
+   sumbuf[len++]= ' ';
+   len += strlcpy(sumbuf+len, cs->name, sizeof sumbuf - 
len);
+   if (len >= (int)sizeof sumbuf - 1)
+   exit_cleanup(RERR_UNSUPPORTED); /* 
IMPOSSIBLE... */
+   saw[cs->num] = ++cnt;
}
-   *tok = '\0';
-   len = tok - sumbuf;
}
 
/* Each side sends their list of valid checksum names to the other side 
and


-- 
The rsync repository.

___
rsync-cvs mailing list
rsync-cvs@lists.samba.org
https://lists.samba.org/mailman/listinfo/rsync-cvs


[SCM] The rsync repository. - branch master updated

2020-05-22 Thread Rsync CVS commit messages
The branch, master has been updated
   via  68516f91 Add "input" handling for cmd_txt_*() pkglib.py.
   via  531ffa81 Optimized assembler version of md5_process() for x86-64
  from  d7212df0 A little more safety in negotiate_checksum().

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -
commit 68516f91be8591b3a2d9fc4c9ed5a904e7282265
Author: Wayne Davison 
Date:   Fri May 22 22:40:54 2020 -0700

Add "input" handling for cmd_txt_*() pkglib.py.

commit 531ffa8104fa26e58ed487c340ed64af5d456fb2
Author: Jorrit Jongma 
Date:   Fri May 22 19:38:37 2020 +0200

Optimized assembler version of md5_process() for x86-64

Originally created by Marc Bevand and placed in the public domain.
Enable/disabled via the same --enable-simd configure switch as
the rolling checksum optimizations.

---

Summary of changes:
 Makefile.in  |   5 +-
 lib/md5-asm-x86_64.s | 693 +++
 lib/md5.c|  13 +
 packaging/pkglib.py  |   5 +-
 4 files changed, 714 insertions(+), 2 deletions(-)
 create mode 100644 lib/md5-asm-x86_64.s


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 0e18e96e..13cba5d9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -31,7 +31,7 @@ VERSION=@RSYNC_VERSION@
 .SUFFIXES:
 .SUFFIXES: .c .o
 
-SIMD_x86_64=simd-checksum-x86_64.o
+SIMD_x86_64=simd-checksum-x86_64.o lib/md5-asm-x86_64.o
 
 GENFILES=configure.sh aclocal.m4 config.h.in proto.h proto.h-tstamp rsync.1 
rsync-ssl.1 rsyncd.conf.5
 HEADERS=byteorder.h config.h errcode.h proto.h rsync.h ifuncs.h itypes.h 
inums.h \
@@ -122,6 +122,9 @@ rounding.h: rounding.c rsync.h proto.h
 simd-checksum-x86_64.o: simd-checksum-x86_64.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
 
+lib/md5-asm-x86_64.o: lib/md5-asm-x86_64.s
+   $(CC) -c -o $@ $<
+
 tls$(EXEEXT): $(TLS_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TLS_OBJ) $(LIBS)
 
diff --git a/lib/md5-asm-x86_64.s b/lib/md5-asm-x86_64.s
new file mode 100644
index ..a3126151
--- /dev/null
+++ b/lib/md5-asm-x86_64.s
@@ -0,0 +1,693 @@
+/*
+ * x86-64 optimized assembler MD5 implementation
+ *
+ * Author: Marc Bevand, 2004
+ *
+ * This code was placed in the public domain by the author. The original
+ * publication can be found at:
+ *
+ * https://www.zorinaq.com/papers/md5-amd64.html
+ */
+/*
+ * No modifications were made aside from changing the function and file names.
+ * The MD5_CTX structure as expected here (from OpenSSL) is binary compatible
+ * with the md_context used by rsync, for the fields accessed.
+ *
+ * Benchmarks (in MB/s)C ASM
+ * - Intel Atom D2700302 334
+ * - Intel i7-7700hq 351 376
+ * - AMD ThreadRipper 2950x  728 784
+ *
+ * The original code was also incorporated into OpenSSL. It has since been
+ * modified there. Those changes have not been made here due to licensing
+ * incompatibilities. Benchmarks of those changes on the above CPUs did not
+ * show any significant difference in performance, though.
+ */
+
+.text
+.align 16
+
+.globl md5_process_asm
+.type md5_process_asm,@function
+md5_process_asm:
+   push%rbp
+   push%rbx
+   push%r12
+   push%r13# not really useful (r13 is unused)
+   push%r14
+   push%r15
+
+   # rdi = arg #1 (ctx, MD5_CTX pointer)
+   # rsi = arg #2 (ptr, data pointer)
+   # rdx = arg #3 (nbr, number of 16-word blocks to process)
+   mov %rdi,   %rbp# rbp = ctx
+   shl $6, %rdx# rdx = nbr in bytes
+   lea (%rsi,%rdx),%rdi# rdi = end
+   mov 0*4(%rbp),  %eax# eax = ctx->A
+   mov 1*4(%rbp),  %ebx# ebx = ctx->B
+   mov 2*4(%rbp),  %ecx# ecx = ctx->C
+   mov 3*4(%rbp),  %edx# edx = ctx->D
+   # end is 'rdi'
+   # ptr is 'rsi'
+   # A is 'eax'
+   # B is 'ebx'
+   # C is 'ecx'
+   # D is 'edx'
+
+   cmp %rdi,   %rsi# cmp end with ptr
+   je  1f  # jmp if ptr == end
+
+   # BEGIN of loop over 16-word blocks
+2: # save old values of A, B, C, D
+   mov %eax,   %r8d
+   mov %ebx,   %r9d
+   mov %ecx,   %r14d
+   mov %edx,   %r15d
+ mov   0*4(%rsi),  %r10d   /* (NEXT STEP) X[0] */
+ mov   %edx,   %r11d   /* (NEXT STEP) z' = %edx */
+   xor %ecx,   %r11d   /* y ^ ... */
+   lea -680876936(%eax,%r10d),%eax /* Const + dst + ... */
+   and %ebx,   %r11d   /* x & ... */
+   xor %edx,   %r11d   /* z ^ ... */
+   mov 1*4(%rsi),%r10d /* (NEXT STEP) X[1] */
+   

[SCM] The rsync repository. - branch master updated

2020-05-22 Thread Rsync CVS commit messages
The branch, master has been updated
   via  a28bc3eb Promoting xxhash support.
   via  55bb4dab Some checksum improvements
  from  5fa4209c AVX2 optimized version of get_checksum1() for x86-64

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -
commit a28bc3ebf672113cdd90432ef0270782d8ab6c2c
Author: Wayne Davison 
Date:   Fri May 22 17:40:08 2020 -0700

Promoting xxhash support.

commit 55bb4dab7a4f132537b5ed93e504ffc618b643b9
Author: Wayne Davison 
Date:   Fri May 22 15:06:20 2020 -0700

Some checksum improvements

- Improve csum negotation logic.
- Define the csum names in a single structure.
- Add --debug=CSUM.

---

Summary of changes:
 checksum.c   | 240 +++
 compat.c |  21 +++---
 configure.ac |  14 +++-
 flist.c  |   2 +-
 io.c |   2 +-
 options.c|  11 ++-
 rsync.h  |   3 +-
 rsync.yo |   5 +-
 8 files changed, 247 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/checksum.c b/checksum.c
index 54e2c4aa..17a9507a 100644
--- a/checksum.c
+++ b/checksum.c
@@ -20,6 +20,9 @@
  */
 
 #include "rsync.h"
+#ifdef SUPPORT_XXHASH
+#include "xxhash.h"
+#endif
 
 extern int am_server;
 extern int local_server;
@@ -36,9 +39,22 @@ extern char *checksum_choice;
 #define CSUM_MD4_OLD 3
 #define CSUM_MD4 4
 #define CSUM_MD5 5
+#define CSUM_XXHASH 6
+
+#define CSUM_SAW_BUFLEN 10
 
-const char *default_checksum_list =
-   "md5 md4";
+struct csum_struct {
+   int num;
+   const char *name;
+} valid_checksums[] = {
+#ifdef SUPPORT_XXHASH
+   { CSUM_XXHASH, "xxhash" },
+#endif
+   { CSUM_MD5, "md5" },
+   { CSUM_MD4, "md4" },
+   { CSUM_NONE, "none" },
+   { -1, NULL }
+};
 
 #define MAX_CHECKSUM_LIST 1024
 
@@ -48,6 +64,8 @@ const char *negotiated_csum_name = NULL;
 
 static int parse_csum_name(const char *name, int len, int allow_auto)
 {
+   struct csum_struct *cs;
+
if (len < 0 && name)
len = strlen(name);
 
@@ -60,12 +78,11 @@ static int parse_csum_name(const char *name, int len, int 
allow_auto)
return CSUM_MD4_BUSTED;
return CSUM_MD4_ARCHAIC;
}
-   if (len == 3 && strncasecmp(name, "md4", 3) == 0)
-   return CSUM_MD4;
-   if (len == 3 && strncasecmp(name, "md5", 3) == 0)
-   return CSUM_MD5;
-   if (len == 4 && strncasecmp(name, "none", 4) == 0)
-   return CSUM_NONE;
+
+   for (cs = valid_checksums; cs->name; cs++) {
+   if (strncasecmp(name, cs->name, len) == 0 && cs->name[len] == 
'\0')
+   return cs->num;
+   }
 
if (allow_auto) {
rprintf(FERROR, "unknown checksum name: %s\n", name);
@@ -75,7 +92,22 @@ static int parse_csum_name(const char *name, int len, int 
allow_auto)
return -1;
 }
 
-void parse_checksum_choice(void)
+static const char *checksum_name(int num)
+{
+   struct csum_struct *cs;
+
+   for (cs = valid_checksums; cs->name; cs++) {
+   if (num == cs->num)
+   return cs->name;
+   }
+
+   if (num < CSUM_MD4)
+   return "MD4";
+
+   return "UNKNOWN";
+}
+
+void parse_checksum_choice(int final_call)
 {
if (!negotiated_csum_name) {
char *cp = checksum_choice ? strchr(checksum_choice, ',') : 
NULL;
@@ -85,46 +117,124 @@ void parse_checksum_choice(void)
} else
xfersum_type = checksum_type = 
parse_csum_name(checksum_choice, -1, 1);
}
+
if (xfersum_type == CSUM_NONE)
whole_file = 1;
+
+   if (final_call && DEBUG_GTE(CSUM, 1)) {
+   if (negotiated_csum_name)
+   rprintf(FINFO, "[%s] negotiated checksum: %s\n", 
who_am_i(), negotiated_csum_name);
+   else if (xfersum_type == checksum_type) {
+   rprintf(FINFO, "[%s] %s checksum: %s\n", who_am_i(),
+   checksum_choice ? "chosen" : "protocol-based",
+   checksum_name(xfersum_type));
+   } else {
+   rprintf(FINFO, "[%s] chosen transfer checksum: %s\n",
+   who_am_i(), checksum_name(xfersum_type));
+   rprintf(FINFO, "[%s] chosen pre-transfer checksum: 
%s\n",
+   who_am_i(), checksum_name(checksum_type));
+   }
+   }
+}
+
+static int parse_checksum_list(const char *from, char *sumbuf, int sumbuf_len, 
char *saw)
+{
+   char *to = sumbuf, *tok = NULL;
+   int cnt = 0;
+
+   memset(saw, 0, CSUM_SAW_BUFLEN);
+
+   while (1) {
+   if (*from == ' ' || !*from) {
+   if (tok) {
+   

[SCM] The rsync repository. - branch master updated

2020-05-22 Thread Rsync CVS commit messages
The branch, master has been updated
   via  4f6c8c66 Checksum negotiation & more bits for compat_flags
   via  a7303a3d Fix a bug in the writing of the batch.sh file
  from  70c6b408 SSE2/SSSE3 optimized version of get_checksum1() for x86-64

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -
commit 4f6c8c6652c74b958c631ca9a16f450c6ce6a23c
Author: Wayne Davison 
Date:   Fri May 22 08:23:26 2020 -0700

Checksum negotiation & more bits for compat_flags

- Add checksum negotiation to the protocol so that we can easily add new
  checksum algorithms and each will be used when both sides support it.
- Increase the size of the compat_flags value in the protocol from a
  byte to an int.

commit a7303a3d3d1ab3221bcb950f19eefb10e27b4bf7
Author: Wayne Davison 
Date:   Fri May 22 08:10:41 2020 -0700

Fix a bug in the writing of the batch.sh file

Fix the code that writes the options and the default destination path
into the batch.sh file to be able to handle options being specified
after source/dest args.

---

Summary of changes:
 batch.c| 15 ---
 checksum.c | 88 ++
 compat.c   | 44 +++
 io.c   |  3 ++-
 main.c |  2 +-
 options.c  |  8 +++---
 rsync.yo   | 45 
 7 files changed, 163 insertions(+), 42 deletions(-)


Changeset truncated at 500 lines:

diff --git a/batch.c b/batch.c
index 263a9a35..8915d9e0 100644
--- a/batch.c
+++ b/batch.c
@@ -213,7 +213,7 @@ static void write_filter_rules(int fd)
  * understand most of the options, so it uses some overly simple
  * heuristics to munge the command line into something that will
  * (hopefully) work. */
-void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
+void write_batch_shell_file(int argc, char *argv[], int file_argc, char 
*file_argv[])
 {
int fd, i, len, err = 0;
char *p, *p2, filename[MAXPATHLEN];
@@ -237,8 +237,15 @@ void write_batch_shell_file(int argc, char *argv[], int 
file_arg_cnt)
else
write_sbuf(fd, " --exclude-from=-");
}
-   for (i = 1; i < argc - file_arg_cnt; i++) {
+   for (i = 1; i < argc; i++) {
p = argv[i];
+   if (file_argc && p == file_argv[0]) {
+   if (file_argc > 1) {
+   file_argv++;
+   file_argc--;
+   }
+   continue;
+   }
if (strncmp(p, "--files-from", 12) == 0
|| strncmp(p, "--filter", 8) == 0
|| strncmp(p, "--include", 9) == 0
@@ -267,8 +274,8 @@ void write_batch_shell_file(int argc, char *argv[], int 
file_arg_cnt)
err = 1;
}
}
-   if (!(p = check_for_hostspec(argv[argc - 1], , )))
-   p = argv[argc - 1];
+   if (!(p = check_for_hostspec(file_argv[file_argc - 1], , )))
+   p = file_argv[file_argc - 1];
if (write(fd, " ${1:-", 6) != 6
 || write_arg(fd, p) < 0)
err = 1;
diff --git a/checksum.c b/checksum.c
index 8698543d..980d262b 100644
--- a/checksum.c
+++ b/checksum.c
@@ -21,6 +21,10 @@
 
 #include "rsync.h"
 
+extern int am_server;
+extern int local_server;
+extern int whole_file;
+extern int read_batch;
 extern int checksum_seed;
 extern int protocol_version;
 extern int proper_seed_order;
@@ -33,27 +37,21 @@ extern char *checksum_choice;
 #define CSUM_MD4 4
 #define CSUM_MD5 5
 
+const char *default_checksum_list =
+   "md5 md4";
+
+#define MAX_CHECKSUM_LIST 1024
+
 int xfersum_type = 0; /* used for the file transfer checksums */
 int checksum_type = 0; /* used for the pre-transfer (--checksum) checksums */
+const char *negotiated_csum_name = NULL;
 
-/* Returns 1 if --whole-file must be enabled. */
-int parse_checksum_choice(void)
-{
-   char *cp = checksum_choice ? strchr(checksum_choice, ',') : NULL;
-   if (cp) {
-   xfersum_type = parse_csum_name(checksum_choice, cp - 
checksum_choice);
-   checksum_type = parse_csum_name(cp+1, -1);
-   } else
-   xfersum_type = checksum_type = parse_csum_name(checksum_choice, 
-1);
-   return xfersum_type == CSUM_NONE;
-}
-
-int parse_csum_name(const char *name, int len)
+static int parse_csum_name(const char *name, int len, int allow_auto)
 {
if (len < 0 && name)
len = strlen(name);
 
-   if (!name || (len == 4 && strncasecmp(name, "auto", 4) == 0)) {
+   if (!name || (allow_auto && len == 4 && strncasecmp(name, "auto", 4) == 
0)) {
if (protocol_version >= 30)
return CSUM_MD5;
if (protocol_version >= 

[SCM] The rsync repository. - branch master updated

2020-05-22 Thread Rsync CVS commit messages
The branch, master has been updated
   via  5fa4209c AVX2 optimized version of get_checksum1() for x86-64
  from  4f6c8c66 Checksum negotiation & more bits for compat_flags

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -
commit 5fa4209ca0ce67f18fc9fd5da2ac6a83b4f7d34e
Author: Jorrit Jongma 
Date:   Fri May 22 13:03:55 2020 +0200

AVX2 optimized version of get_checksum1() for x86-64

Additionally restructures build switches and defines from SSE2 to SIMD,
to allow potential reuse should patches become available with SIMD
instructions for other processor architectures.

(Some minor tweaks of Jorrit's patch to avoid requiring GNU make and to
avoid C++ comments in .c files.)

---

Summary of changes:
 Makefile.in  |   7 +-
 checksum.c   |   2 +-
 checksum_sse2.cpp| 289 -
 configure.ac |  29 ++--
 options.c|  10 +-
 simd-checksum-x86_64.cpp | 414 +++
 6 files changed, 444 insertions(+), 307 deletions(-)
 delete mode 100644 checksum_sse2.cpp
 create mode 100644 simd-checksum-x86_64.cpp


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 30869294..0e18e96e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -31,6 +31,8 @@ VERSION=@RSYNC_VERSION@
 .SUFFIXES:
 .SUFFIXES: .c .o
 
+SIMD_x86_64=simd-checksum-x86_64.o
+
 GENFILES=configure.sh aclocal.m4 config.h.in proto.h proto.h-tstamp rsync.1 
rsync-ssl.1 rsyncd.conf.5
 HEADERS=byteorder.h config.h errcode.h proto.h rsync.h ifuncs.h itypes.h 
inums.h \
lib/pool_alloc.h
@@ -43,11 +45,10 @@ OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o 
sender.o exclude.o \
 OBJS2=options.o io.o compat.o hlink.o token.o uidlist.o socket.o hashtable.o \
fileio.o batch.o clientname.o chmod.o acls.o xattrs.o
 OBJS3=progress.o pipe.o
-CXXOBJ=@CXXOBJ@
 DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o 
authenticate.o
 popt_OBJS=popt/findme.o  popt/popt.o  popt/poptconfig.o \
popt/popthelp.o popt/poptparse.o
-OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(CXXOBJ) $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ 
@BUILD_POPT@
+OBJS=$(OBJS1) $(OBJS2) $(OBJS3) @SIMD@ $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ 
@BUILD_POPT@
 
 TLS_OBJ = tls.o syscall.o t_stub.o lib/compat.o lib/snprintf.o 
lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
 
@@ -118,7 +119,7 @@ rounding.h: rounding.c rsync.h proto.h
fi
@rm -f rounding.out
 
-checksum_sse2.o: checksum_sse2.cpp
+simd-checksum-x86_64.o: simd-checksum-x86_64.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
 
 tls$(EXEEXT): $(TLS_OBJ)
diff --git a/checksum.c b/checksum.c
index 980d262b..54e2c4aa 100644
--- a/checksum.c
+++ b/checksum.c
@@ -155,7 +155,7 @@ int canonical_checksum(int csum_type)
return csum_type >= CSUM_MD4 ? 1 : 0;
 }
 
-#ifndef ENABLE_SSE2 /* See checksum_sse2.cpp for the SSE2 version. */
+#ifndef HAVE_SIMD /* See simd-checksum-*.cpp. */
 /*
   a simple 32 bit checksum that can be updated from either end
   (inspired by Mark Adler's Adler-32 checksum)
diff --git a/checksum_sse2.cpp b/checksum_sse2.cpp
deleted file mode 100644
index 515596f0..
--- a/checksum_sse2.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * SSE2/SSSE3-optimized routines to support checksumming of bytes.
- *
- * Copyright (C) 1996 Andrew Tridgell
- * Copyright (C) 1996 Paul Mackerras
- * Copyright (C) 2004-2020 Wayne Davison
- * Copyright (C) 2020 Jorrit Jongma
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, visit the http://fsf.org website.
- */
-/*
- * Optimization target for get_checksum1() was the Intel Atom D2700, the
- * slowest CPU in the test set and the most likely to be CPU limited during
- * transfers. The combination of intrinsics was chosen specifically for the
- * most gain on that CPU, other combinations were occasionally slightly
- * faster on the others.
- *
- * While on more modern CPUs transfers are less likely to be CPU limited,
- * lower CPU usage is always better. Improvements may still be seen when
- * matching chunks from NVMe storage even on newer CPUs.
- *
- * Benchmarks   C   SSE2SSSE3
- * - Intel Atom D2700   550 MB/s750 MB/s1000