The patches for 3.2.7pre1.
[rsync-patches.git] / checksum-reading.diff
index db280b371f681ab1546a5f8189b6cbbbcbf2707f..5c1466a370e5b8df85e5371900c510c755b6b42f 100644 (file)
@@ -16,11 +16,11 @@ To use this patch, run these commands for a successful build:
     ./configure                               (optional if already run)
     make
 
-based-on: 34141954c7179438f3b3c5e11f55089e5aee5a8e
+based-on: ed4b3448be243b1bdb30a5da811f1e217f5a0601
 diff --git a/clientserver.c b/clientserver.c
 --- a/clientserver.c
 +++ b/clientserver.c
-@@ -43,6 +43,8 @@ extern int numeric_ids;
+@@ -44,6 +44,8 @@ extern int numeric_ids;
  extern int filesfrom_fd;
  extern int remote_protocol;
  extern int protocol_version;
@@ -29,7 +29,7 @@ diff --git a/clientserver.c b/clientserver.c
  extern int io_timeout;
  extern int no_detach;
  extern int write_batch;
-@@ -975,6 +977,9 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
+@@ -1106,6 +1108,9 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
        } else if (am_root < 0) /* Treat --fake-super from client as --super. */
                am_root = 2;
  
@@ -39,6 +39,17 @@ diff --git a/clientserver.c b/clientserver.c
        if (filesfrom_fd == 0)
                filesfrom_fd = f_in;
  
+diff --git a/daemon-parm.txt b/daemon-parm.txt
+--- a/daemon-parm.txt
++++ b/daemon-parm.txt
+@@ -49,6 +49,7 @@ INTEGER      max_connections         0
+ INTEGER       max_verbosity           1
+ INTEGER       timeout                 0
++ENUM  checksum_files          CSF_IGNORE_FILES
+ ENUM  syslog_facility         LOG_DAEMON
+ BOOL  fake_super              False
 diff --git a/flist.c b/flist.c
 --- a/flist.c
 +++ b/flist.c
@@ -55,10 +66,10 @@ diff --git a/flist.c b/flist.c
  extern int inc_recurse;
  extern int always_checksum;
 +extern int basis_dir_cnt;
- extern int checksum_type;
  extern int module_id;
  extern int ignore_errors;
-@@ -61,6 +63,7 @@ extern int implied_dirs;
+ extern int numeric_ids;
+@@ -62,6 +64,7 @@ extern int implied_dirs;
  extern int ignore_perishable;
  extern int non_perishable_cnt;
  extern int prune_empty_dirs;
@@ -66,15 +77,15 @@ diff --git a/flist.c b/flist.c
  extern int copy_links;
  extern int copy_unsafe_links;
  extern int protocol_version;
-@@ -72,6 +75,7 @@ extern int sender_symlink_iconv;
- extern int output_needs_newline;
+@@ -74,6 +77,7 @@ extern int output_needs_newline;
  extern int sender_keeps_checksum;
+ extern int trust_sender_filter;
  extern int unsort_ndx;
 +extern char *basis_dir[];
  extern uid_t our_uid;
  extern struct stats stats;
  extern char *filesfrom_host;
-@@ -89,6 +93,20 @@ extern int filesfrom_convert;
+@@ -92,6 +96,20 @@ extern int filesfrom_convert;
  extern iconv_t ic_send, ic_recv;
  #endif
  
@@ -95,20 +106,21 @@ diff --git a/flist.c b/flist.c
  #define PTR_SIZE (sizeof (struct file_struct *))
  
  int io_error;
-@@ -133,7 +151,11 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -136,8 +154,12 @@ static char empty_sum[MAX_DIGEST_LEN];
  static int flist_count_offset; /* for --delete --progress */
  static int show_filelist_progress;
  
--static void flist_sort_and_clean(struct file_list *flist, int strip_root);
 +static struct csum_cache {
 +      struct file_list *flist;
 +} *csum_cache = NULL;
 +
+ static struct file_list *flist_new(int flags, const char *msg);
+-static void flist_sort_and_clean(struct file_list *flist, int strip_root);
 +static void flist_sort_and_clean(struct file_list *flist, int flags);
  static void output_flist(struct file_list *flist);
  
  void init_flist(void)
-@@ -326,6 +348,238 @@ static void flist_done_allocating(struct file_list *flist)
+@@ -329,6 +351,235 @@ static void flist_done_allocating(struct file_list *flist)
                flist->pool_boundary = ptr;
  }
  
