diff --git a/extra/mariabackup/ds_local.cc b/extra/mariabackup/ds_local.cc index ff2021fc03522..d9cd32922093c 100644 --- a/extra/mariabackup/ds_local.cc +++ b/extra/mariabackup/ds_local.cc @@ -136,6 +136,7 @@ local_open(ds_ctxt_t *ctxt, const char *path, local_file = (ds_local_file_t *) (file + 1); local_file->fd = fd; + posix_fadvise(local_file->fd, 0, 0, POSIX_FADV_DONTNEED); local_file->init_ibd_done = 0; local_file->is_ibd = (path_len > 5) && !strcmp(fullpath + path_len - 5, ".ibd"); local_file->compressed = 0; @@ -166,9 +167,7 @@ static int write_compressed(File fd, uchar *data, size_t len, size_t pagesize) size_t n_bytes = MY_MIN(pagesize, len - written); size_t datasize= trim_binary_zeros(ptr,n_bytes); if (datasize > 0) { - if (!my_write(fd, ptr, datasize, MYF(MY_WME | MY_NABP))) - posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); - else + if (my_write(fd, ptr, datasize, MYF(MY_WME | MY_NABP))) return 1; } if (datasize < n_bytes) { @@ -242,11 +241,10 @@ local_write(ds_file_t *file, const uchar *buf, size_t len) return write_compressed(fd, b, len, local_file->pagesize); } - if (!my_write(fd, b , len, MYF(MY_WME | MY_NABP))) { - posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); - return 0; + if (my_write(fd, b , len, MYF(MY_WME | MY_NABP))) { + return 1; } - return 1; + return 0; } static diff --git a/extra/mariabackup/ds_stdout.cc b/extra/mariabackup/ds_stdout.cc index 3fc0873b6ca85..a05740c37b728 100644 --- a/extra/mariabackup/ds_stdout.cc +++ b/extra/mariabackup/ds_stdout.cc @@ -84,6 +84,7 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)), #endif stdout_file->fd = my_fileno(stdout); + posix_fadvise(stdout_file->fd, 0, 0, POSIX_FADV_DONTNEED); file->path = (char *) stdout_file + sizeof(ds_stdout_file_t); memcpy(file->path, fullpath, pathlen); @@ -99,12 +100,11 @@ stdout_write(ds_file_t *file, const uchar *buf, size_t len) { File fd = ((ds_stdout_file_t *) file->ptr)->fd; - if (!my_write(fd, buf, len, MYF(MY_WME | MY_NABP))) { - posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); - return 0; + if (my_write(fd, buf, len, MYF(MY_WME | MY_NABP))) { + return 1; } - return 1; + return 0; } static diff --git a/extra/mariabackup/ds_tmpfile.cc b/extra/mariabackup/ds_tmpfile.cc index 6bafee2597146..2067b6d7d960a 100644 --- a/extra/mariabackup/ds_tmpfile.cc +++ b/extra/mariabackup/ds_tmpfile.cc @@ -115,6 +115,7 @@ tmpfile_open(ds_ctxt_t *ctxt, const char *path, tmp_file->orig_path = (char *) tmp_file + sizeof(ds_tmp_file_t); tmp_file->fd = fd; + posix_fadvise(tmp_file->fd, 0, 0, POSIX_FADV_DONTNEED); memcpy(tmp_file->orig_path, path, path_len); /* Store the real temporary file name in file->path */ @@ -138,12 +139,11 @@ tmpfile_write(ds_file_t *file, const uchar *buf, size_t len) { File fd = ((ds_tmp_file_t *) file->ptr)->fd; - if (!my_write(fd, buf, len, MYF(MY_WME | MY_NABP))) { - posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); - return 0; + if (my_write(fd, buf, len, MYF(MY_WME | MY_NABP))) { + return 1; } - return 1; + return 0; } static int