~percona-core/percona-xtrabackup/2.0

« back to all changes in this revision

Viewing changes to xtrabackup.c

  • Committer: Alexey Kopytov
  • Date: 2011-03-13 15:52:22 UTC
  • Revision ID: akopytov@gmail.com-20110313155222-0w1022itjyatlq8w
Ported XtraBackup to MySQL 5.1.55, MySQL 5.5.9 and Percona Server 5.1.55-rel12.6
codebases.

This revision also fixes the following build- and test-related bugs:

bug #733811
bug #733820
bug #733830
bug #733842

Show diffs side-by-side

added added

removed removed

Lines of Context:
661
661
long innobase_open_files = 300L;
662
662
 
663
663
long innobase_page_size = (1 << 14); /* 16KB */
 
664
static ulong innobase_log_block_size = 512;
664
665
my_bool innobase_fast_checksum = FALSE;
665
666
my_bool innobase_extra_undoslots = FALSE;
666
667
char*   innobase_doublewrite_file = NULL;
841
842
#endif
842
843
#ifdef XTRADB_BASED
843
844
  OPT_INNODB_PAGE_SIZE,
 
845
  OPT_INNODB_LOG_BLOCK_SIZE,
844
846
  OPT_INNODB_FAST_CHECKSUM,
845
847
  OPT_INNODB_EXTRA_UNDOSLOTS,
846
848
  OPT_INNODB_DOUBLEWRITE_FILE,
1095
1097
   "The universal page size of the database.",
1096
1098
   (G_PTR*) &innobase_page_size, (G_PTR*) &innobase_page_size, 0,
1097
1099
   GET_LONG, REQUIRED_ARG, (1 << 14), (1 << 12), (1 << UNIV_PAGE_SIZE_SHIFT_MAX), 0, 1L, 0},
 
1100
  {"innodb_log_block_size", OPT_INNODB_LOG_BLOCK_SIZE,
 
1101
  "###EXPERIMENTAL###: The log block size of the transaction log file. "
 
1102
   "Changing for created log file is not supported. Use on your own risk!",
 
1103
   (G_PTR*) &innobase_log_block_size, (G_PTR*) &innobase_log_block_size, 0,
 
1104
   GET_ULONG, REQUIRED_ARG, 512, 512, 1 << UNIV_PAGE_SIZE_SHIFT_MAX, 0, 1L, 0},
1098
1105
  {"innodb_fast_checksum", OPT_INNODB_FAST_CHECKSUM,
1099
1106
   "Change the algorithm of checksum for the whole of datapage to 4-bytes word based.",
1100
1107
   (G_PTR*) &innobase_fast_checksum,
1734
1741
#endif
1735
1742
 
1736
1743
/***********************************************************************
1737
 
Computes page shift for a given page size. If the argument is not a power
 
1744
Computes bit shift for a given value. If the argument is not a power
1738
1745
of 2, returns 0.*/
1739
1746
UNIV_INLINE
1740
1747
ulint
1741
 
get_page_size_shift(ulint page_size)
 
1748
get_bit_shift(ulint value)
1742
1749
{
1743
1750
        ulint shift;
1744
1751
 
1745
 
        if (page_size == 0)
 
1752
        if (value == 0)
1746
1753
                return 0;
1747
 
        
1748
 
        for (shift = 0; !(page_size & 1UL); shift++) {
1749
 
                page_size >>= 1;
 
1754
 
 
1755
        for (shift = 0; !(value & 1UL); shift++) {
 
1756
                value >>= 1;
1750
1757
        }
1751
 
        return (page_size >> 1) ? 0 : shift;
 
1758
        return (value >> 1) ? 0 : shift;
1752
1759
}
1753
1760
 
1754
1761
my_bool
1773
1780
        srv_page_size_shift = 0;
1774
1781
 
1775
1782
        if (innobase_page_size != (1 << 14)) {
1776
 
                int n_shift = get_page_size_shift(innobase_page_size);
 
1783
                int n_shift = get_bit_shift(innobase_page_size);
1777
1784
 
1778
1785
                if (n_shift >= 12 && n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX) {
1779
1786
                        fprintf(stderr,
1795
1802
                srv_page_size = (1 << srv_page_size_shift);
1796
1803
        }
1797
1804
 
 
1805
        srv_log_block_size = 0;
 
1806
        if (innobase_log_block_size != 512) {
 
1807
                uint    n_shift = get_bit_shift(innobase_log_block_size);;
 
1808
 
 
1809
                fprintf(stderr,
 
1810
                        "InnoDB: Warning: innodb_log_block_size has "
 
1811
                        "been changed from its default value. "
 
1812
                        "(###EXPERIMENTAL### operation)\n");
 
1813
                if (n_shift > 0) {
 
1814
                        srv_log_block_size = (1 << n_shift);
 
1815
                        fprintf(stderr,
 
1816
                                "InnoDB: The log block size is set to %lu.\n",
 
1817
                                srv_log_block_size);
 
1818
                }
 
1819
        } else {
 
1820
                srv_log_block_size = 512;
 
1821
        }
 
1822
 
 
1823
        if (!srv_log_block_size) {
 
1824
                fprintf(stderr,
 
1825
                        "InnoDB: Error: %lu is not valid value for "
 
1826
                        "innodb_log_block_size.\n", innobase_log_block_size);
 
1827
                goto error;
 
1828
        }
 
1829
 
1798
1830
        srv_fast_checksum = (ibool) innobase_fast_checksum;
1799
1831
#endif
1800
1832
 
2431
2463
                goto skip;
2432
2464
        } else if (zip_size) {
2433
2465
                page_size = zip_size;
2434
 
                page_size_shift = get_page_size_shift(page_size);
 
2466
                page_size_shift = get_bit_shift(page_size);
2435
2467
                fprintf(stderr, "[%02u] %s is compressed with page size = "
2436
2468
                        "%lu bytes\n", thread_n, node->name, page_size);
2437
2469
                if (page_size_shift < 10 || page_size_shift > 14) {
4297
4329
 
4298
4330
                        if (dict_table_get_first_index(table)) {
4299
4331
#ifdef XTRADB_BASED
4300
 
                                dict_update_statistics_low(table, TRUE, FALSE);
4301
 
#elif MYSQL_VERSION_ID >= 50508
 
4332
                                dict_update_statistics(table, TRUE, FALSE);
 
4333
#elif defined(INNODB_VERSION_SHORT)
4302
4334
                                dict_update_statistics(table, TRUE);
4303
4335
#else
4304
4336
                                dict_update_statistics_low(table, TRUE);
4791
4823
        }
4792
4824
 
4793
4825
        page_size = info.page_size;
4794
 
        page_size_shift = get_page_size_shift(page_size);
 
4826
        page_size_shift = get_bit_shift(page_size);
4795
4827
        fprintf(stderr, "xtrabackup: page size for %s is %lu bytes\n",
4796
4828
                src_path, page_size);
4797
4829
        if (page_size_shift < 10 ||
5768
5800
        /* temporary setting of enough size */
5769
5801
        srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX;
5770
5802
        srv_page_size = UNIV_PAGE_SIZE_MAX;
 
5803
        srv_log_block_size = 512;
5771
5804
#endif
5772
5805
        if (xtrabackup_backup && xtrabackup_incremental) {
5773
5806
                /* direct specification is only for --backup */