@@ -116,11 +128,8 @@ diff --git a/flist.c b/flist.c
 +{
 +      int slot, slots = am_sender ? 1 : basis_dir_cnt + 1;
 +
-+      if (!csum_cache) {
++      if (!csum_cache)
 +              csum_cache = new_array0(struct csum_cache, slots);
-+              if (!csum_cache)
-+                      out_of_memory("reset_checksum_cache");
-+      }
 +
 +      for (slot = 0; slot < slots; slot++) {
 +              struct file_list *flist = csum_cache[slot].flist;
@@ -221,7 +230,7 @@ diff --git a/flist.c b/flist.c
 +
 +      while (fgets(line, sizeof line, fp)) {
 +              cp = line;
-+              if (checksum_type == 5) {
++              if (file_sum_nni->num == CSUM_MD5) {
 +                      char *alt_sum = cp;
 +                      if (*cp == '=')
 +                              while (*++cp == '=') {}
@@ -256,7 +265,7 @@ diff --git a/flist.c b/flist.c
 +                      break;
 +              while (*++cp == ' ') {}
 +
-+              if (checksum_type != 5) {
++              if (file_sum_nni->num < CSUM_MD5) {
 +                      char *alt_sum = cp;
 +                      if (*cp == '=')
 +                              while (*++cp == '=') {}
@@ -347,7 +356,7 @@ diff --git a/flist.c b/flist.c
  /* Call this with EITHER (1) "file, NULL, 0" to chdir() to the file's
   * F_PATHNAME(), or (2) "NULL, dir, dirlen" to chdir() to the supplied dir,
   * with dir == NULL taken to be the starting directory, and dirlen < 0
-@@ -1154,7 +1408,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1231,7 +1482,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                              STRUCT_STAT *stp, int flags, int filter_level)
  {
        static char *lastdir;
@@ -356,7 +365,7 @@ diff --git a/flist.c b/flist.c
        struct file_struct *file;
        char thisname[MAXPATHLEN];
        char linkname[MAXPATHLEN];
-@@ -1300,9 +1554,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1377,9 +1628,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                        memcpy(lastdir, thisname, len);
                        lastdir[len] = '\0';
                        lastdir_len = len;
@@ -374,7 +383,7 @@ diff --git a/flist.c b/flist.c
        basename_len = strlen(basename) + 1; /* count the '\0' */
  
  #ifdef SUPPORT_LINKS
-@@ -1320,11 +1581,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1409,11 +1667,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                extra_len += EXTRA_LEN;
  #endif
  
@@ -388,7 +397,7 @@ diff --git a/flist.c b/flist.c
  
  #if EXTRA_ROUNDING > 0
        if (extra_len & (EXTRA_ROUNDING * EXTRA_LEN))
-@@ -1411,8 +1669,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1502,8 +1757,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                return NULL;
        }
  
@@ -405,7 +414,7 @@ diff --git a/flist.c b/flist.c
  
        if (unsort_ndx)
                F_NDX(file) = stats.num_dirs;
-@@ -2633,7 +2897,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
+@@ -2720,7 +2981,7 @@ struct file_list *recv_file_list(int f, int dir_ndx)
        /* The --relative option sends paths with a leading slash, so we need
         * to specify the strip_root option here.  We rejected leading slashes
         * for a non-relative transfer in recv_file_entry(). */
@@ -414,7 +423,7 @@ diff --git a/flist.c b/flist.c
  
        if (protocol_version < 30) {
                /* Recv the io_error flag */
-@@ -2884,7 +3148,7 @@ void flist_free(struct file_list *flist)
+@@ -2965,7 +3226,7 @@ void flist_free(struct file_list *flist)
  
  /* This routine ensures we don't have any duplicate names in our file list.
   * duplicate names can cause corruption because of the pipelining. */
@@ -423,7 +432,7 @@ diff --git a/flist.c b/flist.c
  {
        char fbuf[MAXPATHLEN];
        int i, prev_i;
-@@ -2935,7 +3199,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -3016,7 +3277,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
                        /* If one is a dir and the other is not, we want to
                         * keep the dir because it might have contents in the
                         * list.  Otherwise keep the first one. */
@@ -432,7 +441,7 @@ diff --git a/flist.c b/flist.c
                                struct file_struct *fp = flist->sorted[j];
                                if (!S_ISDIR(fp->mode))
                                        keep = i, drop = j;
-@@ -2951,8 +3215,8 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -3032,8 +3293,8 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
                        } else
                                keep = j, drop = i;
  
@@ -443,7 +452,7 @@ diff --git a/flist.c b/flist.c
                                        rprintf(FINFO,
                                            "removing duplicate name %s from file list (%d)\n",
                                            f_name(file, fbuf), drop + flist->ndx_start);
-@@ -2974,7 +3238,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
+@@ -3055,7 +3316,7 @@ static void flist_sort_and_clean(struct file_list *flist, int strip_root)
        }
        flist->high = prev_i;
  
@@ -455,7 +464,7 @@ diff --git a/flist.c b/flist.c
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
-@@ -52,6 +52,7 @@ extern int delete_after;
+@@ -54,6 +54,7 @@ extern int delete_after;
  extern int missing_args;
  extern int msgdone_cnt;
  extern int ignore_errors;
@@ -463,37 +472,46 @@ diff --git a/generator.c b/generator.c
  extern int remove_source_files;
  extern int delay_updates;
  extern int update_only;
-@@ -578,7 +579,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
+@@ -614,7 +615,7 @@ static enum filetype get_file_type(mode_t mode)
+ }
  
  /* Perform our quick-check heuristic for determining if a file is unchanged. */
--int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
-+int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st, int slot)
+-int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file, STRUCT_STAT *st)
++int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file, STRUCT_STAT *st, int slot)
  {
-       if (st->st_size != F_LENGTH(file))
-               return 0;
-@@ -587,7 +588,10 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
-          of the file time to determine whether to sync */
-       if (always_checksum > 0 && S_ISREG(st->st_mode)) {
-               char sum[MAX_DIGEST_LEN];
--              file_checksum(fn, st, sum);
-+              if (checksum_files && slot >= 0)
-+                      get_cached_checksum(slot, fn, file, st, sum);
-+              else
-+                      file_checksum(fn, st, sum);
-               return memcmp(sum, F_SUM(file), flist_csum_len) == 0;
-       }
+       switch (ftype) {
+         case FT_REG:
+@@ -625,7 +626,10 @@ int quick_check_ok(enum filetype ftype, const char *fn, struct file_struct *file
+                * of the file mtime to determine whether to sync. */
+               if (always_checksum > 0) {
+                       char sum[MAX_DIGEST_LEN];
+-                      file_checksum(fn, st, sum);
++                      if (checksum_files && slot >= 0)
++                              get_cached_checksum(slot, fn, file, st, sum);
++                      else
++                              file_checksum(fn, st, sum);
+                       return memcmp(sum, F_SUM(file), flist_csum_len) == 0;
+               }
  
-@@ -884,7 +888,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
+@@ -956,7 +960,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
                        best_match = j;
                        match_level = 1;
                }
--              if (!unchanged_file(cmpbuf, file, &sxp->st))
-+              if (!unchanged_file(cmpbuf, file, &sxp->st, j+1))
+-              if (!quick_check_ok(FT_REG, cmpbuf, file, &sxp->st))
++              if (!quick_check_ok(FT_REG, cmpbuf, file, &sxp->st, j+1))
                        continue;
                if (match_level == 1) {
                        best_match = j;
-@@ -1195,7 +1199,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1079,7 +1083,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
+                       match_level = 1;
+                       best_match = j;
+               }
+-              if (!quick_check_ok(ftype, cmpbuf, file, &sxp->st))
++              if (!quick_check_ok(ftype, cmpbuf, file, &sxp->st, j+1))
+                       continue;
+               if (match_level < 2) {
+                       match_level = 2;
+@@ -1215,7 +1219,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
         * --ignore-non-existing, daemon exclude, or mkdir failure. */
        static struct file_struct *skip_dir = NULL;
        static struct file_list *fuzzy_dirlist[MAX_BASIS_DIRS+1];
@@ -502,7 +520,7 @@ diff --git a/generator.c b/generator.c
        struct file_struct *fuzzy_file = NULL;
        int fd = -1, f_copy = -1;
        stat_x sx, real_sx;
-@@ -1306,8 +1310,9 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1332,8 +1336,9 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                                                fuzzy_dirlist[i] = NULL;
                                        }
                                }
@@ -514,11 +532,11 @@ diff --git a/generator.c b/generator.c
  #ifdef SUPPORT_ACLS
                        if (!preserve_perms)
                                dflt_perms = default_perms_for_dir(dn);
-@@ -1315,6 +1320,24 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1341,6 +1346,24 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                }
                parent_dirname = dn;
  
-+              if (need_new_dirscan && S_ISREG(file->mode)) {
++              if (need_new_dirscan && ftype == FT_REG) {
 +                      int i;
 +                      strlcpy(fnamecmpbuf, dn, sizeof fnamecmpbuf);
 +                      for (i = 0; i < fuzzy_basis; i++) {
@@ -539,11 +557,38 @@ diff --git a/generator.c b/generator.c
                statret = link_stat(fname, &sx.st, keep_dirlinks && is_dir);
                stat_errno = errno;
        }
-@@ -1725,22 +1748,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1387,7 +1410,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+                       if (INFO_GTE(SKIP, 2)) {
+                               if (ftype != stype)
+                                       suf = " (type change)";
+-                              else if (!quick_check_ok(ftype, fname, file, &sx.st))
++                              else if (!quick_check_ok(ftype, fname, file, &sx.st, 0))
+                                       suf = always_checksum ? " (sum change)" : " (file change)";
+                               else if (!unchanged_attrs(fname, file, &sx))
+                                       suf = " (attr change)";
+@@ -1558,7 +1581,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+                       goto cleanup;
+               }
+               if (statret == 0) {
+-                      if (stype == FT_SYMLINK && quick_check_ok(stype, fname, file, &sx.st)) {
++                      if (stype == FT_SYMLINK && quick_check_ok(stype, fname, file, &sx.st, 0)) {
+                               /* The link is pointing to the right place. */
+                               set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
+                               if (itemizing)
+@@ -1627,7 +1650,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+               if (statret == 0) {
+                       if (ftype != stype)
+                               statret = -1;
+-                      else if (quick_check_ok(ftype, fname, file, &sx.st)) {
++                      else if (quick_check_ok(ftype, fname, file, &sx.st, 0)) {
+                               /* The device or special file is identical. */
+                               set_file_attrs(fname, file, &sx, NULL, maybe_ATTRS_REPORT);
+                               if (itemizing)
+@@ -1752,22 +1775,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                partialptr = NULL;
  
        if (statret != 0 && fuzzy_basis) {
--              if (need_fuzzy_dirlist && S_ISREG(file->mode)) {
+-              if (need_fuzzy_dirlist) {
 -                      const char *dn = file->dirname ? file->dirname : ".";
 -                      int i;
 -                      strlcpy(fnamecmpbuf, dn, sizeof fnamecmpbuf);
@@ -562,80 +607,48 @@ diff --git a/generator.c b/generator.c
                /* Sets fnamecmp_type to FNAMECMP_FUZZY or above. */
                fuzzy_file = find_fuzzy(file, fuzzy_dirlist, &fnamecmp_type);
                if (fuzzy_file) {
-@@ -1773,7 +1780,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1806,7 +1813,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                ;
        else if (fnamecmp_type >= FNAMECMP_FUZZY)
                ;
--      else if (unchanged_file(fnamecmp, file, &sx.st)) {
-+      else if (unchanged_file(fnamecmp, file, &sx.st, fnamecmp_type == FNAMECMP_FNAME ? 0 : -1)) {
+-      else if (quick_check_ok(FT_REG, fnamecmp, file, &sx.st)) {
++      else if (quick_check_ok(FT_REG, fnamecmp, file, &sx.st, fnamecmp_type == FNAMECMP_FNAME ? 0 : -1)) {
                if (partialptr) {
                        do_unlink(partialptr);
                        handle_partial_dir(partialptr, PDIR_DELETE);
 diff --git a/hlink.c b/hlink.c
 --- a/hlink.c
 +++ b/hlink.c
-@@ -410,7 +410,7 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
+@@ -406,7 +406,7 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
                                }
                                break;
                        }
--                      if (!unchanged_file(cmpbuf, file, &alt_sx.st))
-+                      if (!unchanged_file(cmpbuf, file, &alt_sx.st, j+1))
+-                      if (!quick_check_ok(FT_REG, cmpbuf, file, &alt_sx.st))
++                      if (!quick_check_ok(FT_REG, cmpbuf, file, &alt_sx.st, j+1))
                                continue;
                        statret = 1;
                        if (unchanged_attrs(cmpbuf, file, &alt_sx))
 diff --git a/loadparm.c b/loadparm.c
 --- a/loadparm.c
 +++ b/loadparm.c
-@@ -177,6 +177,7 @@ typedef struct {
-       BOOL temp_dir_EXP;
-       BOOL uid_EXP;
-+      int checksum_files;
-       int max_connections;
-       int max_verbosity;
-       int syslog_facility;
-@@ -294,6 +295,7 @@ static const all_vars Defaults = {
-  /* temp_dir_EXP; */          False,
-  /* uid_EXP; */                       False,
-+ /* checksum_files; */                CSF_IGNORE_FILES,
-  /* max_connections; */               0,
-  /* max_verbosity; */         1,
-  /* syslog_facility; */               LOG_DAEMON,
-@@ -396,6 +398,13 @@ static struct enum_list enum_facilities[] = {
+@@ -162,6 +162,13 @@ static struct enum_list enum_syslog_facility[] = {
        { -1, NULL }
  };
  
-+static struct enum_list enum_csum_modes[] = {
++static struct enum_list enum_checksum_files[] = {
 +      { CSF_IGNORE_FILES, "none" },
 +      { CSF_LAX_MODE, "lax" },
 +      { CSF_STRICT_MODE, "strict" },
 +      { -1, NULL }
 +};
 +
- static struct parm_struct parm_table[] =
- {
-  {"address",           P_STRING, P_GLOBAL,&Vars.g.bind_address,        NULL,0},
-@@ -411,6 +420,7 @@ static struct parm_struct parm_table[] =
-  {"auth users",        P_STRING, P_LOCAL, &Vars.l.auth_users,          NULL,0},
-  {"charset",           P_STRING, P_LOCAL, &Vars.l.charset,             NULL,0},
-+ {"checksum files",    P_ENUM,   P_LOCAL, &Vars.l.checksum_files,      enum_csum_modes,0},
-  {"comment",           P_STRING, P_LOCAL, &Vars.l.comment,             NULL,0},
-  {"dont compress",     P_STRING, P_LOCAL, &Vars.l.dont_compress,       NULL,0},
-  {"early exec",        P_STRING, P_LOCAL, &Vars.l.early_exec,          NULL,0},
-@@ -579,6 +589,7 @@ FN_LOCAL_STRING(lp_syslog_tag, syslog_tag)
- FN_LOCAL_STRING(lp_temp_dir, temp_dir)
- FN_LOCAL_STRING(lp_uid, uid)
-+FN_LOCAL_INTEGER(lp_checksum_files, checksum_files)
- FN_LOCAL_INTEGER(lp_max_connections, max_connections)
- FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity)
- FN_LOCAL_INTEGER(lp_syslog_facility, syslog_facility)
+ /* Expand %VAR% references.  Any unknown vars or unrecognized
+  * syntax leaves the raw chars unchanged. */
+ static char *expand_vars(const char *str)
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
-@@ -118,6 +118,7 @@ size_t bwlimit_writemax = 0;
+@@ -126,6 +126,7 @@ size_t bwlimit_writemax = 0;
  int ignore_existing = 0;
  int ignore_non_existing = 0;
  int need_messages_from_generator = 0;
@@ -643,24 +656,24 @@ diff --git a/options.c b/options.c
  int max_delete = INT_MIN;
  OFF_T max_size = -1;
  OFF_T min_size = -1;
-@@ -739,7 +740,7 @@ enum {OPT_SERVER = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
-       OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
+@@ -581,7 +582,7 @@ enum {OPT_SERVER = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
        OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
        OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
--      OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG,
-+      OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG, OPT_SUMFILES,
-       OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT,
-       OPT_OLD_COMPRESS, OPT_NEW_COMPRESS, OPT_NO_COMPRESS,
+       OPT_NO_D, OPT_APPEND, OPT_NO_ICONV, OPT_INFO, OPT_DEBUG, OPT_BLOCK_SIZE,
+-      OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT, OPT_STDERR,
++      OPT_USERMAP, OPT_GROUPMAP, OPT_CHOWN, OPT_BWLIMIT, OPT_STDERR, OPT_SUMFILES,
+       OPT_OLD_COMPRESS, OPT_NEW_COMPRESS, OPT_NO_COMPRESS, OPT_OLD_ARGS,
+       OPT_STOP_AFTER, OPT_STOP_AT,
        OPT_REFUSED_BASE = 9000};
-@@ -890,6 +891,7 @@ static struct poptOption long_options[] = {
+@@ -738,6 +739,7 @@ static struct poptOption long_options[] = {
    {"no-c",             0,  POPT_ARG_VAL,    &always_checksum, 0, 0, 0 },
    {"checksum-choice",  0,  POPT_ARG_STRING, &checksum_choice, 0, 0, 0 },
    {"cc",               0,  POPT_ARG_STRING, &checksum_choice, 0, 0, 0 },
 +  {"sumfiles",         0,  POPT_ARG_STRING, 0, OPT_SUMFILES, 0, 0 },
-   {"block-size",      'B', POPT_ARG_LONG,   &block_size, 0, 0, 0 },
+   {"block-size",      'B', POPT_ARG_STRING, 0, OPT_BLOCK_SIZE, 0, 0 },
    {"compare-dest",     0,  POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
    {"copy-dest",        0,  POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
-@@ -1699,6 +1701,23 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -1746,6 +1748,23 @@ int parse_arguments(int *argc_p, const char ***argv_p)
                        }
                        break;
  
@@ -684,46 +697,46 @@ diff --git a/options.c b/options.c
                case OPT_INFO:
                        arg = poptGetOptArg(pc);
                        parse_output_words(info_words, info_levels, arg, USER_PRIORITY);
-@@ -1968,6 +1987,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
+@@ -2099,6 +2118,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
        }
  #endif
  
 +      if (!always_checksum)
 +              checksum_files = CSF_IGNORE_FILES;
 +
-       if (block_size) {
-               /* We may not know the real protocol_version at this point if this is the client
-                * option parsing, but we still want to check it so that the client can specify
+       if (write_batch && read_batch) {
+               snprintf(err_buf, sizeof err_buf,
+                       "--write-batch and --read-batch can not be used together\n");
 diff --git a/rsync.1.md b/rsync.1.md
 --- a/rsync.1.md
 +++ b/rsync.1.md
-@@ -337,6 +337,7 @@ detailed description below for a complete description.
+@@ -386,6 +386,7 @@ has its own detailed description later in this manpage.
  --quiet, -q              suppress non-error messages
  --no-motd                suppress daemon-mode MOTD
  --checksum, -c           skip based on checksum, not mod-time & size
 +--sumfiles=MODE          use .rsyncsums to speedup --checksum mode
- --archive, -a            archive mode; equals -rlptgoD (no -H,-A,-X)
+ --archive, -a            archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
  --no-OPTION              turn off an implied OPTION (e.g. --no-D)
  --recursive, -r          recurse into directories
-@@ -675,6 +676,8 @@ your home directory (remove the '=' for that).
+@@ -778,6 +779,8 @@ expand it.
      file that has the same size as the corresponding sender's file: files with
      either a changed size or a changed checksum are selected for transfer.
  
-+    See also the `--sumfiles` option for a way to use cached checksum data.
++    See also the [`--sumfiles`](#opt) option for a way to use cached checksum data.
 +
      Note that rsync always verifies that each _transferred_ file was correctly
      reconstructed on the receiving side by checking a whole-file checksum that
      is generated as the file is transferred, but that automatic
-@@ -685,6 +688,38 @@ your home directory (remove the '=' for that).
-     can be overridden using either the `--checksum-choice` option or an
-     environment variable that is discussed in that option's section.
+@@ -789,6 +792,38 @@ expand it.
+     option or an environment variable that is discussed in that option's
+     section.
  
 +0.  `--sumfiles=MODE`
 +
 +    This option tells rsync to make use of any cached checksum information it
 +    finds in per-directory .rsyncsums files when the current transfer is using
-+    the `--checksum` option.  If the checksum data is up-to-date, it is used
-+    instead of recomputing it, saving both disk I/O and CPU time.  If the
++    the [`--checksum`](#opt) option.  If the checksum data is up-to-date, it is
++    used instead of recomputing it, saving both disk I/O and CPU time.  If the
 +    checksum data is missing or outdated, the checksum is computed just as it
 +    would be if `--sumfiles` was not specified.
 +
@@ -733,18 +746,18 @@ diff --git a/rsync.1.md b/rsync.1.md
 +    or update these files, but there is a perl script in the support directory
 +    named "rsyncsums" that can be used for that.
 +
-+    This option has no effect unless `--checksum`, `-c` was also specified.  It
-+    also only affects the current side of the transfer, so if you want the
-+    remote side to parse its own .rsyncsums files, specify the option via the
-+    `--rsync-path` option (e.g. "--rsync-path="rsync --sumfiles=lax").
++    This option has no effect unless [`--checksum`](#opt) (`-c`) was also
++    specified.  It also only affects the current side of the transfer, so if
++    you want the remote side to parse its own .rsyncsums files, specify the
++    option via [`--remote-option`](#opt) (`-M`) (e.g. "`-M--sumfiles=lax`").
 +
 +    To avoid transferring the system's checksum files, you can use an exclude
-+    (e.g. `--exclude=.rsyncsums`).  To make this easier to type, you can use a
-+    popt alias.  For instance, adding the following line in your ~/.popt file
-+    defines a `--cc` option that enables lax checksum files and excludes the
-+    checksum files:
++    (e.g. [`--exclude=.rsyncsums`](#opt)).  To make this easier to type, you
++    can use a popt alias.  For instance, adding the following line in your
++    ~/.popt file defines a `--cs` option that enables lax checksum files and
++    excludes the checksum files:
 +
-+    >     rsync alias --cc -c --sumfiles=lax --exclude=.rsyncsums
++    >     rsync alias --cs -c --sumfiles=lax -M--sumfiles=lax -f-_.rsyncsums
 +
 +    An rsync daemon does not allow the client to control this setting, so see
 +    the "checksum files" daemon parameter for information on how to make a
@@ -756,20 +769,20 @@ diff --git a/rsync.1.md b/rsync.1.md
 diff --git a/rsync.h b/rsync.h
 --- a/rsync.h
 +++ b/rsync.h
-@@ -827,6 +827,10 @@ extern int xattrs_ndx;
+@@ -903,6 +903,10 @@ extern int file_sum_extra_cnt;
  #define F_SUM(f) ((char*)OPT_EXTRA(f, START_BUMP(f) + HLINK_BUMP(f) \
                                    + SUM_EXTRA_CNT - 1))
  
-+/* These are only valid on an entry read from a checksum file. */
++/* These are only valid on an entry derived from a checksum file. */
 +#define F_CTIME(f) OPT_EXTRA(f, LEN64_BUMP(f) + SUM_EXTRA_CNT)->unum
 +#define F_INODE(f) OPT_EXTRA(f, LEN64_BUMP(f) + SUM_EXTRA_CNT + 1)->unum
 +
  /* Some utility defines: */
  #define F_IS_ACTIVE(f) (f)->basename[0]
  #define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)
-@@ -1029,6 +1033,13 @@ typedef struct {
-       char fname[1]; /* has variable size */
- } relnamecache;
+@@ -1117,6 +1121,13 @@ typedef struct {
+ #define RELNAMECACHE_LEN (offsetof(relnamecache, fname))
+ #endif
  
 +#define CSF_ENABLE (1<<1)
 +#define CSF_LAX (1<<2)
@@ -784,7 +797,7 @@ diff --git a/rsync.h b/rsync.h
 diff --git a/rsyncd.conf.5.md b/rsyncd.conf.5.md
 --- a/rsyncd.conf.5.md
 +++ b/rsyncd.conf.5.md
-@@ -404,6 +404,19 @@ the values of parameters.  See the GLOBAL PARAMETERS section for more details.
+@@ -449,6 +449,19 @@ the values of parameters.  See the GLOBAL PARAMETERS section for more details.
      the max connections limit is not exceeded for the modules sharing the lock
      file.  The default is `/var/run/rsyncd.lock`.
  
@@ -793,7 +806,7 @@ diff --git a/rsyncd.conf.5.md b/rsyncd.conf.5.md
 +    This parameter tells rsync to make use of any cached checksum information
 +    it finds in per-directory .rsyncsums files when the current transfer is
 +    using the `--checksum` option.  The value can be set to either "lax",
-+    "strict", or "none" -- see the client's `--sumfiles` option for what these
++    "strict", or "none".  See the client's `--sumfiles` option for what these
 +    choices do.
 +
 +    Note also that the client's command-line option, `--sumfiles`, has no