diff options
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/common.h | 1 | ||||
-rw-r--r-- | extra/mariabackup/crc/crc_glue.c | 2 | ||||
-rw-r--r-- | extra/mariabackup/fil_cur.cc | 19 | ||||
-rw-r--r-- | extra/mariabackup/write_filt.cc | 21 | ||||
-rw-r--r-- | extra/mariabackup/write_filt.h | 2 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 53 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.h | 4 |
7 files changed, 41 insertions, 61 deletions
diff --git a/extra/mariabackup/common.h b/extra/mariabackup/common.h index 7b1dfd7a0db..4d73742af49 100644 --- a/extra/mariabackup/common.h +++ b/extra/mariabackup/common.h @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include <mysql_version.h> #include <fcntl.h> #include <stdarg.h> +#include <my_sys.h> # define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open) diff --git a/extra/mariabackup/crc/crc_glue.c b/extra/mariabackup/crc/crc_glue.c index c301cb01e2e..11d2c21886b 100644 --- a/extra/mariabackup/crc/crc_glue.c +++ b/extra/mariabackup/crc/crc_glue.c @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include <string.h> #include <zlib.h> -#if __GNUC__ >= 4 && defined(__x86_64__) +#if defined(__GNUC__) && defined(__x86_64__) static int pclmul_enabled = 0; #endif diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index e0f0df72611..f6e6fe43085 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -212,24 +212,7 @@ xb_fil_cur_open( posix_fadvise(cursor->file, 0, 0, POSIX_FADV_SEQUENTIAL); - /* Determine the page size */ - ulint flags = xb_get_space_flags(cursor->file); - if (flags == ULINT_UNDEFINED) { - xb_fil_cur_close(cursor); - return(XB_FIL_CUR_SKIP); - } - - if (!fsp_flags_is_valid(flags, cursor->space_id)) { - ulint cflags = fsp_flags_convert_from_101(flags); - if (cflags == ULINT_UNDEFINED) { - msg("[%02u] mariabackup: Error: Invalid " - "tablespace flags: %x.\n", thread_n, uint(flags)); - return(XB_FIL_CUR_SKIP); - } - flags = cflags; - } - - const page_size_t page_size(flags); + const page_size_t page_size(cursor->node->space->flags); cursor->page_size = page_size; /* Allocate read buffer */ diff --git a/extra/mariabackup/write_filt.cc b/extra/mariabackup/write_filt.cc index f35a9accc0d..40ecef6ff79 100644 --- a/extra/mariabackup/write_filt.cc +++ b/extra/mariabackup/write_filt.cc @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "write_filt.h" #include "fil_cur.h" #include "xtrabackup.h" +#include <os0proc.h> /************************************************************************ Write-through page write filter. */ @@ -67,19 +68,22 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name, xb_fil_cur_t *cursor) { char meta_name[FN_REFLEN]; - ulint buf_size; xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt); ctxt->cursor = cursor; /* allocate buffer for incremental backup (4096 pages) */ - buf_size = (cursor->page_size.physical() / 4 + 1) - * cursor->page_size.physical(); - cp->delta_buf_base = static_cast<byte *>(malloc(buf_size)); - memset(cp->delta_buf_base, 0, buf_size); - cp->delta_buf = static_cast<byte *> - (ut_align(cp->delta_buf_base, cursor->page_size.physical())); + cp->delta_buf_size = (cursor->page_size.physical() / 4) + * cursor->page_size.physical(); + cp->delta_buf = (unsigned char *)os_mem_alloc_large(&cp->delta_buf_size); + + if (!cp->delta_buf) { + msg("[%02u] mariabackup: Error: " + "cannot allocate %zu bytes\n", + cursor->thread_n, (size_t) cp->delta_buf_size); + return (FALSE); + } /* write delta meta info */ snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name, @@ -183,8 +187,7 @@ static void wf_incremental_deinit(xb_write_filt_ctxt_t *ctxt) { xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt); - - free(cp->delta_buf_base); + os_mem_free_large(cp->delta_buf, cp->delta_buf_size); } /************************************************************************ diff --git a/extra/mariabackup/write_filt.h b/extra/mariabackup/write_filt.h index bcab263f1dd..69655db5b0b 100644 --- a/extra/mariabackup/write_filt.h +++ b/extra/mariabackup/write_filt.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA /* Incremental page filter context */ typedef struct { - byte *delta_buf_base; + ulint delta_buf_size; byte *delta_buf; ulint npages; } xb_wf_incremental_ctxt_t; diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 4c09bea28ba..c0b79f01cd5 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2137,28 +2137,6 @@ check_if_skip_table( return(FALSE); } -/** @return the tablespace flags from a given data file -@retval ULINT_UNDEFINED if the file is not readable */ -ulint xb_get_space_flags(pfs_os_file_t file) -{ - byte *buf; - byte *page; - ulint flags; - - buf = static_cast<byte *>(malloc(2 * UNIV_PAGE_SIZE)); - page = static_cast<byte *>(ut_align(buf, UNIV_PAGE_SIZE)); - - if (os_file_read(IORequestRead, file, page, 0, UNIV_PAGE_SIZE)) { - flags = fsp_header_get_flags(page); - } else { - flags = ULINT_UNDEFINED; - } - - free(buf); - - return(flags); -} - const char* xb_get_copy_action(const char *dflt) { @@ -4313,12 +4291,12 @@ xtrabackup_apply_delta( page_size = info.page_size.physical(); page_size_shift = get_bit_shift(page_size); - msg("mariabackup: page size for %s is %lu bytes\n", + msg("mariabackup: page size for %s is %zu bytes\n", src_path, page_size); if (page_size_shift < 10 || page_size_shift > UNIV_PAGE_SIZE_SHIFT_MAX) { msg("mariabackup: error: invalid value of page_size " - "(%lu bytes) read from %s\n", page_size, meta_path); + "(%zu bytes) read from %s\n", page_size, meta_path); goto error; } @@ -4420,10 +4398,29 @@ xtrabackup_apply_delta( if (off == 0) { /* Read tablespace size from page 0, and extend the file to specified size.*/ - os_offset_t n_pages = mach_read_from_4(buf + FSP_HEADER_OFFSET + FSP_SIZE); - success = os_file_set_size(dst_path, dst_file, n_pages*page_size); - if (!success) - goto error; + os_offset_t n_pages = mach_read_from_4( + buf + FSP_HEADER_OFFSET + FSP_SIZE); + if (mach_read_from_4(buf + + FIL_PAGE_SPACE_ID)) { + if (!os_file_set_size( + dst_path, dst_file, + n_pages * page_size)) + goto error; + } else if (fil_space_t* space + = fil_space_acquire(0)) { + /* The system tablespace can + consist of multiple files. The + first one has full tablespace + size in page 0, but only the last + file should be extended. */ + fil_node_t* n = UT_LIST_GET_FIRST( + space->chain); + bool fail = !strcmp(n->name, dst_path) + && !fil_space_extend( + space, (ulint)n_pages); + fil_space_release(space); + if (fail) goto error; + } } success = os_file_write(IORequestWrite, diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index 045294a2f9e..8eabf8f0e7e 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -149,10 +149,6 @@ void xtrabackup_io_throttling(void); my_bool xb_write_delta_metadata(const char *filename, const xb_delta_info_t *info); -/** @return the tablespace flags from a given data file -@retval ULINT_UNDEFINED if the file is not readable */ -ulint xb_get_space_flags(pfs_os_file_t file); - /************************************************************************ Checks if a table specified as a name in the form "database/name" (InnoDB 5.6) or "./database/name.ibd" (InnoDB 5.5-) should be skipped from backup based on |