From: Arvin Schnell Date: Fri, 10 Oct 2014 10:16:09 +0000 (+0200) Subject: - improved fadvise usage X-Git-Tag: v0.2.5~7^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=refs%2Fpull%2F124%2Fhead;p=thirdparty%2Fsnapper.git - improved fadvise usage --- diff --git a/package/snapper.changes b/package/snapper.changes index cc04e1d0..e906c29e 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Oct 10 12:15:36 CEST 2014 - aschnell@suse.de + +- improved fadvise usage + ------------------------------------------------------------------- Fri Oct 3 01:05:01 CEST 2014 - dsterba@suse.cz diff --git a/snapper/AppUtil.cc b/snapper/AppUtil.cc index f3804bf9..2db7269b 100644 --- a/snapper/AppUtil.cc +++ b/snapper/AppUtil.cc @@ -91,6 +91,11 @@ namespace snapper bool copyfile(int src_fd, int dest_fd) { + posix_fadvise(src_fd, 0, 0, POSIX_FADV_SEQUENTIAL); + + // TODO: maybe use POSIX_FADV_DONTNEED on dest_fd, but this could + // trigger a kernel bug (see bsc #888259) + while (true) { // use small value for count to make function better interruptible diff --git a/snapper/Compare.cc b/snapper/Compare.cc index 576845a6..50069a54 100644 --- a/snapper/Compare.cc +++ b/snapper/Compare.cc @@ -77,8 +77,8 @@ namespace snapper return false; } - posix_fadvise(fd1, 0, stat1.st_size, POSIX_FADV_SEQUENTIAL); - posix_fadvise(fd2, 0, stat2.st_size, POSIX_FADV_SEQUENTIAL); + posix_fadvise(fd1, 0, 0, POSIX_FADV_SEQUENTIAL); + posix_fadvise(fd2, 0, 0, POSIX_FADV_SEQUENTIAL); static_assert(sizeof(off_t) >= 8, "off_t is too small");