diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-11-30 08:16:37 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-11-30 08:16:37 +0200 |
commit | 7cb3520c0632ad912b309489ad86a90f9fc9bd0b (patch) | |
tree | ff8e6b8fdf5e9cacdfe914790e480bc3bad2ad85 /extra/mariabackup | |
parent | 51b30586ea999744de6a15146257f2976825781e (diff) | |
parent | 5b697c5a23ed7322b5b746b61e3ec66b510ca134 (diff) | |
download | mariadb-git-7cb3520c0632ad912b309489ad86a90f9fc9bd0b.tar.gz |
Merge bb-10.2-ext into 10.3
Diffstat (limited to 'extra/mariabackup')
-rw-r--r-- | extra/mariabackup/backup_copy.cc | 13 | ||||
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 14 | ||||
-rw-r--r-- | extra/mariabackup/changed_page_bitmap.cc | 2 | ||||
-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 | 61 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.h | 4 |
9 files changed, 58 insertions, 80 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index 0b501970efa..5c18098355f 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -252,9 +252,8 @@ datadir_iter_next_database(datadir_iter_t *it) it->dbpath = static_cast<char*>( malloc(it->dbpath_len)); } - ut_snprintf(it->dbpath, it->dbpath_len, - "%s/%s", it->datadir_path, - it->dbinfo.name); + snprintf(it->dbpath, it->dbpath_len, "%s/%s", + it->datadir_path, it->dbinfo.name); os_normalize_path(it->dbpath); if (it->dbinfo.type == OS_FILE_TYPE_FILE) { @@ -1034,8 +1033,8 @@ move_file(ds_ctxt_t *datasink, char dst_dir_abs[FN_REFLEN]; size_t dirname_length; - ut_snprintf(dst_file_path_abs, sizeof(dst_file_path_abs), - "%s/%s", dst_dir, dst_file_path); + snprintf(dst_file_path_abs, sizeof(dst_file_path_abs), + "%s/%s", dst_dir, dst_file_path); dirname_part(dst_dir_abs, dst_file_path_abs, &dirname_length); @@ -1252,8 +1251,8 @@ backup_files(const char *from, bool prep_mode) } else if (!prep_mode) { /* backup fake file into empty directory */ char path[FN_REFLEN]; - ut_snprintf(path, sizeof(path), - "%s/db.opt", node.filepath); + snprintf(path, sizeof(path), + "%s/db.opt", node.filepath); if (!(ret = backup_file_printf( trim_dotslash(path), "%s", ""))) { msg("Failed to create file %s\n", path); diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 40701682139..e8881b9604e 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -589,7 +589,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn) mysql_real_escape_string(mysql_connection, buf, opt_incremental_history_name, (unsigned long)strlen(opt_incremental_history_name)); - ut_snprintf(query, sizeof(query), + snprintf(query, sizeof(query), "SELECT innodb_to_lsn " "FROM PERCONA_SCHEMA.xtrabackup_history " "WHERE name = '%s' " @@ -602,7 +602,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn) mysql_real_escape_string(mysql_connection, buf, opt_incremental_history_uuid, (unsigned long)strlen(opt_incremental_history_uuid)); - ut_snprintf(query, sizeof(query), + snprintf(query, sizeof(query), "SELECT innodb_to_lsn " "FROM PERCONA_SCHEMA.xtrabackup_history " "WHERE uuid = '%s' " @@ -766,7 +766,7 @@ kill_long_queries(MYSQL *connection, time_t timeout) is_select_query(info))) { msg_ts("Killing query %s (duration %d sec): %s\n", id, (int)duration, info); - ut_snprintf(kill_stmt, sizeof(kill_stmt), + snprintf(kill_stmt, sizeof(kill_stmt), "KILL %s", id); xb_mysql_query(connection, kill_stmt, false, false); } @@ -1288,8 +1288,8 @@ write_current_binlog_file(MYSQL *connection) goto cleanup; } - ut_snprintf(filepath, sizeof(filepath), "%s%c%s", - log_bin_dir, FN_LIBCHAR, log_bin_file); + snprintf(filepath, sizeof(filepath), "%s%c%s", + log_bin_dir, FN_LIBCHAR, log_bin_file); result = copy_file(ds_data, filepath, log_bin_file, 0); } @@ -1574,8 +1574,8 @@ char *make_argv(char *buf, size_t len, int argc, char **argv) if (strncmp(*argv, "--password", strlen("--password")) == 0) { arg = "--password=..."; } - left-= ut_snprintf(buf + len - left, left, - "%s%c", arg, argc > 1 ? ' ' : 0); + left-= snprintf(buf + len - left, left, + "%s%c", arg, argc > 1 ? ' ' : 0); ++argv; --argc; } diff --git a/extra/mariabackup/changed_page_bitmap.cc b/extra/mariabackup/changed_page_bitmap.cc index a430a6cb0af..46bb3a7bcb5 100644 --- a/extra/mariabackup/changed_page_bitmap.cc +++ b/extra/mariabackup/changed_page_bitmap.cc @@ -441,7 +441,7 @@ log_online_open_bitmap_file_read_only( xb_ad(name[0] != '\0'); - ut_snprintf(bitmap_file->name, FN_REFLEN, "%s%s", srv_data_home, name); + snprintf(bitmap_file->name, FN_REFLEN, "%s%s", srv_data_home, name); bitmap_file->file = os_file_create_simple_no_error_handling( 0, bitmap_file->name, OS_FILE_OPEN, OS_FILE_READ_ONLY, true, &success); 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 6e6c61e74cc..627ef7a4b72 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 254ecdb740d..382a31f859f 100644 --- a/extra/mariabackup/write_filt.cc +++ b/extra/mariabackup/write_filt.cc @@ -28,6 +28,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. */ @@ -68,19 +69,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, @@ -184,8 +188,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 af00173a4de..c41fa569f06 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2135,28 +2135,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) { @@ -2683,10 +2661,10 @@ xb_load_single_table_tablespace( name = static_cast<char*>(ut_malloc_nokey(pathlen)); if (dirname != NULL) { - ut_snprintf(name, pathlen, "%s/%s", dirname, filname); + snprintf(name, pathlen, "%s/%s", dirname, filname); name[pathlen - 5] = 0; } else { - ut_snprintf(name, pathlen, "%s", filname); + snprintf(name, pathlen, "%s", filname); name[pathlen - 5] = 0; } @@ -2804,8 +2782,8 @@ static dberr_t enumerate_ibd_files(process_single_tablespace_func_t callback) dbpath = static_cast<char*>(ut_malloc_nokey(dbpath_len)); } - ut_snprintf(dbpath, dbpath_len, - "%s/%s", fil_path_to_mysql_datadir, dbinfo.name); + snprintf(dbpath, dbpath_len, + "%s/%s", fil_path_to_mysql_datadir, dbinfo.name); os_normalize_path(dbpath); if (check_if_skip_database_by_path(dbpath)) { @@ -4311,12 +4289,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; } @@ -4418,10 +4396,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 |