[PATCH 3/3] Inform kernel of FADV_DONTNEED hint in receiver

Ben Gamari bgamari.foss at gmail.com
Fri Feb 17 17:54:11 MST 2012


Use the FADV_DONTNEED fadvise hint after finishing writing to a
destinataion fd in the receiver.
---
 receiver.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/receiver.c b/receiver.c
index d90fa25..b151cf8 100644
--- a/receiver.c
+++ b/receiver.c
@@ -742,6 +742,12 @@ int recv_files(int f_in, char *local_name)
 		recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
 				       fname, fd2, F_LENGTH(file));
 
+		if (do_fadvise(fd2, 0, 0, POSIX_FADV_DONTNEED) != 0) {
+			rsyserr(FERROR_XFER, errno,
+				"fadvise failed in writing %s",
+				full_fname(fname));
+		}
+
 		log_item(log_code, file, &initial_stats, iflags, NULL);
 
 		if (fd1 != -1)
-- 
1.7.5.4



More information about the rsync mailing list