diff options
-rw-r--r-- | mysql-test/suite/innodb/r/innodb-page_compression_snappy.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/innodb-page_encryption_log_encryption.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/innodb-page_compression_snappy.test | 2 | ||||
-rw-r--r-- | storage/innobase/fil/fil0crypt.cc | 58 | ||||
-rw-r--r-- | storage/innobase/fil/fil0pagecompress.cc | 172 | ||||
-rw-r--r-- | storage/innobase/log/log0crypt.cc | 61 | ||||
-rw-r--r-- | storage/xtradb/fil/fil0crypt.cc | 58 | ||||
-rw-r--r-- | storage/xtradb/fil/fil0pagecompress.cc | 173 | ||||
-rw-r--r-- | storage/xtradb/log/log0crypt.cc | 61 |
9 files changed, 331 insertions, 258 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result b/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result index 1709d8e9d2b..a0b2f947fd3 100644 --- a/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result +++ b/mysql-test/suite/innodb/r/innodb-page_compression_snappy.result @@ -1,4 +1,4 @@ -call mtr.add_suppression("InnoDB: Warning: Compression failed for space*"); +call mtr.add_suppression("Compression failed for space*"); set global innodb_file_format = `barracuda`; set global innodb_file_per_table = on; set global innodb_compression_algorithm = 6; diff --git a/mysql-test/suite/innodb/r/innodb-page_encryption_log_encryption.result b/mysql-test/suite/innodb/r/innodb-page_encryption_log_encryption.result index 62f07778d5a..03a8c658225 100644 --- a/mysql-test/suite/innodb/r/innodb-page_encryption_log_encryption.result +++ b/mysql-test/suite/innodb/r/innodb-page_encryption_log_encryption.result @@ -1,5 +1,7 @@ call mtr.add_suppression("KeyID 0 not found or with error. Check the key and the log file*"); call mtr.add_suppression("Disabling redo log encryption"); +call mtr.add_suppression("InnoDB: [Warning] Disabling redo log encryption"); +call mtr.add_suppression("InnoDB:*"); SET GLOBAL innodb_file_format = `Barracuda`; SET GLOBAL innodb_file_per_table = ON; create table innodb_normal(c1 bigint not null, b char(200)) engine=innodb; diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test b/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test index 8c4980ff479..929f547b6ac 100644 --- a/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test +++ b/mysql-test/suite/innodb/t/innodb-page_compression_snappy.test @@ -1,7 +1,7 @@ -- source include/have_innodb.inc -- source include/have_innodb_snappy.inc -call mtr.add_suppression("InnoDB: Warning: Compression failed for space*"); +call mtr.add_suppression("Compression failed for space*"); --disable_query_log let $innodb_compression_algorithm_orig=`select @@innodb_compression_algorithm`; diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index d7b26eed49f..823c74aa88c 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1,3 +1,29 @@ +/***************************************************************************** + +Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. +Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*****************************************************************************/ +/**************************************************//** +@file fil0crypt.cc +Innodb file space encrypt/decrypt + +Created Jonas Oreland Google +Modified Jan Lindström jan.lindstrom@mariadb.com +*******************************************************/ + #include "fil0fil.h" #include "srv0srv.h" #include "srv0start.h" @@ -11,6 +37,7 @@ #include "fsp0fsp.h" #include "fil0pagecompress.h" #include "fil0pageencryption.h" +#include "ha_prototypes.h" // IB_LOG_ #include <my_crypt.h> @@ -368,11 +395,11 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset) } if (memcmp(page + offset, CRYPT_MAGIC, MAGIC_SZ) != 0) { - fprintf(stderr, - "Warning: found potentially bogus bytes on " + ib_logf(IB_LOG_LEVEL_WARN, + "Found potentially bogus bytes on " "page 0 offset %lu for space %lu : " "[ %.2x %.2x %.2x %.2x %.2x %.2x ]. " - "Assuming space is not encrypted!\n", + "Assuming space is not encrypted!.", offset, space, page[offset + 0], page[offset + 1], @@ -387,10 +414,10 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset) if (! (type == CRYPT_SCHEME_UNENCRYPTED || type == CRYPT_SCHEME_1)) { - fprintf(stderr, + ib_logf(IB_LOG_LEVEL_ERROR, "Found non sensible crypt scheme: %lu for space %lu " " offset: %lu bytes: " - "[ %.2x %.2x %.2x %.2x %.2x %.2x ]\n", + "[ %.2x %.2x %.2x %.2x %.2x %.2x ].", type, space, offset, page[offset + 0 + MAGIC_SZ], page[offset + 1 + MAGIC_SZ], @@ -403,10 +430,10 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset) ulint iv_length = mach_read_from_1(page + offset + MAGIC_SZ + 1); if (! (iv_length == CRYPT_SCHEME_1_IV_LEN)) { - fprintf(stderr, + ib_logf(IB_LOG_LEVEL_ERROR, "Found non sensible iv length: %lu for space %lu " " offset: %lu type: %lu bytes: " - "[ %.2x %.2x %.2x %.2x %.2x %.2x ]\n", + "[ %.2x %.2x %.2x %.2x %.2x %.2x ].", iv_length, space, offset, type, page[offset + 0 + MAGIC_SZ], page[offset + 1 + MAGIC_SZ], @@ -1414,8 +1441,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state) state->sum_waited_us / state->cnt_waited; #if DEBUG_KEYROTATION_THROTTLING - fprintf(stderr, - "thr_no: %u - update estimated_max_iops from %u to %u\n", + ib_logf(IB_LOG_LEVEL_INFO, + "thr_no: %u - update estimated_max_iops from %u to %u.", state->thread_no, state->estimated_max_iops, 1000000 / avg_wait_time_us); @@ -1428,8 +1455,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state) state->sum_waited_us = 0; } else { #if DEBUG_KEYROTATION_THROTTLING - fprintf(stderr, - "thr_no: %u only waited %lu%% skip re-estimate\n", + ib_logf(IB_LOG_LEVEL_INFO, + "thr_no: %u only waited %lu%% skip re-estimate.", state->thread_no, (100 * state->cnt_waited) / state->batch); #endif @@ -1477,8 +1504,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state) n_fil_crypt_iops_allocated += extra; state->allocated_iops += extra; #if DEBUG_KEYROTATION_THROTTLING - fprintf(stderr, - "thr_no: %u increased iops from %u to %u\n", + ib_logf(IB_LOG_LEVEL_INFO, + "thr_no: %u increased iops from %u to %u.", state->thread_no, state->allocated_iops - extra, state->allocated_iops); @@ -2325,9 +2352,8 @@ fil_space_crypt_close_tablespace( uint now = time(0); if (now >= last + 30) { - fprintf(stderr, - "WARNING: " - "waited %u seconds to drop space: %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Waited %u seconds to drop space: %lu.", now - start, space); last = now; } diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index 80a71d23c9b..caed038b4ee 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -47,6 +47,7 @@ Updated 14/02/2015 #include "page0zip.h" #include "trx0sys.h" #include "row0mysql.h" +#include "ha_prototypes.h" // IB_LOG_ #ifndef UNIV_HOTBACKUP # include "buf0lru.h" # include "ibuf0ibuf.h" @@ -117,9 +118,9 @@ fil_decompress_page_2( if (original_len < UNIV_PAGE_SIZE_MIN - (FIL_PAGE_DATA + 8) || original_len > UNIV_PAGE_SIZE_MAX - FIL_PAGE_DATA || len < original_len + FIL_PAGE_DATA) { - fprintf(stderr, - "InnoDB: Corruption: We try to uncompress corrupted page\n" - "InnoDB: Original len %lu len %lu.\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: We try to uncompress corrupted page. " + "Original len %lu len %lu.", original_len, len); fflush(stderr); @@ -132,16 +133,15 @@ fil_decompress_page_2( switch(algorithm) { case PAGE_ZLIB_ALGORITHM: { - fprintf(stderr, "InnoDB: [Note]: zlib\n"); - err = uncompress(page_buf, &len, ptr, original_len); + /* If uncompress fails it means that page is corrupted */ if (err != Z_OK) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but uncompress failed with error %d.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed " + "but uncompress failed with error %d " + " size %lu len %lu.", err, original_len, len); fflush(stderr); @@ -153,15 +153,15 @@ fil_decompress_page_2( } #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: { - fprintf(stderr, "InnoDB: [Note]: lz4\n"); + err = LZ4_decompress_fast( (const char*) ptr, (char*) (page_buf), original_len); if (err < 0) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %d bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %d bytes" + " size %lu len %lu.", err, original_len, len); fflush(stderr); @@ -179,7 +179,6 @@ fil_decompress_page_2( size_t dst_pos = 0; uint64_t memlimit = UINT64_MAX; - fprintf(stderr, "InnoDB: [Note]: lzma\n"); ret = lzma_stream_buffer_decode( &memlimit, 0, @@ -193,10 +192,10 @@ fil_decompress_page_2( if (ret != LZMA_OK || (dst_pos <= 0 || dst_pos > len)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", dst_pos, original_len, len); fflush(stderr); @@ -210,15 +209,15 @@ fil_decompress_page_2( #ifdef HAVE_LZO case PAGE_LZO_ALGORITHM: { ulint olen = 0; - fprintf(stderr, "InnoDB: [Note]: lzo \n"); + err = lzo1x_decompress((const unsigned char *)ptr, original_len,(unsigned char *)(page_buf), &olen, NULL); if (err != LZO_E_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", olen, original_len, len); fflush(stderr); @@ -229,10 +228,10 @@ fil_decompress_page_2( #endif /* HAVE_LZO */ default: - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but compression algorithm %s\n" - "InnoDB: is not known.\n" + ib_logf(IB_LOG_LEVEL_ERROR, + " Corruption: Page is marked as compressed " + " but compression algorithm %s" + " is not known." ,fil_get_compression_alg_name(algorithm)); fflush(stderr); @@ -296,8 +295,6 @@ fil_compress_page( return (buf); } - fprintf(stderr, "JAN: orig_page_type %lu\n", orig_page_type); - level = compression_level; ut_ad(fil_space_is_page_compressed(space_id)); @@ -312,8 +309,8 @@ fil_compress_page( } #ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Preparing for compress for space %lu name %s len %lu\n", + ib_logf(IB_LOG_LEVEL_INFO, + "Preparing for compress for space %lu name %s len %lu.", space_id, fil_space_name(space), len); #endif /* UNIV_PAGECOMPRESS_DEBUG */ @@ -330,8 +327,8 @@ fil_compress_page( /* If error we leave the actual page as it was */ if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu rt %d write %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu rt %d write %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -349,8 +346,8 @@ fil_compress_page( if (err != LZO_E_OK || write_size > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -377,8 +374,8 @@ fil_compress_page( if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu", space_id, fil_space_name(space), len, err, out_pos); space->printed_compression_failure = true; } @@ -408,8 +405,8 @@ fil_compress_page( if (err != BZ_OK || write_size > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -430,8 +427,8 @@ fil_compress_page( if (cstatus != SNAPPY_OK || write_size > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu.", space_id, fil_space_name(space), len, (int)cstatus, write_size); space->printed_compression_failure = true; } @@ -450,8 +447,8 @@ fil_compress_page( /* If error we leave the actual page as it was */ if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu rt %d write %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu rt %d write %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -525,8 +522,8 @@ fil_compress_page( } #ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Compression succeeded for space %lu name %s len %lu out_len %lu\n", + ib_logf(IB_LOG_LEVEL_INFO, + "Compression succeeded for space %lu name %s len %lu out_len %lu.", space_id, fil_space_name(space), len, write_size); #endif /* UNIV_PAGECOMPRESS_DEBUG */ @@ -577,10 +574,6 @@ fil_decompress_page( // If no buffer was given, we need to allocate temporal buffer if (page_buf == NULL) { -#ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: FIL: Compression buffer not given, allocating...\n"); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ in_buf = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*3)); } else { in_buf = page_buf; @@ -600,10 +593,9 @@ fil_decompress_page( if (mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM) != BUF_NO_CHECKSUM_MAGIC || mach_read_from_2(buf+FIL_PAGE_TYPE) != FIL_PAGE_PAGE_COMPRESSED) { - fprintf(stderr, - "InnoDB: Corruption: We try to uncompress corrupted page\n" - "InnoDB: CRC %lu type %lu.\n" - "InnoDB: len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: We try to uncompress corrupted page" + " CRC %lu type %lu len %lu.", mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM), mach_read_from_2(buf+FIL_PAGE_TYPE), len); @@ -618,9 +610,9 @@ fil_decompress_page( actual_size = mach_read_from_2(buf+FIL_PAGE_DATA); /* Check if payload size is corrupted */ if (actual_size == 0 || actual_size > UNIV_PAGE_SIZE) { - fprintf(stderr, - "InnoDB: Corruption: We try to uncompress corrupted page\n" - "InnoDB: actual size %lu compression %s\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: We try to uncompress corrupted page" + " actual size %lu compression %s.", actual_size, fil_get_compression_alg_name(compression_alg)); fflush(stderr); ut_error; @@ -633,8 +625,8 @@ fil_decompress_page( } #ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Preparing for decompress for len %lu\n", + ib_logf(IB_LOG_LEVEL_INFO, + "Preparing for decompress for len %lu\n", actual_size); #endif /* UNIV_PAGECOMPRESS_DEBUG */ @@ -646,10 +638,10 @@ fil_decompress_page( /* If uncompress fails it means that page is corrupted */ if (err != Z_OK) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but uncompress failed with error %d.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but uncompress failed with error %d " + " size %lu len %lu.", err, actual_size, len); fflush(stderr); @@ -663,10 +655,10 @@ fil_decompress_page( err = LZ4_decompress_fast((const char *)buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (char *)in_buf, len); if (err != (int)actual_size) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %d bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %d bytes " + " size %lu len %lu.", err, actual_size, len); fflush(stderr); @@ -682,10 +674,10 @@ fil_decompress_page( actual_size,(unsigned char *)in_buf, &olen, NULL); if (err != LZO_E_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", olen, actual_size, len); fflush(stderr); @@ -715,10 +707,10 @@ fil_decompress_page( if (ret != LZMA_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", dst_pos, actual_size, len); fflush(stderr); @@ -741,10 +733,10 @@ fil_decompress_page( 0); if (err != BZ_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %du bytes.\n" - "InnoDB: size %lu len %lu err %d\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %du bytes" + " size %lu len %lu err %d.", dst_pos, actual_size, len, err); fflush(stderr); @@ -766,10 +758,10 @@ fil_decompress_page( &olen); if (cstatus != SNAPPY_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %lu bytes.\n" - "InnoDB: size %lu len %lu err %d\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %lu bytes" + " size %lu len %lu err %d.", olen, actual_size, len, (int)cstatus); fflush(stderr); @@ -779,10 +771,10 @@ fil_decompress_page( } #endif /* HAVE_SNAPPY */ default: - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but compression algorithm %s\n" - "InnoDB: is not known.\n" + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but compression algorithm %s" + " is not known." ,fil_get_compression_alg_name(compression_alg)); fflush(stderr); @@ -790,12 +782,6 @@ fil_decompress_page( break; } -#ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Decompression succeeded for len %lu \n", - len); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ - srv_stats.pages_page_decompressed.inc(); /* Copy the uncompressed page to the buffer pool, not diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc index 3d4be2e7792..fa07ad933a8 100644 --- a/storage/innobase/log/log0crypt.cc +++ b/storage/innobase/log/log0crypt.cc @@ -1,8 +1,27 @@ +/***************************************************************************** + +Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. +Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*****************************************************************************/ /**************************************************//** @file log0crypt.cc Innodb log encrypt/decrypt -Created 11/25/2013 Minli Zhu +Created 11/25/2013 Minli Zhu Google +Modified Jan Lindström jan.lindstrom@mariadb.com *******************************************************/ #include "m_string.h" #include "log0crypt.h" @@ -13,6 +32,7 @@ Created 11/25/2013 Minli Zhu #include "log0recv.h" // for recv_sys #include "mysql/plugin_encryption_key_management.h" // for BAD_ENCRYPTION_KEY_VERSION +#include "ha_prototypes.h" // IB_LOG_ /* If true, enable redo log encryption. */ UNIV_INTERN my_bool srv_encrypt_log = FALSE; @@ -51,18 +71,18 @@ log_init_crypt_msg_and_nonce(void) mach_write_to_1(redo_log_crypt_msg, redo_log_purpose_byte); if (my_random_bytes(redo_log_crypt_msg + 1, PURPOSE_BYTE_LEN) != AES_OK) { - fprintf(stderr, - "\nInnoDB redo log crypto: generate " - "%u-byte random number as crypto msg failed.\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: generate " + "%u-byte random number as crypto msg failed.", PURPOSE_BYTE_LEN); abort(); } if (my_random_bytes(aes_ctr_nonce, MY_AES_BLOCK_SIZE) != AES_OK) { - fprintf(stderr, - "\nInnoDB redo log crypto: generate " - "%u-byte random number as AES_CTR nonce failed.\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: generate " + "%u-byte random number as AES_CTR nonce failed.", MY_AES_BLOCK_SIZE); abort(); } @@ -80,16 +100,17 @@ log_init_crypt_key( { if (crypt_ver == UNENCRYPTED_KEY_VER) { - fprintf(stderr, "\nInnoDB redo log crypto: unencrypted key ver.\n\n"); + ib_logf(IB_LOG_LEVEL_INFO, + "Redo log crypto: unencrypted key ver."); memset(key, 0, MY_AES_BLOCK_SIZE); return; } if (crypt_msg[PURPOSE_BYTE_OFFSET] != redo_log_purpose_byte) { - fprintf(stderr, - "\nInnoDB redo log crypto: msg type mismatched. " - "Expected: %x; Actual: %x\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: msg type mismatched. " + "Expected: %x; Actual: %x.", redo_log_purpose_byte, crypt_msg[PURPOSE_BYTE_OFFSET]); abort(); } @@ -97,9 +118,9 @@ log_init_crypt_key( byte mysqld_key[MY_AES_BLOCK_SIZE] = {0}; if (get_encryption_key(crypt_ver, mysqld_key, MY_AES_BLOCK_SIZE)) { - fprintf(stderr, - "\nInnoDB redo log crypto: getting mysqld crypto key " - "from key version failed.\n"); + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: getting mysqld crypto key " + "from key version failed."); abort(); } @@ -113,9 +134,9 @@ log_init_crypt_key( if (rc != AES_OK || dst_len != MY_AES_BLOCK_SIZE) { - fprintf(stderr, - "\nInnoDB redo log crypto: getting redo log crypto key " - "failed.\n"); + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: getting redo log crypto key " + "failed."); abort(); } } @@ -247,9 +268,11 @@ log_crypt_set_ver_and_key( vkey == (unsigned int)CRYPT_KEY_UNKNOWN) { encrypted = false; - fprintf(stderr, "\nInnoDB redo log crypto: Can't initialize to key version %du\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Redo log crypto: Can't initialize to key version %du.", key_ver); - fprintf(stderr, "InnoDB: [Warning] Disabling redo log encryption\n"); + ib_logf(IB_LOG_LEVEL_WARN, + "Disabling redo log encryption."); srv_encrypt_log = FALSE; } else { key_ver = vkey; diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc index d7b26eed49f..823c74aa88c 100644 --- a/storage/xtradb/fil/fil0crypt.cc +++ b/storage/xtradb/fil/fil0crypt.cc @@ -1,3 +1,29 @@ +/***************************************************************************** + +Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. +Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*****************************************************************************/ +/**************************************************//** +@file fil0crypt.cc +Innodb file space encrypt/decrypt + +Created Jonas Oreland Google +Modified Jan Lindström jan.lindstrom@mariadb.com +*******************************************************/ + #include "fil0fil.h" #include "srv0srv.h" #include "srv0start.h" @@ -11,6 +37,7 @@ #include "fsp0fsp.h" #include "fil0pagecompress.h" #include "fil0pageencryption.h" +#include "ha_prototypes.h" // IB_LOG_ #include <my_crypt.h> @@ -368,11 +395,11 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset) } if (memcmp(page + offset, CRYPT_MAGIC, MAGIC_SZ) != 0) { - fprintf(stderr, - "Warning: found potentially bogus bytes on " + ib_logf(IB_LOG_LEVEL_WARN, + "Found potentially bogus bytes on " "page 0 offset %lu for space %lu : " "[ %.2x %.2x %.2x %.2x %.2x %.2x ]. " - "Assuming space is not encrypted!\n", + "Assuming space is not encrypted!.", offset, space, page[offset + 0], page[offset + 1], @@ -387,10 +414,10 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset) if (! (type == CRYPT_SCHEME_UNENCRYPTED || type == CRYPT_SCHEME_1)) { - fprintf(stderr, + ib_logf(IB_LOG_LEVEL_ERROR, "Found non sensible crypt scheme: %lu for space %lu " " offset: %lu bytes: " - "[ %.2x %.2x %.2x %.2x %.2x %.2x ]\n", + "[ %.2x %.2x %.2x %.2x %.2x %.2x ].", type, space, offset, page[offset + 0 + MAGIC_SZ], page[offset + 1 + MAGIC_SZ], @@ -403,10 +430,10 @@ fil_space_read_crypt_data(ulint space, const byte* page, ulint offset) ulint iv_length = mach_read_from_1(page + offset + MAGIC_SZ + 1); if (! (iv_length == CRYPT_SCHEME_1_IV_LEN)) { - fprintf(stderr, + ib_logf(IB_LOG_LEVEL_ERROR, "Found non sensible iv length: %lu for space %lu " " offset: %lu type: %lu bytes: " - "[ %.2x %.2x %.2x %.2x %.2x %.2x ]\n", + "[ %.2x %.2x %.2x %.2x %.2x %.2x ].", iv_length, space, offset, type, page[offset + 0 + MAGIC_SZ], page[offset + 1 + MAGIC_SZ], @@ -1414,8 +1441,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state) state->sum_waited_us / state->cnt_waited; #if DEBUG_KEYROTATION_THROTTLING - fprintf(stderr, - "thr_no: %u - update estimated_max_iops from %u to %u\n", + ib_logf(IB_LOG_LEVEL_INFO, + "thr_no: %u - update estimated_max_iops from %u to %u.", state->thread_no, state->estimated_max_iops, 1000000 / avg_wait_time_us); @@ -1428,8 +1455,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state) state->sum_waited_us = 0; } else { #if DEBUG_KEYROTATION_THROTTLING - fprintf(stderr, - "thr_no: %u only waited %lu%% skip re-estimate\n", + ib_logf(IB_LOG_LEVEL_INFO, + "thr_no: %u only waited %lu%% skip re-estimate.", state->thread_no, (100 * state->cnt_waited) / state->batch); #endif @@ -1477,8 +1504,8 @@ fil_crypt_realloc_iops(rotate_thread_t *state) n_fil_crypt_iops_allocated += extra; state->allocated_iops += extra; #if DEBUG_KEYROTATION_THROTTLING - fprintf(stderr, - "thr_no: %u increased iops from %u to %u\n", + ib_logf(IB_LOG_LEVEL_INFO, + "thr_no: %u increased iops from %u to %u.", state->thread_no, state->allocated_iops - extra, state->allocated_iops); @@ -2325,9 +2352,8 @@ fil_space_crypt_close_tablespace( uint now = time(0); if (now >= last + 30) { - fprintf(stderr, - "WARNING: " - "waited %u seconds to drop space: %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Waited %u seconds to drop space: %lu.", now - start, space); last = now; } diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index a48fcf0f71a..3c2edd832c4 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -47,6 +47,7 @@ Updated 14/02/2015 #include "page0zip.h" #include "trx0sys.h" #include "row0mysql.h" +#include "ha_prototypes.h" // IB_LOG_ #ifndef UNIV_HOTBACKUP # include "buf0lru.h" # include "ibuf0ibuf.h" @@ -117,9 +118,9 @@ fil_decompress_page_2( if (original_len < UNIV_PAGE_SIZE_MIN - (FIL_PAGE_DATA + 8) || original_len > UNIV_PAGE_SIZE_MAX - FIL_PAGE_DATA || len < original_len + FIL_PAGE_DATA) { - fprintf(stderr, - "InnoDB: Corruption: We try to uncompress corrupted page\n" - "InnoDB: Original len %lu len %lu.\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: We try to uncompress corrupted page. " + "Original len %lu len %lu.", original_len, len); fflush(stderr); @@ -132,16 +133,15 @@ fil_decompress_page_2( switch(algorithm) { case PAGE_ZLIB_ALGORITHM: { - fprintf(stderr, "InnoDB: [Note]: zlib\n"); - err = uncompress(page_buf, &len, ptr, original_len); + /* If uncompress fails it means that page is corrupted */ if (err != Z_OK) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but uncompress failed with error %d.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed " + "but uncompress failed with error %d " + " size %lu len %lu.", err, original_len, len); fflush(stderr); @@ -153,15 +153,15 @@ fil_decompress_page_2( } #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: { - fprintf(stderr, "InnoDB: [Note]: lz4\n"); + err = LZ4_decompress_fast( (const char*) ptr, (char*) (page_buf), original_len); if (err < 0) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %d bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %d bytes" + " size %lu len %lu.", err, original_len, len); fflush(stderr); @@ -179,7 +179,6 @@ fil_decompress_page_2( size_t dst_pos = 0; uint64_t memlimit = UINT64_MAX; - fprintf(stderr, "InnoDB: [Note]: lzma\n"); ret = lzma_stream_buffer_decode( &memlimit, 0, @@ -193,10 +192,10 @@ fil_decompress_page_2( if (ret != LZMA_OK || (dst_pos <= 0 || dst_pos > len)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", dst_pos, original_len, len); fflush(stderr); @@ -210,16 +209,17 @@ fil_decompress_page_2( #ifdef HAVE_LZO case PAGE_LZO_ALGORITHM: { ulint olen = 0; - fprintf(stderr, "InnoDB: [Note]: lzo \n"); + err = lzo1x_decompress((const unsigned char *)ptr, original_len,(unsigned char *)(page_buf), &olen, NULL); if (err != LZO_E_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", olen, original_len, len); + fflush(stderr); ut_error; @@ -229,10 +229,10 @@ fil_decompress_page_2( #endif /* HAVE_LZO */ default: - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but compression algorithm %s\n" - "InnoDB: is not known.\n" + ib_logf(IB_LOG_LEVEL_ERROR, + " Corruption: Page is marked as compressed " + " but compression algorithm %s" + " is not known." ,fil_get_compression_alg_name(algorithm)); fflush(stderr); @@ -296,8 +296,6 @@ fil_compress_page( return (buf); } - fprintf(stderr, "JAN: orig_page_type %lu\n", orig_page_type); - level = compression_level; ut_ad(fil_space_is_page_compressed(space_id)); @@ -312,8 +310,8 @@ fil_compress_page( } #ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Preparing for compress for space %lu name %s len %lu\n", + ib_logf(IB_LOG_LEVEL_INFO, + "Preparing for compress for space %lu name %s len %lu.", space_id, fil_space_name(space), len); #endif /* UNIV_PAGECOMPRESS_DEBUG */ @@ -330,8 +328,8 @@ fil_compress_page( /* If error we leave the actual page as it was */ if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu rt %d write %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu rt %d write %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -349,8 +347,8 @@ fil_compress_page( if (err != LZO_E_OK || write_size > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -377,8 +375,8 @@ fil_compress_page( if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu", space_id, fil_space_name(space), len, err, out_pos); space->printed_compression_failure = true; } @@ -407,8 +405,8 @@ fil_compress_page( if (err != BZ_OK || write_size > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -429,8 +427,8 @@ fil_compress_page( if (cstatus != SNAPPY_OK || write_size > UNIV_PAGE_SIZE-header_len) { if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu err %d write_size %lu.", space_id, fil_space_name(space), len, (int)cstatus, write_size); space->printed_compression_failure = true; } @@ -449,8 +447,8 @@ fil_compress_page( /* If error we leave the actual page as it was */ if (space->printed_compression_failure == false) { - fprintf(stderr, - "InnoDB: Warning: Compression failed for space %lu name %s len %lu rt %d write %lu\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Compression failed for space %lu name %s len %lu rt %d write %lu.", space_id, fil_space_name(space), len, err, write_size); space->printed_compression_failure = true; } @@ -523,8 +521,8 @@ fil_compress_page( } #ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Compression succeeded for space %lu name %s len %lu out_len %lu\n", + ib_logf(IB_LOG_LEVEL_INFO, + "Compression succeeded for space %lu name %s len %lu out_len %lu.", space_id, fil_space_name(space), len, write_size); #endif /* UNIV_PAGECOMPRESS_DEBUG */ @@ -574,10 +572,6 @@ fil_decompress_page( // If no buffer was given, we need to allocate temporal buffer if (page_buf == NULL) { -#ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: FIL: Compression buffer not given, allocating...\n"); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ in_buf = static_cast<byte *>(ut_malloc(UNIV_PAGE_SIZE*3)); } else { in_buf = page_buf; @@ -597,10 +591,9 @@ fil_decompress_page( if (mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM) != BUF_NO_CHECKSUM_MAGIC || mach_read_from_2(buf+FIL_PAGE_TYPE) != FIL_PAGE_PAGE_COMPRESSED) { - fprintf(stderr, - "InnoDB: Corruption: We try to uncompress corrupted page\n" - "InnoDB: CRC %lu type %lu.\n" - "InnoDB: len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: We try to uncompress corrupted page" + " CRC %lu type %lu len %lu.", mach_read_from_4(buf+FIL_PAGE_SPACE_OR_CHKSUM), mach_read_from_2(buf+FIL_PAGE_TYPE), len); @@ -615,9 +608,9 @@ fil_decompress_page( actual_size = mach_read_from_2(buf+FIL_PAGE_DATA); /* Check if payload size is corrupted */ if (actual_size == 0 || actual_size > UNIV_PAGE_SIZE) { - fprintf(stderr, - "InnoDB: Corruption: We try to uncompress corrupted page\n" - "InnoDB: actual size %lu compression %s\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: We try to uncompress corrupted page" + " actual size %lu compression %s.", actual_size, fil_get_compression_alg_name(compression_alg)); fflush(stderr); ut_error; @@ -630,8 +623,8 @@ fil_decompress_page( } #ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Preparing for decompress for len %lu\n", + ib_logf(IB_LOG_LEVEL_INFO, + "Preparing for decompress for len %lu\n", actual_size); #endif /* UNIV_PAGECOMPRESS_DEBUG */ @@ -643,10 +636,10 @@ fil_decompress_page( /* If uncompress fails it means that page is corrupted */ if (err != Z_OK) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but uncompress failed with error %d.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but uncompress failed with error %d " + " size %lu len %lu.", err, actual_size, len); fflush(stderr); @@ -660,10 +653,10 @@ fil_decompress_page( err = LZ4_decompress_fast((const char *)buf+FIL_PAGE_DATA+FIL_PAGE_COMPRESSED_SIZE, (char *)in_buf, len); if (err != (int)actual_size) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %d bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %d bytes " + " size %lu len %lu.", err, actual_size, len); fflush(stderr); @@ -678,10 +671,10 @@ fil_decompress_page( actual_size,(unsigned char *)in_buf, &olen, NULL); if (err != LZO_E_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", olen, actual_size, len); fflush(stderr); @@ -711,10 +704,10 @@ fil_decompress_page( if (ret != LZMA_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %ld bytes.\n" - "InnoDB: size %lu len %lu\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %ld bytes" + " size %lu len %lu.", dst_pos, actual_size, len); fflush(stderr); @@ -737,10 +730,10 @@ fil_decompress_page( 0); if (err != BZ_OK || (dst_pos == 0 || dst_pos > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %du bytes.\n" - "InnoDB: size %lu len %lu err %d\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %du bytes" + " size %lu len %lu err %d.", dst_pos, actual_size, len, err); fflush(stderr); @@ -762,10 +755,10 @@ fil_decompress_page( &olen); if (cstatus != SNAPPY_OK || (olen == 0 || olen > UNIV_PAGE_SIZE)) { - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but decompression read only %lu bytes.\n" - "InnoDB: size %lu len %lu err %d\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but decompression read only %lu bytes" + " size %lu len %lu err %d.", olen, actual_size, len, (int)cstatus); fflush(stderr); @@ -775,10 +768,10 @@ fil_decompress_page( } #endif /* HAVE_SNAPPY */ default: - fprintf(stderr, - "InnoDB: Corruption: Page is marked as compressed\n" - "InnoDB: but compression algorithm %s\n" - "InnoDB: is not known.\n" + ib_logf(IB_LOG_LEVEL_ERROR, + "Corruption: Page is marked as compressed" + " but compression algorithm %s" + " is not known." ,fil_get_compression_alg_name(compression_alg)); fflush(stderr); @@ -786,12 +779,6 @@ fil_decompress_page( break; } -#ifdef UNIV_PAGECOMPRESS_DEBUG - fprintf(stderr, - "InnoDB: Note: Decompression succeeded for len %lu \n", - len); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ - srv_stats.pages_page_decompressed.inc(); /* Copy the uncompressed page to the buffer pool, not diff --git a/storage/xtradb/log/log0crypt.cc b/storage/xtradb/log/log0crypt.cc index be2f77ebc72..6f1b4163dd7 100644 --- a/storage/xtradb/log/log0crypt.cc +++ b/storage/xtradb/log/log0crypt.cc @@ -1,8 +1,27 @@ +/***************************************************************************** + +Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. +Copyright (C) 2014, 2015, MariaDB Corporation. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*****************************************************************************/ /**************************************************//** @file log0crypt.cc Innodb log encrypt/decrypt -Created 11/25/2013 Minli Zhu +Created 11/25/2013 Minli Zhu Google +Modified Jan Lindström jan.lindstrom@mariadb.com *******************************************************/ #include "m_string.h" #include "log0crypt.h" @@ -14,6 +33,7 @@ Created 11/25/2013 Minli Zhu #include "log0recv.h" // for recv_sys #include "mysql/plugin_encryption_key_management.h" // for BAD_ENCRYPTION_KEY_VERSION +#include "ha_prototypes.h" // IB_LOG_ /* If true, enable redo log encryption. */ UNIV_INTERN my_bool srv_encrypt_log = FALSE; @@ -52,18 +72,18 @@ log_init_crypt_msg_and_nonce(void) mach_write_to_1(redo_log_crypt_msg, redo_log_purpose_byte); if (my_random_bytes(redo_log_crypt_msg + 1, PURPOSE_BYTE_LEN) != AES_OK) { - fprintf(stderr, - "\nInnoDB redo log crypto: generate " - "%u-byte random number as crypto msg failed.\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: generate " + "%u-byte random number as crypto msg failed.", PURPOSE_BYTE_LEN); abort(); } if (my_random_bytes(aes_ctr_nonce, MY_AES_BLOCK_SIZE) != AES_OK) { - fprintf(stderr, - "\nInnoDB redo log crypto: generate " - "%u-byte random number as AES_CTR nonce failed.\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: generate " + "%u-byte random number as AES_CTR nonce failed.", MY_AES_BLOCK_SIZE); abort(); } @@ -81,16 +101,17 @@ log_init_crypt_key( { if (crypt_ver == UNENCRYPTED_KEY_VER) { - fprintf(stderr, "\nInnoDB redo log crypto: unencrypted key ver.\n\n"); + ib_logf(IB_LOG_LEVEL_INFO, + "Redo log crypto: unencrypted key ver."); memset(key, 0, MY_AES_BLOCK_SIZE); return; } if (crypt_msg[PURPOSE_BYTE_OFFSET] != redo_log_purpose_byte) { - fprintf(stderr, - "\nInnoDB redo log crypto: msg type mismatched. " - "Expected: %x; Actual: %x\n", + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: msg type mismatched. " + "Expected: %x; Actual: %x.", redo_log_purpose_byte, crypt_msg[PURPOSE_BYTE_OFFSET]); abort(); } @@ -98,9 +119,9 @@ log_init_crypt_key( byte mysqld_key[MY_AES_BLOCK_SIZE] = {0}; if (get_encryption_key(crypt_ver, mysqld_key, MY_AES_BLOCK_SIZE)) { - fprintf(stderr, - "\nInnoDB redo log crypto: getting mysqld crypto key " - "from key version failed.\n"); + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: getting mysqld crypto key " + "from key version failed."); abort(); } @@ -114,9 +135,9 @@ log_init_crypt_key( if (rc != AES_OK || dst_len != MY_AES_BLOCK_SIZE) { - fprintf(stderr, - "\nInnoDB redo log crypto: getting redo log crypto key " - "failed.\n"); + ib_logf(IB_LOG_LEVEL_ERROR, + "Redo log crypto: getting redo log crypto key " + "failed."); abort(); } } @@ -248,9 +269,11 @@ log_crypt_set_ver_and_key( vkey == (unsigned int)CRYPT_KEY_UNKNOWN) { encrypted = false; - fprintf(stderr, "\nInnoDB redo log crypto: Can't initialize to key version %du\n", + ib_logf(IB_LOG_LEVEL_WARN, + "Redo log crypto: Can't initialize to key version %du.", key_ver); - fprintf(stderr, "InnoDB: [Warning] Disabling redo log encryption\n"); + ib_logf(IB_LOG_LEVEL_WARN, + "Disabling redo log encryption."); srv_encrypt_log = FALSE; } else { key_ver = vkey; |