Merge lp:~akopytov/percona-xtrabackup/bug925441 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov on 2012-03-22
Status: Merged
Approved by: Stewart Smith on 2012-03-26
Approved revision: 401
Merged at revision: 405
Proposed branch: lp:~akopytov/percona-xtrabackup/bug925441
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 63 lines (+13/-5)
1 file modified
src/xtrabackup.c (+13/-5)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug925441
Reviewer Review Type Date Requested Status
Stewart Smith (community) 2012-03-22 Approve on 2012-03-26
Review via email: mp+98817@code.launchpad.net

Description of the change

  The problem was that posix_fadvise(POSIX_FADV_DONTNEED) was used
  incorrectly, because the call just releases already cached pages from
  the pagecache, thus making a single-shot call before file access
  useless.

  Fixed by making sure the call is invoked after each read/write to
  make the feature work as advertised.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xtrabackup.c'
2--- src/xtrabackup.c 2012-02-20 04:38:44 +0000
3+++ src/xtrabackup.c 2012-03-22 11:21:18 +0000
4@@ -3125,7 +3125,6 @@
5
6 #ifdef USE_POSIX_FADVISE
7 posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);
8- posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);
9 #endif
10
11 if (my_stat(node->name, &src_stat, MYF(MY_WME)) == NULL) {
12@@ -3188,6 +3187,10 @@
13 goto error;
14 }
15
16+#ifdef USE_POSIX_FADVISE
17+ posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);
18+#endif
19+
20 /* check corruption and retry */
21 for (chunk_offset = 0; chunk_offset < chunk; chunk_offset += page_size) {
22 #ifndef INNODB_VERSION_SHORT
23@@ -3538,6 +3541,12 @@
24 rc = my_write(dst_log_fd, log_sys->buf, write_size,
25 MYF(MY_WME | MY_NABP));
26
27+#ifdef USE_POSIX_FADVISE
28+ if (!xtrabackup_log_only) {
29+ posix_fadvise(dst_log_fd, 0, 0, POSIX_FADV_DONTNEED);
30+ }
31+#endif
32+
33 if(rc) {
34 msg("xtrabackup: Error: write to logfile failed\n");
35 goto error;
36@@ -3792,7 +3801,6 @@
37
38 #ifdef USE_POSIX_FADVISE
39 posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);
40- posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);
41 #endif
42
43 if (my_seek(src_file, 0, SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR) {
44@@ -3816,6 +3824,9 @@
45 buf = (uchar *) ut_malloc(buf_size);
46
47 while ((bytes = my_read(src_file, buf, buf_size, MYF(MY_WME))) > 0) {
48+#ifdef USE_POSIX_FADVISE
49+ posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);
50+#endif
51 if (ds->write(dst_file, buf, bytes)) {
52 msg("xtrabackup: error: cannot write to stream "
53 "for %s.\n", XB_LOG_FILENAME);
54@@ -4228,9 +4239,6 @@
55 exit(EXIT_FAILURE);
56 }
57 }
58-#ifdef USE_POSIX_FADVISE
59- posix_fadvise(dst_log_fd, 0, 0, POSIX_FADV_DONTNEED);
60-#endif
61 } else {
62 dst_log_fd = dup(fileno(stdout));
63 if (dst_log_fd < 0) {

Subscribers

People subscribed via source and target branches