mariadb/storage/xtradb/include/fil0fil.ic
Marko Mäkelä f5eb37129f MDEV-13103 Deal with page_compressed page corruption
fil_page_decompress(): Replaces fil_decompress_page().
Allow the caller detect errors. Remove
duplicated code. Use the "safe" instead of "fast" variants of
decompression routines.

fil_page_compress(): Replaces fil_compress_page().
The length of the input buffer always was srv_page_size (innodb_page_size).
Remove printouts, and remove the fil_space_t* parameter.

buf_tmp_buffer_t::reserved: Make private; the accessors acquire()
and release() will use atomic memory access.

buf_pool_reserve_tmp_slot(): Make static. Remove the second parameter.
Do not acquire any mutex. Remove the allocation of the buffers.

buf_tmp_reserve_crypt_buf(), buf_tmp_reserve_compression_buf():
Refactored away from buf_pool_reserve_tmp_slot().

buf_page_decrypt_after_read(): Make static, and simplify the logic.
Use the encryption buffer also for decompressing.

buf_page_io_complete(), buf_dblwr_process(): Check more failures.

fil_space_encrypt(): Simplify the debug checks.

fil_space_t::printed_compression_failure: Remove.

fil_get_compression_alg_name(): Remove.

fil_iterate(): Allocate a buffer for compression and decompression
only once, instead of allocating and freeing it for every page
that uses compression, during IMPORT TABLESPACE.

fil_node_get_space_id(), fil_page_is_index_page(),
fil_page_is_lzo_compressed(): Remove (unused code).
2018-06-14 13:46:07 +03:00

144 lines
4.4 KiB
Text

/*****************************************************************************
Copyright (c) 2015, 2018, MariaDB Corporation.
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 Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
/**************************************************//**
@file include/fil0fil.ic
The low-level file system support functions
Created 31/03/2015 Jan Lindström
*******************************************************/
#ifndef fil0fil_ic
#define fil0fil_ic
/*******************************************************************//**
Return page type name */
UNIV_INLINE
const char*
fil_get_page_type_name(
/*===================*/
ulint page_type) /*!< in: FIL_PAGE_TYPE */
{
switch(page_type) {
case FIL_PAGE_PAGE_COMPRESSED:
return "PAGE_COMPRESSED";
case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED:
return "PAGE_COMPRESSED_ENCRYPTED";
case FIL_PAGE_INDEX:
return "INDEX";
case FIL_PAGE_UNDO_LOG:
return "UNDO LOG";
case FIL_PAGE_INODE:
return "INODE";
case FIL_PAGE_IBUF_FREE_LIST:
return "IBUF_FREE_LIST";
case FIL_PAGE_TYPE_ALLOCATED:
return "ALLOCATED";
case FIL_PAGE_IBUF_BITMAP:
return "IBUF_BITMAP";
case FIL_PAGE_TYPE_SYS:
return "SYS";
case FIL_PAGE_TYPE_TRX_SYS:
return "TRX_SYS";
case FIL_PAGE_TYPE_FSP_HDR:
return "FSP_HDR";
case FIL_PAGE_TYPE_XDES:
return "XDES";
case FIL_PAGE_TYPE_BLOB:
return "BLOB";
case FIL_PAGE_TYPE_ZBLOB:
return "ZBLOB";
case FIL_PAGE_TYPE_ZBLOB2:
return "ZBLOB2";
}
return "PAGE TYPE CORRUPTED";
}
/****************************************************************//**
Get block size from fil node
@return block size*/
UNIV_INLINE
ulint
fil_node_get_block_size(
/*====================*/
fil_node_t* node) /*!< in: Node where to get block
size */
{
return (node->file_block_size);
}
/****************************************************************//**
Validate page type.
@return true if valid, false if not */
UNIV_INLINE
bool
fil_page_type_validate(
const byte* page) /*!< in: page */
{
#ifdef UNIV_DEBUG
ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE);
/* Validate page type */
if (!((page_type == FIL_PAGE_PAGE_COMPRESSED ||
page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED ||
page_type == FIL_PAGE_INDEX ||
page_type == FIL_PAGE_UNDO_LOG ||
page_type == FIL_PAGE_INODE ||
page_type == FIL_PAGE_IBUF_FREE_LIST ||
page_type == FIL_PAGE_TYPE_ALLOCATED ||
page_type == FIL_PAGE_IBUF_BITMAP ||
page_type == FIL_PAGE_TYPE_SYS ||
page_type == FIL_PAGE_TYPE_TRX_SYS ||
page_type == FIL_PAGE_TYPE_FSP_HDR ||
page_type == FIL_PAGE_TYPE_XDES ||
page_type == FIL_PAGE_TYPE_BLOB ||
page_type == FIL_PAGE_TYPE_ZBLOB ||
page_type == FIL_PAGE_TYPE_ZBLOB2))) {
ulint key_version = mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION);
bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED);
bool page_compressed_encrypted = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED);
ulint space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
ulint offset = mach_read_from_4(page + FIL_PAGE_OFFSET);
ib_uint64_t lsn = mach_read_from_8(page + FIL_PAGE_LSN);
ulint compressed_len = mach_read_from_2(page + FIL_PAGE_DATA);
fil_system_enter();
fil_space_t* rspace = fil_space_get_by_id(space);
fil_system_exit();
/* Dump out the page info */
fprintf(stderr, "InnoDB: Page " ULINTPF ":" ULINTPF
" name %s page_type " ULINTPF " page_type_name %s\n"
"InnoDB: key_version " ULINTPF
" page_compressed %d page_compressed_encrypted %d lsn "
LSN_PF " compressed_len " ULINTPF "\n",
space, offset, rspace->name, page_type,
fil_get_page_type_name(page_type),
key_version,
page_compressed, page_compressed_encrypted,
lsn, compressed_len);
ut_error;
return false;
}
#endif /* UNIV_DEBUG */
return true;
}
#endif /* fil0fil_ic */