diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-12-14 16:19:49 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-12-14 16:20:17 +0200 |
commit | fd37344feb18af61c9c025da05049926daf9e23c (patch) | |
tree | 639c21c1393e0bd728841356981322f51bdc376e /extra | |
parent | 67e3d1ee93505e320bdb4343a8a8be827183a58e (diff) | |
parent | 5fefcb0a2136e419d194f8b7b846adb0697fb23a (diff) | |
download | mariadb-git-fd37344feb18af61c9c025da05049926daf9e23c.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/fil_cur.cc | 70 |
1 files changed, 49 insertions, 21 deletions
diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index d37c8e2f752..258317bec05 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include <trx0sys.h> #include "fil_cur.h" +#include "fil0crypt.h" #include "common.h" #include "read_filt.h" #include "xtrabackup.h" @@ -230,7 +231,7 @@ xb_fil_cur_open( posix_fadvise(cursor->file, 0, 0, POSIX_FADV_SEQUENTIAL); - const page_size_t page_size(cursor->node->space->flags); + const page_size_t page_size(node->space->flags); cursor->page_size = page_size; /* Allocate read buffer */ @@ -246,6 +247,19 @@ xb_fil_cur_open( cursor->buf_page_no = 0; cursor->thread_n = thread_n; + if (!node->space->crypt_data + && os_file_read(IORequestRead, + node->handle, cursor->buf, 0, + page_size.physical())) { + mutex_enter(&fil_system.mutex); + if (!node->space->crypt_data) { + node->space->crypt_data + = fil_space_read_crypt_data(page_size, + cursor->buf); + } + mutex_exit(&fil_system.mutex); + } + cursor->space_size = (ulint)(cursor->statinfo.st_size / page_size.physical()); @@ -267,7 +281,6 @@ xb_fil_cur_read( /*============*/ xb_fil_cur_t* cursor) /*!< in/out: source file cursor */ { - ibool success; byte* page; ulint i; ulint npages; @@ -275,6 +288,8 @@ xb_fil_cur_read( xb_fil_cur_result_t ret; ib_int64_t offset; ib_int64_t to_read; + byte tmp_frame[UNIV_PAGE_SIZE_MAX]; + byte tmp_page[UNIV_PAGE_SIZE_MAX]; const ulint page_size = cursor->page_size.physical(); xb_ad(!cursor->is_system() || page_size == srv_page_size); @@ -317,6 +332,12 @@ xb_fil_cur_read( retry_count = 10; ret = XB_FIL_CUR_SUCCESS; + fil_space_t *space = fil_space_acquire_for_io(cursor->space_id); + + if (!space) { + return XB_FIL_CUR_ERROR; + } + read_retry: xtrabackup_io_throttling(); @@ -325,19 +346,11 @@ read_retry: cursor->buf_offset = offset; cursor->buf_page_no = (ulint)(offset / cursor->page_size.physical()); - fil_space_t* space = fil_space_get(cursor->space_id); - - if (!space) { - return(XB_FIL_CUR_ERROR); - } - - success = os_file_read(IORequestRead, - cursor->file, cursor->buf, offset, - (ulint) to_read); - if (!success) { - return(XB_FIL_CUR_ERROR); + if (!os_file_read(IORequestRead, cursor->file, cursor->buf, offset, + (ulint) to_read)) { + ret = XB_FIL_CUR_ERROR; + goto func_exit; } - /* check pages for corruption and re-read if necessary. i.e. in case of partially written pages */ for (page = cursor->buf, i = 0; i < npages; @@ -348,11 +361,26 @@ read_retry: page_no >= FSP_EXTENT_SIZE && page_no < FSP_EXTENT_SIZE * 3) { /* We ignore the doublewrite buffer pages */ - } else if (!fil_space_verify_crypt_checksum( - page, cursor->page_size, space->id, page_no) - && buf_page_is_corrupted(true, page, - cursor->page_size, - space)) { + } else if (fil_space_verify_crypt_checksum( + page, cursor->page_size, + space->id, page_no)) { + ut_ad(mach_read_from_4(page + FIL_PAGE_SPACE_ID) + == space->id); + + bool decrypted = false; + + memcpy(tmp_page, page, page_size); + + if (!fil_space_decrypt(space, tmp_frame, + tmp_page, &decrypted) + || buf_page_is_corrupted(true, tmp_page, + cursor->page_size, + space)) { + goto corrupted; + } + } else if (buf_page_is_corrupted(true, page, cursor->page_size, + space)) { +corrupted: retry_count--; if (retry_count == 0) { msg("[%02u] mariabackup: " @@ -372,7 +400,6 @@ read_retry: } os_thread_sleep(100000); - goto read_retry; } cursor->buf_read += page_size; @@ -380,7 +407,8 @@ read_retry: } posix_fadvise(cursor->file, offset, to_read, POSIX_FADV_DONTNEED); - +func_exit: + space->release_for_io(); return(ret); } |