The patches for 3.2.5.
[rsync-patches.git] / direct-io.diff
index 917fe8a97ea6fedd565f7bec2413a1126d5239d0..1ad91ec705cc421d32a0f3d2a63e98f26e9de9f1 100644 (file)
@@ -10,27 +10,19 @@ To use this patch, run these commands for a successful build:
     ./configure                         (optional if already run)
     make
 
-based-on: 43d6d0c5ba63e3a69717702a1d58ea6a04192bb4
+based-on: 5fcf20ee9d8abf7aae8578354f82c6f500822e06
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
 @@ -24,6 +24,7 @@
+ #include "ifuncs.h"
  #include <popt.h>
- #include <zlib.h>
  
 +extern int direct_io;
  extern int module_id;
  extern int local_server;
  extern int sanitize_paths;
-@@ -747,6 +748,7 @@ void usage(enum logcode F)
-   rprintf(F,"     --partial               keep partially transferred files\n");
-   rprintf(F,"     --partial-dir=DIR       put a partially transferred file into DIR\n");
-   rprintf(F,"     --delay-updates         put all updated files into place at transfer's end\n");
-+  rprintf(F,"     --direct-io             don't use buffer cache for xfer file I/O\n");
-   rprintf(F," -m, --prune-empty-dirs      prune empty directory chains from the file-list\n");
-   rprintf(F,"     --numeric-ids           don't map uid/gid values by user/group name\n");
-   rprintf(F,"     --usermap=STRING        custom username mapping\n");
-@@ -981,6 +983,8 @@ static struct poptOption long_options[] = {
+@@ -763,6 +764,8 @@ static struct poptOption long_options[] = {
    {"partial-dir",      0,  POPT_ARG_STRING, &partial_dir, 0, 0, 0 },
    {"delay-updates",    0,  POPT_ARG_VAL,    &delay_updates, 1, 0, 0 },
    {"no-delay-updates", 0,  POPT_ARG_VAL,    &delay_updates, 0, 0, 0 },
@@ -39,69 +31,71 @@ diff --git a/options.c b/options.c
    {"prune-empty-dirs",'m', POPT_ARG_VAL,    &prune_empty_dirs, 1, 0, 0 },
    {"no-prune-empty-dirs",0,POPT_ARG_VAL,    &prune_empty_dirs, 0, 0, 0 },
    {"no-m",             0,  POPT_ARG_VAL,    &prune_empty_dirs, 0, 0, 0 },
-diff --git a/rsync.yo b/rsync.yo
---- a/rsync.yo
-+++ b/rsync.yo
-@@ -401,6 +401,7 @@ to the detailed description below for a complete description.  verb(
     --partial               keep partially transferred files
     --partial-dir=DIR       put a partially transferred file into DIR
     --delay-updates         put all updated files into place at end
-+     --direct-io             don't use buffer cache for xfer file I/O
 -m, --prune-empty-dirs      prune empty directory chains from file-list
     --numeric-ids           don't map uid/gid values by user/group name
     --usermap=STRING        custom username mapping
-@@ -2348,6 +2349,14 @@ See also the "atomic-rsync" perl script in the "support" subdir for an
- update algorithm that is even more atomic (it uses bf(--link-dest) and a
- parallel hierarchy of files).
+diff --git a/rsync.1.md b/rsync.1.md
+--- a/rsync.1.md
++++ b/rsync.1.md
+@@ -434,6 +434,7 @@ has its own detailed description later in this manpage.
--partial                keep partially transferred files
--partial-dir=DIR        put a partially transferred file into DIR
--delay-updates          put all updated files into place at end
++--direct-io              don't use buffer cache for xfer file I/O
--prune-empty-dirs, -m   prune empty directory chains from file-list
--numeric-ids            don't map uid/gid values by user/group name
--usermap=STRING         custom username mapping
+@@ -3339,6 +3340,17 @@ expand it.
+     update algorithm that is even more atomic (it uses [`--link-dest`](#opt)
    and a parallel hierarchy of files).
  
-+dit(bf(--direct-io)) This option opens files with a direct-I/O flag that
-+makes the file I/O avoid the buffer cache.  The option only affects one
-+side of the transfer (unless the transfer is local).  If you want it to
-+affect both sides, use the bf(--remote-option) (bf(-M)) option to specify
-+it for the remote side.  For instance, this specifies it for both sides:
++0.  `--direct-io`
 +
-+quote(tt(  rsync -av {,-M}--direct-io /src/ host:/dest/))
++    This option opens files with a direct-I/O flag that makes the file I/O
++    avoid the buffer cache.  The option only affects one side of the transfer
++    (unless the transfer is local).  If you want it to affect both sides, use
++    the [`--remote-option`](#opt) (`-M`) option to specify it for the remote
++    side.  For instance, this specifies it for both sides (via brace
++    expansion):
 +
- dit(bf(-m, --prune-empty-dirs)) This option tells the receiving rsync to get
- rid of empty directories from the file-list, including nested directories
- that have no non-directory children.  This is useful for avoiding the
++    >     rsync -av {,-M}--direct-io /src/ host:/dest/
++
+ 0.  `--prune-empty-dirs`, `-m`
+     This option tells the receiving rsync to get rid of empty directories from
 diff --git a/syscall.c b/syscall.c
 --- a/syscall.c
 +++ b/syscall.c
-@@ -41,6 +41,8 @@ extern int list_only;
- extern int preserve_perms;
+@@ -44,6 +44,8 @@ extern int preserve_perms;
  extern int preserve_executability;
+ extern int open_noatime;
  
 +int direct_io = 0;
 +
- #define RETURN_ERROR_IF(x,e) \
-       do { \
-               if (x) { \
-@@ -69,7 +71,12 @@ int do_symlink(const char *lnk, const char *fname)
+ #ifndef S_BLKSIZE
+ # if defined hpux || defined __hpux__ || defined __hpux
+ #  define S_BLKSIZE 1024
+@@ -95,7 +97,12 @@ int do_symlink(const char *lnk, const char *path)
         * and write the lnk into it. */
        if (am_root < 0) {
                int ok, len = strlen(lnk);
--              int fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
+-              int fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
 +              int flags = O_WRONLY|O_CREAT|O_TRUNC;
 +
 +              if (direct_io)
 +                      flags |= O_DIRECT;
 +
-+              int fd = open(fname, flags, S_IWUSR|S_IRUSR);
++              int fd = open(path, flags, S_IWUSR|S_IRUSR);
                if (fd < 0)
                        return -1;
                ok = write(fd, lnk, len) == len;
-@@ -190,6 +197,9 @@ int do_open(const char *pathname, int flags, mode_t mode)
-               RETURN_ERROR_IF_RO_OR_LO;
-       }
+@@ -224,6 +231,8 @@ int do_open(const char *pathname, int flags, mode_t mode)
+       if (open_noatime)
+               flags |= O_NOATIME;
+ #endif
 +      if (direct_io)
 +              flags |= O_DIRECT;
-+
        return open(pathname, flags | O_BINARY, mode);
  }
-@@ -461,6 +471,9 @@ int do_open_nofollow(const char *pathname, int flags)
+@@ -684,6 +693,9 @@ int do_open_nofollow(const char *pathname, int flags)
  #endif
        }