cheers
tobi
-Changes:
+Changes:
2007-04-23
* pass --drop-cache on to the remote server
* make test works now
+To use this patch, run these commands for a successful build:
+
+ patch -p1 <patches/drop-cache.diff
+ ./configure
+ make
+
+based-on: 40afd365cc8ca968fd16e161d24df5b8a8a520cc
diff --git a/checksum.c b/checksum.c
--- a/checksum.c
+++ b/checksum.c
-@@ -26,6 +26,10 @@ extern int protocol_version;
-
- int csum_length = SHORT_SUM_LENGTH; /* initial value */
+@@ -24,6 +24,10 @@
+ extern int checksum_seed;
+ extern int protocol_version;
+#ifdef HAVE_POSIX_FADVISE64
+#define close(fd) fadv_close(fd)
diff --git a/cleanup.c b/cleanup.c
--- a/cleanup.c
+++ b/cleanup.c
-@@ -46,7 +46,13 @@ void close_all(void)
+@@ -47,7 +47,13 @@ void close_all(void)
int fd;
int ret;
STRUCT_STAT st;
max_fd = sysconf(_SC_OPEN_MAX) - 1;
for (fd = max_fd; fd >= 0; fd--) {
if ((ret = do_fstat(fd, &st)) == 0) {
-diff --git a/configure.in b/configure.in
---- a/configure.in
-+++ b/configure.in
-@@ -554,7 +554,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
+diff --git a/configure.ac b/configure.ac
+--- a/configure.ac
++++ b/configure.ac
+@@ -570,6 +570,7 @@ AC_FUNC_ALLOCA
+ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
+ fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
+ memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
++ posix_fadvise64 \
strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
- strerror putenv iconv_open locale_charset nl_langinfo getxattr \
-- extattr_get_link sigaction sigprocmask setattrlist)
-+ extattr_get_link sigaction sigprocmask setattrlist posix_fadvise64)
-
- dnl cygwin iconv.h defines iconv_open as libiconv_open
- if test x"$ac_cv_func_iconv_open" != x"yes"; then
+ seteuid strerror putenv iconv_open locale_charset nl_langinfo getxattr \
diff --git a/fileio.c b/fileio.c
--- a/fileio.c
+++ b/fileio.c
-@@ -30,6 +30,12 @@ extern int sparse_files;
- static char last_byte;
- static size_t sparse_seek = 0;
+@@ -29,6 +29,12 @@ extern int sparse_files;
+
+ static OFF_T sparse_seek = 0;
+#ifdef HAVE_POSIX_FADVISE64
+#define close(fd) fadv_close(fd)
+#define write(fd,buf,len) fadv_write(fd,buf,len)
+#endif
+
- int sparse_end(int f)
+ int sparse_end(int f, OFF_T size)
{
int ret;
diff --git a/generator.c b/generator.c
--- a/generator.c
+++ b/generator.c
-@@ -115,6 +115,10 @@ static int need_retouch_dir_times;
+@@ -113,6 +113,10 @@ static int need_retouch_dir_times;
static int need_retouch_dir_perms;
static const char *solo_file = NULL;
int cvs_exclude = 0;
int dry_run = 0;
int do_xfers = 1;
-@@ -326,6 +327,9 @@ void usage(enum logcode F)
+@@ -325,6 +326,9 @@ void usage(enum logcode F)
rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n");
rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
rprintf(F," -u, --update skip files that are newer on the receiver\n");
rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n");
rprintf(F," --append append data onto shorter files\n");
rprintf(F," --append-verify like --append, but with old data in file checksum\n");
-@@ -534,6 +538,9 @@ static struct poptOption long_options[] = {
- {"no-one-file-system",'x',POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
- {"no-x", 'x', POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
+@@ -533,6 +537,9 @@ static struct poptOption long_options[] = {
+ {"no-one-file-system",0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
+ {"no-x", 0, POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
{"update", 'u', POPT_ARG_NONE, &update_only, 0, 0, 0 },
+#ifdef HAVE_POSIX_FADVISE64
+ {"drop-cache", 0, POPT_ARG_NONE, &drop_cache, 0, 0, 0 },
{"existing", 0, POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
{"ignore-non-existing",0,POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
{"ignore-existing", 0, POPT_ARG_NONE, &ignore_existing, 0, 0, 0 },
-@@ -1719,6 +1726,11 @@ void server_options(char **args, int *argc_p)
+@@ -1730,6 +1737,11 @@ void server_options(char **args, int *argc_p)
if (!am_sender)
args[ac++] = "--sender";
diff --git a/receiver.c b/receiver.c
--- a/receiver.c
+++ b/receiver.c
-@@ -62,6 +62,10 @@ static int phase = 0, redoing = 0;
+@@ -64,6 +64,10 @@ static flist_ndx_list batch_redo_list;
/* We're either updating the basis file or an identical copy: */
static int updating_basis_or_equiv;
+#define close(fd) fadv_close(fd)
+#endif
+
- /*
- * get_tmpname() - create a tmp filename for a given filename
- *
+ #define TMPNAME_SUFFIX ".XXXXXX"
+ #define TMPNAME_SUFFIX_LEN ((int)sizeof TMPNAME_SUFFIX - 1)
+
diff --git a/rsync.yo b/rsync.yo
--- a/rsync.yo
+++ b/rsync.yo
-@@ -352,6 +352,7 @@ to the detailed description below for a complete description. verb(
+@@ -369,6 +369,7 @@ to the detailed description below for a complete description. verb(
--super receiver attempts super-user activities
--fake-super store/recover privileged attrs using xattrs
-S, --sparse handle sparse files efficiently
-n, --dry-run perform a trial run with no changes made
-W, --whole-file copy files whole (w/o delta-xfer algorithm)
-x, --one-file-system don't cross filesystem boundaries
-@@ -1043,6 +1044,10 @@ NOTE: Don't use this option when the destination is a Solaris "tmpfs"
- filesystem. It doesn't seem to handle seeks over null regions
- correctly and ends up corrupting the files.
+@@ -1122,6 +1123,10 @@ dit(bf(-S, --sparse)) Try to handle sparse files efficiently so they take
+ up less space on the destination. Conflicts with bf(--inplace) because it's
+ not possible to overwrite data in a sparse fashion.
+dit(bf(--drop-cache)) Tell the OS to drop the caching of the file data. This
+prevents rsync from filling up the filesystem cache. This can sometimes help
diff --git a/sender.c b/sender.c
--- a/sender.c
+++ b/sender.c
-@@ -46,6 +46,10 @@ extern int write_batch;
+@@ -45,6 +45,10 @@ extern int write_batch;
extern struct stats stats;
extern struct file_list *cur_flist, *first_flist, *dir_flist;
diff --git a/util.c b/util.c
--- a/util.c
+++ b/util.c
-@@ -26,6 +26,7 @@
+@@ -25,6 +25,7 @@
+
extern int verbose;
- extern int dry_run;
extern int module_id;
+extern int drop_cache;
extern int modify_window;
extern int relative_paths;
- extern int human_readable;
-@@ -41,6 +42,131 @@ char curr_dir[MAXPATHLEN];
+ extern int preserve_times;
+@@ -42,6 +43,131 @@ char curr_dir[MAXPATHLEN];
unsigned int curr_dir_len;
int curr_dir_depth; /* This is only set for a sanitizing daemon. */
+ fadv_fd_init_func();
+ fadv_close_buffer_size += pos - fadv_fd_pos[fd];
+ fadv_close_ring[fadv_close_ring_head] = newfd;
-+ fadv_close_ring_head = (fadv_close_ring_head + 1) % fadv_max_fd;
++ fadv_close_ring_head = (fadv_close_ring_head + 1) % fadv_max_fd;
+ fadv_close_ring_size ++;
+ if (fadv_close_ring_size == fadv_max_fd || fadv_close_buffer_size > 1024*1024 ){
+ /* it seems fastest to drop things 'in groups' */
+ fadv_close_all();
-+ }
++ }
+ }
+ return close(fd);
+}